Skip to main content
Menu
Advisories

php_server in a Caddy named route runs with the root, env and workers of another site

GHSA-G7PW-WHV8-97J7Published Updated GitHub

Description

Impact

A php_server or php directive written in a Caddy named route (&(name) { ... }, used with invoke) can be attached to the PHP server of an unrelated php_server declared in a site block. Requests to the site invoking the named route then run the other site's PHP application, with its document root, env values and workers, and bypass the access rules of that other site.

For instance, if an intranet site restricted with remote_ip holds the first php_server of the site blocks, and a public site invokes a named route holding the first php_server of the named routes, any client of the public site reaches the intranet's front controller and the secrets it receives through env.

Only configurations using php_server or php inside named routes are affected.

Patches

Fixed in 1.13.5.

Workarounds

Don't use php_server or php in named routes: write the directive in the site blocks, or in a snippet imported with import.

Details

Each php_server directive gets a server_index, so the routes it generates (including the ones added for worker { match }) share one PHP server and its workers. The index is counted in httpcaddyfile.Helper.State, but Caddy adapts named routes with a State map of their own, so the n-th directive of the named routes got the same index as the n-th directive of the site blocks. At start-up, FrankenPHP reused the server already registered under that index and ignored the root, environment and workers of the second module.

FrankenPHP now shares a server only between modules whose configuration, index included, is identical before provisioning, and that use the same Mercure hub.

Proof of concept

&(shop) {
	php_server {
		root /srv/shop
	}
}

http://intranet.example.com {
	@outside not remote_ip 192.0.2.0/24
	respond @outside 403

	php_server {
		root /srv/intranet
		env DATABASE_PASSWORD secret
	}
}

http://shop.example.com {
	invoke shop
}
$ curl http://intranet.example.com/   # 403
$ curl http://shop.example.com/       # runs /srv/intranet/index.php, with DATABASE_PASSWORD in $_SERVER

Credits

Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-24JPX8J2.

Affected versions

References

GitHub · php/frankenphp