Skip to content

Commit

Permalink
Merge pull request #60 from Laravel-Backpack/prevent-mimes-tampering
Browse files Browse the repository at this point in the history
prevent mime types tampering
  • Loading branch information
pxpm authored Nov 18, 2024
2 parents d7d729d + 3275e4b commit 25b5c97
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/BackpackElfinderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,23 @@ public function showPopup($input_id)
{
$mimes = request('mimes');

if (! isset($mimes)) {
Log::error('Someone attempted to tamper with mime types in elfinder popup. The attempt was blocked.');
abort(403, 'Unauthorized action.');
}

try {
$mimes = Crypt::decrypt(urldecode(request('mimes')));
} catch (\Illuminate\Contracts\Encryption\DecryptException $e) {
Log::error('Someone attempted to tamper with mime types in elfinder popup. The attempt was blocked.');
abort(403, 'Unauthorized action.');
}

request()->merge(['mimes' => urlencode(serialize($mimes))]);
if (! empty($mimes)) {
request()->merge(['mimes' => urlencode(serialize($mimes))]);
} else {
request()->merge(['mimes' => '']);
}

return $this->app['view']
->make($this->package.'::standalonepopup')
Expand Down

0 comments on commit 25b5c97

Please sign in to comment.