Prevent malicious code execution through uploaded image files
This is a small but handy package to prevent malicious code execution coming into your application through uploaded images. It was created after being inspired by @appelsiini's talk on How to Hack your Laravel Application
You can install the package via composer:
composer require laravel-at/laravel-image-sanitize
Register the
ImageSanitizeMiddlewarein your
App\Http\Kernelclass ``` php protected $routeMiddleware = [ // ... 'image-sanitize' => \LaravelAt\ImageSanitize\ImageSanitizeMiddleware::class, ];
Then, just use it in your Controller's constructor ``` php public function __construct() { $this->middleware('image-sanitize'); }
Or use it in your
routes/web.phpfile
php Route::post('/files', '[email protected]') ->name('file.upload') ->middleware(['image-sanitize']);
If you want to learn more about
middlewares, please check out the official Laravel documentation
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.