Skip to content

Commit 3ec1573

Browse files
committed
security fix: avoid deleting inappropriate files
1 parent d951c13 commit 3ec1573

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/Controllers/DeleteController.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace UniSharp\LaravelFilemanager\Controllers;
44

5+
use Illuminate\Support\Facades\Storage;
56
use UniSharp\LaravelFilemanager\Events\ImageIsDeleting;
67
use UniSharp\LaravelFilemanager\Events\ImageWasDeleted;
78

@@ -18,6 +19,12 @@ public function getDelete()
1819
$errors = [];
1920

2021
foreach ($item_names as $name_to_delete) {
22+
$file = $this->lfm->setName($name_to_delete);
23+
24+
if (!Storage::disk($this->helper->config('disk'))->exists($file->path('storage'))) {
25+
abort(404);
26+
}
27+
2128
$file_to_delete = $this->lfm->pretty($name_to_delete);
2229
$file_path = $file_to_delete->path();
2330

0 commit comments

Comments
 (0)