From d83682f7bcb5f258a3b549bcaf6ffb400bff6a53 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Wed, 21 Oct 2026 17:10:15 -0700 Subject: [PATCH 1/3] Refuse .php URLs under /storage/ by default in the frankenphp images The Livewire upload RCE (GHSA-29cq-5w36-x7w3) was exploited by dropping a .php file into Laravel's storage and requesting it, and the base image executed it (verified: /storage/x.php, /storage/X.PHP, x.php/foo, //, ./, .. and percent-encoded forms all ran). docker-configure now renders a rule that 404s any /storage/ URL naming a .php file; PHP_DENY_STORAGE_PHP=off disables it. A no-exec handle on /storage/* was not used because it also 404s requests with no file behind them, which breaks Laravel 11+'s local-disk serve route (GET /storage/{path}, answered by PHP). The new rule keys on the .php name only, so that route, uploads and other URLs still work. The smoke test now asserts the rule, so CI keeps proving it. ALI-1116 --- .github/scripts/smoke-test.sh | 19 ++++++++++++++++++- README.md | 10 +++++++--- php/8.2/frankenphp/Dockerfile | 1 + php/8.2/frankenphp/docker-configure | 17 +++++++++++++++++ php/8.3/frankenphp/Dockerfile | 1 + php/8.3/frankenphp/docker-configure | 17 +++++++++++++++++ php/8.4/frankenphp/Dockerfile | 1 + php/8.4/frankenphp/docker-configure | 17 +++++++++++++++++ php/8.5/frankenphp/Dockerfile | 1 + php/8.5/frankenphp/docker-configure | 17 +++++++++++++++++ 10 files changed, 97 insertions(+), 4 deletions(-) diff --git a/.github/scripts/smoke-test.sh b/.github/scripts/smoke-test.sh index 6654728..e2ac4e6 100755 --- a/.github/scripts/smoke-test.sh +++ b/.github/scripts/smoke-test.sh @@ -68,7 +68,11 @@ trap cleanup EXIT # A page that reports what the server's own PHP looks like. The container user # is not the runner's, so the fixture must be world-readable. -mkdir -p "$fixture/public" +mkdir -p "$fixture/public/storage" +# A script an attacker could drop under /storage/ (Livewire GHSA-29cq-5w36-x7w3), +# and an ordinary upload next to it. +echo ' "$fixture/public/storage/shell.php" +echo 'upload' > "$fixture/public/storage/hello.txt" cat > "$fixture/public/index.php" <<'PHP' temporaryUrl()` links. + +The rule covers only the URL path `/storage/`. For other directories the app can write to, `PHP_NO_EXEC_PATHS` goes further: nothing under those prefixes can ever reach the PHP handler, so a request for a path with no file behind it gets a 404 rather than falling through to the app (which is why it is not the default for `/storage/`). ```sh -docker run -e PHP_NO_EXEC_PATHS="/storage/*" \ +docker run -e PHP_NO_EXEC_PATHS="/uploads/*" \ -e CADDY_IMMUTABLE_ASSET_PATHS="/build/" \ -e CADDY_MEDIA_PATHS="/storage/" \ ghcr.io/aliasproject/php:8.4-frankenphp ``` -Requests for PHP source under that path (any case, e.g. `shell.PHP`, or with trailing path info, e.g. `shell.php/foo`) never execute: they return 404 or 400, or (with a trailing slash) redirect to a URL that returns 404. Images and other files in the directory are still served, so `public/storage` uploads keep working. The rule covers only the URL path `/storage/`; if the app serves uploads or other writable files from another public path, add it too, space-separated (`PHP_NO_EXEC_PATHS="/storage/* /uploads/*"`). `PHP_NO_EXEC_PATHS` replaces the default rather than appending, so a derived image or `docker run` that sets it must list every path it wants protected. +Requests for PHP source under a `PHP_NO_EXEC_PATHS` prefix (any case, or with trailing path info) never execute: they return 404 or 400, or (with a trailing slash) redirect to a URL that returns 404. Images and other files in the directory are still served. Add more prefixes space-separated (`PHP_NO_EXEC_PATHS="/uploads/* /files/*"`). `PHP_NO_EXEC_PATHS` replaces the default rather than appending, so a derived image or `docker run` that sets it must list every path it wants protected. ## WordPress hardening diff --git a/php/8.2/frankenphp/Dockerfile b/php/8.2/frankenphp/Dockerfile index 6242ebc..534c32c 100644 --- a/php/8.2/frankenphp/Dockerfile +++ b/php/8.2/frankenphp/Dockerfile @@ -32,6 +32,7 @@ ENV PHP_MEMORY_LIMIT=256M \ PHP_NO_EXEC_HIDE_EXTENSIONS="php phtml phar phps php3 php4 php5 php6 php7 php8 inc" \ PHP_DENY_PATHS= \ PHP_DENY_EXTENSIONS= \ + PHP_DENY_STORAGE_PHP=on \ CADDY_ACCESS_LOG=on \ CADDY_ACCESS_LOG_PATH=/data/caddy/access.log \ MSMTP_RELAY_SERVER_HOST=mailhog \ diff --git a/php/8.2/frankenphp/docker-configure b/php/8.2/frankenphp/docker-configure index ba99f08..f590f77 100644 --- a/php/8.2/frankenphp/docker-configure +++ b/php/8.2/frankenphp/docker-configure @@ -110,6 +110,23 @@ ext_alternation() { echo "}" fi + # Laravel's storage directory holds user-controlled files, and the Livewire + # upload RCE (GHSA-29cq-5w36-x7w3) was exploited in the wild by dropping a + # .php file there and requesting it. Nothing legitimately executes PHP from + # a /storage/ URL, so refuse any URL under it that names a .php file: any + # case, any depth, with or without trailing path info (which is how + # php_server splits it). Deliberately NOT `handle /storage/*` + file_server + # like the no-exec paths below: that also 404s requests with no file behind + # them, which breaks Laravel 11+'s local-disk serve route (GET + # /storage/{path}, answered by PHP). Everything else under /storage/ still + # reaches php_server and the static file handler. + if [ "${PHP_DENY_STORAGE_PHP:-on}" = "on" ]; then + echo "@storage_php path_regexp (?i)^/storage/.*\\.php(/|\$)" + echo "handle @storage_php {" + echo " respond 404" + echo "}" + fi + # Paths the application can WRITE to must never EXECUTE. `handle` is # terminal and contains only file_server, so requests matching these # prefixes can never reach the PHP handler -- regardless of extension diff --git a/php/8.3/frankenphp/Dockerfile b/php/8.3/frankenphp/Dockerfile index 578c9af..49e1029 100644 --- a/php/8.3/frankenphp/Dockerfile +++ b/php/8.3/frankenphp/Dockerfile @@ -32,6 +32,7 @@ ENV PHP_MEMORY_LIMIT=256M \ PHP_NO_EXEC_HIDE_EXTENSIONS="php phtml phar phps php3 php4 php5 php6 php7 php8 inc" \ PHP_DENY_PATHS= \ PHP_DENY_EXTENSIONS= \ + PHP_DENY_STORAGE_PHP=on \ CADDY_ACCESS_LOG=on \ CADDY_ACCESS_LOG_PATH=/data/caddy/access.log \ MSMTP_RELAY_SERVER_HOST=mailhog \ diff --git a/php/8.3/frankenphp/docker-configure b/php/8.3/frankenphp/docker-configure index ba99f08..f590f77 100644 --- a/php/8.3/frankenphp/docker-configure +++ b/php/8.3/frankenphp/docker-configure @@ -110,6 +110,23 @@ ext_alternation() { echo "}" fi + # Laravel's storage directory holds user-controlled files, and the Livewire + # upload RCE (GHSA-29cq-5w36-x7w3) was exploited in the wild by dropping a + # .php file there and requesting it. Nothing legitimately executes PHP from + # a /storage/ URL, so refuse any URL under it that names a .php file: any + # case, any depth, with or without trailing path info (which is how + # php_server splits it). Deliberately NOT `handle /storage/*` + file_server + # like the no-exec paths below: that also 404s requests with no file behind + # them, which breaks Laravel 11+'s local-disk serve route (GET + # /storage/{path}, answered by PHP). Everything else under /storage/ still + # reaches php_server and the static file handler. + if [ "${PHP_DENY_STORAGE_PHP:-on}" = "on" ]; then + echo "@storage_php path_regexp (?i)^/storage/.*\\.php(/|\$)" + echo "handle @storage_php {" + echo " respond 404" + echo "}" + fi + # Paths the application can WRITE to must never EXECUTE. `handle` is # terminal and contains only file_server, so requests matching these # prefixes can never reach the PHP handler -- regardless of extension diff --git a/php/8.4/frankenphp/Dockerfile b/php/8.4/frankenphp/Dockerfile index f844453..d335357 100644 --- a/php/8.4/frankenphp/Dockerfile +++ b/php/8.4/frankenphp/Dockerfile @@ -32,6 +32,7 @@ ENV PHP_MEMORY_LIMIT=256M \ PHP_NO_EXEC_HIDE_EXTENSIONS="php phtml phar phps php3 php4 php5 php6 php7 php8 inc" \ PHP_DENY_PATHS= \ PHP_DENY_EXTENSIONS= \ + PHP_DENY_STORAGE_PHP=on \ CADDY_ACCESS_LOG=on \ CADDY_ACCESS_LOG_PATH=/data/caddy/access.log \ MSMTP_RELAY_SERVER_HOST=mailhog \ diff --git a/php/8.4/frankenphp/docker-configure b/php/8.4/frankenphp/docker-configure index ba99f08..f590f77 100644 --- a/php/8.4/frankenphp/docker-configure +++ b/php/8.4/frankenphp/docker-configure @@ -110,6 +110,23 @@ ext_alternation() { echo "}" fi + # Laravel's storage directory holds user-controlled files, and the Livewire + # upload RCE (GHSA-29cq-5w36-x7w3) was exploited in the wild by dropping a + # .php file there and requesting it. Nothing legitimately executes PHP from + # a /storage/ URL, so refuse any URL under it that names a .php file: any + # case, any depth, with or without trailing path info (which is how + # php_server splits it). Deliberately NOT `handle /storage/*` + file_server + # like the no-exec paths below: that also 404s requests with no file behind + # them, which breaks Laravel 11+'s local-disk serve route (GET + # /storage/{path}, answered by PHP). Everything else under /storage/ still + # reaches php_server and the static file handler. + if [ "${PHP_DENY_STORAGE_PHP:-on}" = "on" ]; then + echo "@storage_php path_regexp (?i)^/storage/.*\\.php(/|\$)" + echo "handle @storage_php {" + echo " respond 404" + echo "}" + fi + # Paths the application can WRITE to must never EXECUTE. `handle` is # terminal and contains only file_server, so requests matching these # prefixes can never reach the PHP handler -- regardless of extension diff --git a/php/8.5/frankenphp/Dockerfile b/php/8.5/frankenphp/Dockerfile index 3438d80..a484eb8 100644 --- a/php/8.5/frankenphp/Dockerfile +++ b/php/8.5/frankenphp/Dockerfile @@ -32,6 +32,7 @@ ENV PHP_MEMORY_LIMIT=256M \ PHP_NO_EXEC_HIDE_EXTENSIONS="php phtml phar phps php3 php4 php5 php6 php7 php8 inc" \ PHP_DENY_PATHS= \ PHP_DENY_EXTENSIONS= \ + PHP_DENY_STORAGE_PHP=on \ CADDY_ACCESS_LOG=on \ CADDY_ACCESS_LOG_PATH=/data/caddy/access.log \ MSMTP_RELAY_SERVER_HOST=mailhog \ diff --git a/php/8.5/frankenphp/docker-configure b/php/8.5/frankenphp/docker-configure index ba99f08..f590f77 100644 --- a/php/8.5/frankenphp/docker-configure +++ b/php/8.5/frankenphp/docker-configure @@ -110,6 +110,23 @@ ext_alternation() { echo "}" fi + # Laravel's storage directory holds user-controlled files, and the Livewire + # upload RCE (GHSA-29cq-5w36-x7w3) was exploited in the wild by dropping a + # .php file there and requesting it. Nothing legitimately executes PHP from + # a /storage/ URL, so refuse any URL under it that names a .php file: any + # case, any depth, with or without trailing path info (which is how + # php_server splits it). Deliberately NOT `handle /storage/*` + file_server + # like the no-exec paths below: that also 404s requests with no file behind + # them, which breaks Laravel 11+'s local-disk serve route (GET + # /storage/{path}, answered by PHP). Everything else under /storage/ still + # reaches php_server and the static file handler. + if [ "${PHP_DENY_STORAGE_PHP:-on}" = "on" ]; then + echo "@storage_php path_regexp (?i)^/storage/.*\\.php(/|\$)" + echo "handle @storage_php {" + echo " respond 404" + echo "}" + fi + # Paths the application can WRITE to must never EXECUTE. `handle` is # terminal and contains only file_server, so requests matching these # prefixes can never reach the PHP handler -- regardless of extension From cdb79f0c72fc0f1005ecf96de83a4d62776fabe3 Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Wed, 21 Oct 2026 17:15:52 -0700 Subject: [PATCH 2/3] Also refuse /storage/ directory URLs: php_server runs their index.php Review of #16 found a bypass: GET /storage/ or /storage/dir/ never names a .php file, but php_server answers it by running that directory's index.php (verified: both returned 200 and executed it with the first version of the rule; /storage/dir redirects to the slash form). The rule now also matches any URL ending in a slash, plus /storage/ itself. Also make only an explicit off/0/false/no disable the rule, so a value like 'true' or a typo cannot silently turn the protection off, and add the directory case to the smoke test (the first version of the rule fails it). --- .github/scripts/smoke-test.sh | 8 ++++++- README.md | 4 ++-- php/8.2/frankenphp/docker-configure | 35 ++++++++++++++++++----------- php/8.3/frankenphp/docker-configure | 35 ++++++++++++++++++----------- php/8.4/frankenphp/docker-configure | 35 ++++++++++++++++++----------- php/8.5/frankenphp/docker-configure | 35 ++++++++++++++++++----------- 6 files changed, 97 insertions(+), 55 deletions(-) diff --git a/.github/scripts/smoke-test.sh b/.github/scripts/smoke-test.sh index e2ac4e6..53ed2f4 100755 --- a/.github/scripts/smoke-test.sh +++ b/.github/scripts/smoke-test.sh @@ -68,10 +68,11 @@ trap cleanup EXIT # A page that reports what the server's own PHP looks like. The container user # is not the runner's, so the fixture must be world-readable. -mkdir -p "$fixture/public/storage" +mkdir -p "$fixture/public/storage/idx" # A script an attacker could drop under /storage/ (Livewire GHSA-29cq-5w36-x7w3), # and an ordinary upload next to it. echo ' "$fixture/public/storage/shell.php" +echo ' "$fixture/public/storage/idx/index.php" echo 'upload' > "$fixture/public/storage/hello.txt" cat > "$fixture/public/index.php" <<'PHP' temporaryUrl()` links. +Only those URLs are refused. Everything else under `/storage/` is handled as usual: uploads in `public/storage` are served as static files, and a PHP route at `/storage/{path}` still works, such as Laravel 11+'s local-disk `serve` route for signed `Storage::disk('local')->temporaryUrl()` links. The rule covers only the URL path `/storage/`. For other directories the app can write to, `PHP_NO_EXEC_PATHS` goes further: nothing under those prefixes can ever reach the PHP handler, so a request for a path with no file behind it gets a 404 rather than falling through to the app (which is why it is not the default for `/storage/`). diff --git a/php/8.2/frankenphp/docker-configure b/php/8.2/frankenphp/docker-configure index f590f77..407d255 100644 --- a/php/8.2/frankenphp/docker-configure +++ b/php/8.2/frankenphp/docker-configure @@ -113,19 +113,28 @@ ext_alternation() { # Laravel's storage directory holds user-controlled files, and the Livewire # upload RCE (GHSA-29cq-5w36-x7w3) was exploited in the wild by dropping a # .php file there and requesting it. Nothing legitimately executes PHP from - # a /storage/ URL, so refuse any URL under it that names a .php file: any - # case, any depth, with or without trailing path info (which is how - # php_server splits it). Deliberately NOT `handle /storage/*` + file_server - # like the no-exec paths below: that also 404s requests with no file behind - # them, which breaks Laravel 11+'s local-disk serve route (GET - # /storage/{path}, answered by PHP). Everything else under /storage/ still - # reaches php_server and the static file handler. - if [ "${PHP_DENY_STORAGE_PHP:-on}" = "on" ]; then - echo "@storage_php path_regexp (?i)^/storage/.*\\.php(/|\$)" - echo "handle @storage_php {" - echo " respond 404" - echo "}" - fi + # a /storage/ URL, so refuse two kinds of URL under it: + # - one that names a .php file: any case, any depth, with or without + # trailing path info (which is how php_server splits it); + # - a directory URL (trailing slash, or /storage/ itself): php_server + # answers those by running the directory's index.php, without the URL + # ever naming a .php file. A request for the directory without the + # slash is redirected to the slash form, so it lands here too. + # Deliberately NOT `handle /storage/*` + file_server like the no-exec paths + # below: that also 404s requests with no file behind them, which breaks + # Laravel 11+'s local-disk serve route (GET /storage/{path}, answered by + # PHP). Everything else under /storage/ still reaches php_server and the + # static file handler. Only an explicit off/0/false/no turns this off, so a + # mistyped value cannot silently disable the protection. + case "${PHP_DENY_STORAGE_PHP:-on}" in + off | OFF | Off | 0 | false | FALSE | False | no | NO | No) ;; + *) + echo "@storage_php path_regexp (?i)^/storage/(.*\\.php(/|\$)|(.*/)?\$)" + echo "handle @storage_php {" + echo " respond 404" + echo "}" + ;; + esac # Paths the application can WRITE to must never EXECUTE. `handle` is # terminal and contains only file_server, so requests matching these diff --git a/php/8.3/frankenphp/docker-configure b/php/8.3/frankenphp/docker-configure index f590f77..407d255 100644 --- a/php/8.3/frankenphp/docker-configure +++ b/php/8.3/frankenphp/docker-configure @@ -113,19 +113,28 @@ ext_alternation() { # Laravel's storage directory holds user-controlled files, and the Livewire # upload RCE (GHSA-29cq-5w36-x7w3) was exploited in the wild by dropping a # .php file there and requesting it. Nothing legitimately executes PHP from - # a /storage/ URL, so refuse any URL under it that names a .php file: any - # case, any depth, with or without trailing path info (which is how - # php_server splits it). Deliberately NOT `handle /storage/*` + file_server - # like the no-exec paths below: that also 404s requests with no file behind - # them, which breaks Laravel 11+'s local-disk serve route (GET - # /storage/{path}, answered by PHP). Everything else under /storage/ still - # reaches php_server and the static file handler. - if [ "${PHP_DENY_STORAGE_PHP:-on}" = "on" ]; then - echo "@storage_php path_regexp (?i)^/storage/.*\\.php(/|\$)" - echo "handle @storage_php {" - echo " respond 404" - echo "}" - fi + # a /storage/ URL, so refuse two kinds of URL under it: + # - one that names a .php file: any case, any depth, with or without + # trailing path info (which is how php_server splits it); + # - a directory URL (trailing slash, or /storage/ itself): php_server + # answers those by running the directory's index.php, without the URL + # ever naming a .php file. A request for the directory without the + # slash is redirected to the slash form, so it lands here too. + # Deliberately NOT `handle /storage/*` + file_server like the no-exec paths + # below: that also 404s requests with no file behind them, which breaks + # Laravel 11+'s local-disk serve route (GET /storage/{path}, answered by + # PHP). Everything else under /storage/ still reaches php_server and the + # static file handler. Only an explicit off/0/false/no turns this off, so a + # mistyped value cannot silently disable the protection. + case "${PHP_DENY_STORAGE_PHP:-on}" in + off | OFF | Off | 0 | false | FALSE | False | no | NO | No) ;; + *) + echo "@storage_php path_regexp (?i)^/storage/(.*\\.php(/|\$)|(.*/)?\$)" + echo "handle @storage_php {" + echo " respond 404" + echo "}" + ;; + esac # Paths the application can WRITE to must never EXECUTE. `handle` is # terminal and contains only file_server, so requests matching these diff --git a/php/8.4/frankenphp/docker-configure b/php/8.4/frankenphp/docker-configure index f590f77..407d255 100644 --- a/php/8.4/frankenphp/docker-configure +++ b/php/8.4/frankenphp/docker-configure @@ -113,19 +113,28 @@ ext_alternation() { # Laravel's storage directory holds user-controlled files, and the Livewire # upload RCE (GHSA-29cq-5w36-x7w3) was exploited in the wild by dropping a # .php file there and requesting it. Nothing legitimately executes PHP from - # a /storage/ URL, so refuse any URL under it that names a .php file: any - # case, any depth, with or without trailing path info (which is how - # php_server splits it). Deliberately NOT `handle /storage/*` + file_server - # like the no-exec paths below: that also 404s requests with no file behind - # them, which breaks Laravel 11+'s local-disk serve route (GET - # /storage/{path}, answered by PHP). Everything else under /storage/ still - # reaches php_server and the static file handler. - if [ "${PHP_DENY_STORAGE_PHP:-on}" = "on" ]; then - echo "@storage_php path_regexp (?i)^/storage/.*\\.php(/|\$)" - echo "handle @storage_php {" - echo " respond 404" - echo "}" - fi + # a /storage/ URL, so refuse two kinds of URL under it: + # - one that names a .php file: any case, any depth, with or without + # trailing path info (which is how php_server splits it); + # - a directory URL (trailing slash, or /storage/ itself): php_server + # answers those by running the directory's index.php, without the URL + # ever naming a .php file. A request for the directory without the + # slash is redirected to the slash form, so it lands here too. + # Deliberately NOT `handle /storage/*` + file_server like the no-exec paths + # below: that also 404s requests with no file behind them, which breaks + # Laravel 11+'s local-disk serve route (GET /storage/{path}, answered by + # PHP). Everything else under /storage/ still reaches php_server and the + # static file handler. Only an explicit off/0/false/no turns this off, so a + # mistyped value cannot silently disable the protection. + case "${PHP_DENY_STORAGE_PHP:-on}" in + off | OFF | Off | 0 | false | FALSE | False | no | NO | No) ;; + *) + echo "@storage_php path_regexp (?i)^/storage/(.*\\.php(/|\$)|(.*/)?\$)" + echo "handle @storage_php {" + echo " respond 404" + echo "}" + ;; + esac # Paths the application can WRITE to must never EXECUTE. `handle` is # terminal and contains only file_server, so requests matching these diff --git a/php/8.5/frankenphp/docker-configure b/php/8.5/frankenphp/docker-configure index f590f77..407d255 100644 --- a/php/8.5/frankenphp/docker-configure +++ b/php/8.5/frankenphp/docker-configure @@ -113,19 +113,28 @@ ext_alternation() { # Laravel's storage directory holds user-controlled files, and the Livewire # upload RCE (GHSA-29cq-5w36-x7w3) was exploited in the wild by dropping a # .php file there and requesting it. Nothing legitimately executes PHP from - # a /storage/ URL, so refuse any URL under it that names a .php file: any - # case, any depth, with or without trailing path info (which is how - # php_server splits it). Deliberately NOT `handle /storage/*` + file_server - # like the no-exec paths below: that also 404s requests with no file behind - # them, which breaks Laravel 11+'s local-disk serve route (GET - # /storage/{path}, answered by PHP). Everything else under /storage/ still - # reaches php_server and the static file handler. - if [ "${PHP_DENY_STORAGE_PHP:-on}" = "on" ]; then - echo "@storage_php path_regexp (?i)^/storage/.*\\.php(/|\$)" - echo "handle @storage_php {" - echo " respond 404" - echo "}" - fi + # a /storage/ URL, so refuse two kinds of URL under it: + # - one that names a .php file: any case, any depth, with or without + # trailing path info (which is how php_server splits it); + # - a directory URL (trailing slash, or /storage/ itself): php_server + # answers those by running the directory's index.php, without the URL + # ever naming a .php file. A request for the directory without the + # slash is redirected to the slash form, so it lands here too. + # Deliberately NOT `handle /storage/*` + file_server like the no-exec paths + # below: that also 404s requests with no file behind them, which breaks + # Laravel 11+'s local-disk serve route (GET /storage/{path}, answered by + # PHP). Everything else under /storage/ still reaches php_server and the + # static file handler. Only an explicit off/0/false/no turns this off, so a + # mistyped value cannot silently disable the protection. + case "${PHP_DENY_STORAGE_PHP:-on}" in + off | OFF | Off | 0 | false | FALSE | False | no | NO | No) ;; + *) + echo "@storage_php path_regexp (?i)^/storage/(.*\\.php(/|\$)|(.*/)?\$)" + echo "handle @storage_php {" + echo " respond 404" + echo "}" + ;; + esac # Paths the application can WRITE to must never EXECUTE. `handle` is # terminal and contains only file_server, so requests matching these From 5797e72e11c9b782354e788cfe04bb04a684829c Mon Sep 17 00:00:00 2001 From: Michael Aguiar Date: Wed, 21 Oct 2026 17:17:50 -0700 Subject: [PATCH 3/3] README: list the exact spellings that turn PHP_DENY_STORAGE_PHP off Review of #16: the README said any other value than off/0/false/no leaves the rule on, but the code also accepts OFF, Off, FALSE, False, NO and No. Verified: oFF, 'off ' and ' off' leave it on. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60cff4f..be1bd80 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ The `wordpress` variant sets both lists out of the box (see below). ## Laravel hardening -Laravel's `storage` directory holds user-controlled files, and the Livewire upload vulnerability ([GHSA-29cq-5w36-x7w3](https://github.com/livewire/livewire/security/advisories/GHSA-29cq-5w36-x7w3)) was exploited in the wild by dropping a `.php` file there and requesting `/storage/....php`. Every frankenphp image therefore refuses, with a 404, any URL under `/storage/` that names a `.php` file (any case such as `shell.PHP`, any depth, with or without trailing path info such as `shell.php/foo`, however the path is encoded) and any directory URL (`/storage/` or `/storage/dir/`), because the server would answer a directory by running its `index.php`. This is on by default; set `PHP_DENY_STORAGE_PHP=off` (or `0`, `false`, `no`) for an app that really does serve PHP from a `/storage/` URL. Any other value leaves the rule on. +Laravel's `storage` directory holds user-controlled files, and the Livewire upload vulnerability ([GHSA-29cq-5w36-x7w3](https://github.com/livewire/livewire/security/advisories/GHSA-29cq-5w36-x7w3)) was exploited in the wild by dropping a `.php` file there and requesting `/storage/....php`. Every frankenphp image therefore refuses, with a 404, any URL under `/storage/` that names a `.php` file (any case such as `shell.PHP`, any depth, with or without trailing path info such as `shell.php/foo`, however the path is encoded) and any directory URL (`/storage/` or `/storage/dir/`), because the server would answer a directory by running its `index.php`. This is on by default; set `PHP_DENY_STORAGE_PHP=off` for an app that really does serve PHP from a `/storage/` URL. The accepted spellings are `off`, `false` and `no` in lower case, upper case or capitalised (`off`, `OFF`, `Off`), and `0`; any other value, including `true`, `1` or a typo, leaves the rule on. Only those URLs are refused. Everything else under `/storage/` is handled as usual: uploads in `public/storage` are served as static files, and a PHP route at `/storage/{path}` still works, such as Laravel 11+'s local-disk `serve` route for signed `Storage::disk('local')->temporaryUrl()` links.