Skip to content

Commit 3420259

Browse files
committed
security fix: avoid excutable files being uploaded
1 parent 8d8a7de commit 3420259

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/LfmPath.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function sortByColumn($arr_items)
209209

210210
public function error($error_type, $variables = [])
211211
{
212-
return $this->helper->error($error_type, $variables);
212+
throw new \Exception($this->helper->error($error_type, $variables));
213213
}
214214

215215
// Upload section
@@ -250,8 +250,15 @@ private function uploadValidator($file)
250250
return $this->error('file-exist');
251251
}
252252

253+
$mimetype = $file->getMimeType();
254+
255+
$excutable = ['text/x-php'];
256+
257+
if (in_array($mimetype, $excutable)) {
258+
throw new \Exception('Invalid file detected');
259+
}
260+
253261
if (config('lfm.should_validate_mime', false)) {
254-
$mimetype = $file->getMimeType();
255262
if (false === in_array($mimetype, $this->helper->availableMimeTypes())) {
256263
return $this->error('mime') . $mimetype;
257264
}

0 commit comments

Comments
 (0)