Skip to content

Commit d951c13

Browse files
committed
security fix: avoid downloading inappropriate files
1 parent 3b189ce commit d951c13

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/Controllers/DownloadController.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22

33
namespace UniSharp\LaravelFilemanager\Controllers;
44

5+
use Illuminate\Support\Facades\Storage;
6+
57
class DownloadController extends LfmController
68
{
79
public function getDownload()
810
{
9-
return response()->download($this->lfm->setName(request('file'))->path('absolute'));
11+
$file = $this->lfm->setName(request('file'));
12+
13+
if (!Storage::disk($this->helper->config('disk'))->exists($file->path('storage'))) {
14+
abort(404);
15+
}
16+
17+
return response()->download($file->path('absolute'));
1018
}
1119
}

src/Controllers/LfmController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function error($error_type, $variables = [])
8484
public function applyIniOverrides()
8585
{
8686
$overrides = config('lfm.php_ini_overrides', []);
87-
87+
8888
if ($overrides && is_array($overrides) && count($overrides) === 0) {
8989
return;
9090
}

0 commit comments

Comments
 (0)