php_server serves the Caddyfile when it is stored in the document root
Description
Impact
When the Caddyfile, or a file it imports, is stored under the document root of a php_server site, any client can download it with a GET /Caddyfile request. Values written inline in the Caddyfile, such as env values passed to PHP, Mercure JWT keys or basic_auth password hashes, are disclosed. Values referenced with {$VAR} or {env.VAR} are not.
This happens with the minimal layout shown in the documentation: a Caddyfile next to index.php, with no root, and FrankenPHP started from that directory. Caddy's file_server directive hides these files, and so does the php + file_server configuration documented as equivalent to php_server.
Patches
Fixed in 1.13.5.
Workarounds
Store the Caddyfile and its imports outside the document root, for instance by moving the PHP application to a public/ subdirectory and setting root. Alternatively, block the request before php_server, for instance with respond /Caddyfile 404.
Details
Caddy's file_server directive adds the Caddyfile being adapted and its imports to the hide list of the handler. This is done in FileServer.FinalizeUnmarshalCaddyfile(). php_server builds its file server without this step, so both the file server it adds at the end of its routes and the one it adds for worker { match } had an empty hide list.
php_server now calls FinalizeUnmarshalCaddyfile() on its file server.
Proof of concept
/srv/app/Caddyfile:
http://localhost {
php_server {
env DATABASE_PASSWORD secret
}
}$ cd /srv/app && frankenphp run
$ curl http://localhost/Caddyfile # returns the CaddyfileCredits
Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-30F8W2OH.