[9.x] Adding additional PHP extensions to shouldBlockPhpUpload Function #44512
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adding additional PHP extensions to shouldBlockPhpUpload() Function
Some webserver configurations will treat php7 and php8 as a valid php extensions will execute them as a normal php file.
Laravel by default will block list of php extensions from being uploaded using shouldBlockPhpUpload function.
Yet by using this function the application can not prevent uploading php files using php7 or php8 extentions which some webservers will treat them as a normal php code and will execute it.
To prevent uploading php7 or php8 files i just added php7,php8 to blocked php extensions.
Vulnerable webservers
Duirng my research i found out, A lot of cloud and host providers will configure there webservers to execute php7 and php8 file extensions as a normal php file.
Here is an example of vulnrable configured apache2 webserver.
This is contents of /etc/apache2/conf/mime.types file
Fixing Webservers
Make sure your webserver configuration didn't treat other php extension types as a valid php file like example above.
Also you can add .htaccess file to uploads directory to prevent execution of php in uploads directory which is controlled by end users.
Add this to .htaccess file in uploads directory