Patch PHP2Shell on FrankenPHP
FrankenPHP compiles the PHP interpreter into the server binary, so the flaw ships inside FrankenPHP itself. The fix is a build that embeds one of the fixed PHP versions, whether you pull a rebuilt image, replace the binary, or compile your own.
- You need
- Permission to pull images and recreate containers, or root to replace the binary and restart the service. To build from source: Docker, or Go with a PHP built for embedding.
- Updated
- By
- PXL
Fixed in
- A FrankenPHP build bundling PHP 8.2.35, 8.3.36, 8.4.27 or 8.5.12
Affected: Every FrankenPHP binary and image built against a PHP version older than the fixed versions, in classic and worker mode alike.
How FrankenPHP is exposed
FrankenPHP links libphp into a single Go binary built on Caddy, so every request runs through the PHP it was compiled against. Both CVEs apply, in classic and worker mode alike. In worker mode the exposure is wider, because the interpreter and its global state stay resident between requests. Nothing in your Caddyfile or application code closes the hole; only a build that embeds a fixed PHP does.
Update the official image
The dunglas/frankenphp images are rebuilt on the fixed PHP versions. The current release bundles PHP 8.2.35, 8.3.36, 8.4.27 and 8.5.12. Pull the branch tag again and recreate the containers. A cached tag keeps the old bundled PHP.
01Pull the image for your PHP branch
The tag carries the PHP branch, so pull the one you run. php8.3 tracks the latest stable FrankenPHP on PHP 8.3; pin the full form for a reproducible build.
docker pull dunglas/frankenphp:php8.3 # fully pinned: docker pull dunglas/frankenphp:1.13-php8.3-bookworm02Recreate the containers
Replace the containers so they run the new image. Restarting a container keeps the old one.
docker compose pull && docker compose up -d
Update a standalone binary
If you run the native binary rather than a container, download the current release and replace it, then restart the service. The latest release bundles PHP 8.5.12 in its static binaries.
01Install the current release
Use the install script, or download the binary for your platform from the releases page.
curl https://frankenphp.dev/install.sh | sh # or download from: # https://github.com/php/frankenphp/releases02Restart the service
Restart FrankenPHP so the new binary takes over. In worker mode, make sure the workers restart too.
sudo systemctl restart frankenphp
Build from source
FrankenPHP is a Go program that embeds libphp, so building from source means building against a fixed PHP. Pick one of the three documented routes; each bundles the PHP you build against. The fix lands only once the embedded PHP is 8.2.35, 8.3.36, 8.4.27, 8.5.12 or later on its branch.
The recommended route builds FrankenPHP as a Caddy binary against the libphp on your machine. Build or install a fixed PHP with embedding support first (--enable-embed --enable-zts --disable-zend-signals --enable-zend-max-execution-timers), then point the build at its php-config.
CGO_ENABLED=1 \
CGO_CFLAGS=$(php-config --includes) \
CGO_LDFLAGS="$(php-config --ldflags) $(php-config --libs)" \
xcaddy build --output frankenphp \
--with github.com/dunglas/frankenphp/caddyRestart the workers after the upgrade
In worker mode FrankenPHP keeps the interpreter resident, so a pulled image or replaced binary does not take effect until the worker processes restart. A reload of the server is not enough; the running workers carry the old PHP until they are cycled. Recreating the container or restarting the service starts fresh workers; to cycle them in place, enable the admin endpoint in your Caddyfile and call the restart route. MAX_REQUESTS also recycles a worker after a set number of requests.
curl -X POST http://localhost:2019/frankenphp/workers/restartConfirm the bundled PHP version
FrankenPHP reports the PHP it embeds. Check that it is the fixed release for its branch or later, both on the server build and on the CLI.
frankenphp version
frankenphp php-cli -v