Skip to content
PHP released the fixed versions on 21 October at 14:00 UTC. Update PHP on every server you run.CERT-EU advisory
php2shell.xyz
Container imageAction needed

Patch PHP2Shell on Official PHP Docker images

The official php images on Docker Hub were rebuilt on the fixed PHP versions. A container keeps the PHP baked into its image, so it stays vulnerable until you pull the rebuilt tag and recreate the container, or rebuild any image you base on php.

You need
Permission to pull images, rebuild your Dockerfiles and recreate containers. For digest-pinned deployments, access to update the digest in your manifests or compose files.
Updated
By
PXL

Fixed in

  • php:8.2.35
  • php:8.3.36
  • php:8.4.27
  • php:8.5.12

Affected: Any container built from a php image tag older than the fixed versions, including the -fpm, -cli, -apache, -alpine and -zts variants.

Why a running container stays vulnerable

An image is immutable: the PHP binary is fixed at build time and a running container keeps it. Pulling a newer base, restarting the container or reloading PHP-FPM inside it changes nothing until the container is recreated from a rebuilt image. The fix is to move to a rebuilt tag and replace the container.

Pull the rebuilt tag

The php images carry the fixed versions: 8.2.35, 8.3.36, 8.4.27 and 8.5.12, on Debian (bookworm, trixie) and Alpine. Pull the tag for the variant you run; the moving minor tag now resolves to the fixed patch. Append -alpine to any variant for the smaller musl build.

PHP-FPM, run behind a reverse proxy.

docker pull php:8.3.36-fpm
# or the minor tag, now rebuilt:
docker pull php:8.3-fpm

Recreate the containers

Replace the containers so they run the new image. Restarting a container keeps the old image.

docker compose pull && docker compose up -d

Build a patched image

You do not compile PHP here; the official image already ships the fixed binary. Building your own image means basing it on a fixed tag and rebuilding against the new base. Rebuild without the layer cache so the base is pulled fresh, then push and roll out. If you maintain a shared base image for a fleet, rebuild and re-publish it so everything downstream inherits the fix.

  1. 01Base on a fixed tag

    Set the FROM to a fixed patch release so the build is reproducible and the fix is explicit.

    FROM php:8.3.36-fpm-bookworm
    # ...
    RUN docker-php-ext-install pdo_mysql opcache
  2. 02Rebuild without cache and roll out

    Force a fresh pull of the base, rebuild each layer, then recreate the containers.

    docker build --pull --no-cache -t your-app .
    docker compose up -d

Update digest-pinned images

A tag pinned by digest (php@sha256:…, or a digest pinned in a compose file, Kubernetes manifest or lockfile) does not move when the tag is rebuilt. It keeps pulling the old, vulnerable layer. Resolve the new digest and update every place it is pinned.

  1. 01Resolve the new digest

    Pull the tag, read back the digest it now points at, then replace the pinned value in your manifests.

    docker pull php:8.3.36-fpm-alpine
    docker inspect --format "{{index .RepoDigests 0}}" php:8.3.36-fpm-alpine

EOL tags are not rebuilt

The official images are built only for the supported branches, currently PHP 8.2 and newer. Tags for 8.1, 8.0, 7.4 and older are no longer in the supported list and are not rebuilt, so they never receive the fix. Move those workloads to a maintained branch, or build a fixed PHP from source into your own image.

Confirm the version inside the container

Read the version from inside the running container, not from the host. Check it against the fixed release for its branch.

docker exec <container> php -v

Confirm the update

Read the version from inside the running container.

docker exec <container> php -v

Sources