← PHP / Laravel · Contents

PHP-015 / Intermediate

Allowing script execution in upload directories

A05:2021 Security Misconfiguration · CWE-434 Unrestricted Upload of File with Dangerous Type

Why is this a problem?

If uploaded files can execute as PHP on the web, a single upload can become a web shell.

How to fix it

nginx
location /storage/uploads/ { location ~ \.php$ { return 403; } }
# Rule: upload to storage/app (private) and serve through a controller or signed URL

Further reading