Repository navigation
v5.1.3
🔐 Security update: fpm-nginx could run uploaded .phar files
Important
Pull and redeploy if you use fpm-nginx and your app accepts uploads into its public folder. A request like /uploads/file.phar/x.php made PHP-FPM run the uploaded file.phar (GHSA-8wf6-vq49-m6w2). Thanks to @jeremiesourabie92-svg for reporting it.
Note
cli and frankenphp are not affected. fpm and fpm-apache weren't exposed through our configs, but they get the new PHP-FPM default below too.
NGINX checks that a PHP script exists
Our NGINX config sent any request ending in .php to PHP-FPM, even if that file didn't exist. PHP-FPM then walked back up the path until it found a real file. For /uploads/file.phar/x.php, that's file.phar, so it ran it.
You were only exposed if your app accepts .phar uploads into a public folder outside /storage. Our images already return 403 for any .php path under /storage, which covers Laravel's public uploads. Images and other files were safe, because PHP-FPM only runs .php and .phar files this way.
NGINX now returns a 404 for a PHP script that doesn't exist, before the request reaches PHP-FPM. Our v1 and v2 images had this check through Ubuntu's fastcgi-php.conf. It got left behind when we moved to NGINX from nginx.org in v3.
PHP-FPM only runs .php files
Every FPM variation now sets security.limit_extensions = .php. PHP-FPM's default also allows .phar.
If you run fpm behind your own NGINX, this protects you from the .phar case. Add try_files $uri =404; to your PHP location too, so a missing script never reaches PHP-FPM:
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass php:9000;
# ...
}Two things that stop working
- Running a
.pharas a web script through PHP-FPM - URLs like
/script.php/extrafor any script exceptindex.phpnow return404./index.php/extrastill redirects to/extra, like before
How to update
| If you use | Example | Do this |
|---|---|---|
| A floating tag | 8.5-fpm-nginx |
Pull and redeploy |
| A release tag | 8.5-fpm-nginx-v5.1.2 |
Change it to 8.5-fpm-nginx-v5.1.3 |
| A patch version tag | 8.5.12-fpm-nginx |
Pull and redeploy |
If you build your own image FROM one of these, rebuild it too.
v4 will not get a fix. Upgrade to v5, or see the workaround in the advisory.
What's Changed
- Security: Return 404 for missing PHP scripts in NGINX and limit PHP-FPM to
.phpby @jaydrogers
Full Changelog: v5.1.2...v5.1.3