Skip to content

Docker PHP security update: rebuild, pin and verify

Get the PHP2Shell fix into your PHP containers by rebuilding them on a fixed official php image and pinning that image by digest. You will recreate every container and prove that each one runs the new image and reports a fixed PHP version.

If you run WordPress or another PHP application in Docker, here is how to move every container onto a PHP build with the October 2026 PHP2Shell fix, and how to prove it. PHP2Shell covers two critical remote code execution flaws, listed in the Common Vulnerabilities and Exposures (CVE) catalogue as CVE-2026-109618 and CVE-2026-109619. The PHP project fixed them in 8.2.35, 8.3.36, 8.4.27 and 8.5.12 on 21 October 2026 (php.net release archive). With containers, docker pull only downloads a new image, and every container you started earlier keeps running the old one. Rebuild on a fixed official php image, pin that image by its digest, recreate the containers, then check from inside each running container.

The official images checked below were first inspected on 30 October 2026 and checked again on 21 November 2026. Tags move, so re-check before you rely on a specific digest.

Update, 21 November 2026. The October versions are no longer the ones to aim for. On 19 November 2026 the PHP project released 8.2.36, 8.3.37, 8.4.28 and 8.5.13 as security releases (php.net release archive). They fix CVE-2026-115560. On 8.3 and later they also fix CVE-2026-129481, which the PHP project describes as an incomplete fix for CVE-2026-109619. Those four versions are now the minimum in each branch. The tags, the digest and the example outputs in the steps below use the November versions, confirmed on Docker Hub on 21 November 2026.

What you’ll accomplish

  • A list of every running container with the PHP version it really runs, and whether it still uses an outdated image.
  • A Dockerfile that starts from a fixed official tag, pinned by digest so the build cannot silently drift.
  • Rebuilt images and recreated containers, using Docker Compose or plain docker run.
  • Proof per container that its image ID matches the new image and that PHP reports a fixed version.
  • The session.upload_progress.enabled = 0 setting baked into the image, which the PHP project recommends for a third flaw, CVE-2026-115560.

Prerequisites

  • Shell access to the Docker host, as a user who can run docker commands.
  • Docker Engine with the Compose plugin (docker compose) and the Buildx plugin, both part of Docker’s standard Engine install. The commands below were checked with Docker 29 and Compose 5.
  • The Dockerfile and compose.yaml (or docker-compose.yml) for each application, in version control.
  • A recent backup of your volumes and database. Recreating a container keeps named volumes, and a backup still gives you a way back if the new image misbehaves.
  • If you cannot rebuild today, start with PHP2Shell mitigations until you can patch first.

How it works

Three different things share the name “the image”, and only one of them serves your visitors.

Three layers after a docker pull: the registry tag php:8.3-fpm and the local image both show PHP 8.3.37, but the container started before the pull still runs PHP 8.3.36 on the old image ID until compose up recreates it

A tag such as php:8.3-fpm is a movable name in the registry. The Docker Official Images team rebuilds it whenever PHP or the underlying Debian or Alpine system changes. A local image is the copy on your host, identified by an image ID. A container is started from one specific image ID and keeps it for its whole life. Pulling or building a newer image moves the tag on your host to the new image ID, but it never touches a running container. Docker has no step that swaps the image under a live container. You must remove it and start a new one.

That is why the proof has to come from the running container itself. Two facts settle it. The container’s image ID must equal the ID of the image you built, and PHP inside it must report a fixed version.

One more trap sits in the base image. The official php image compiles PHP from the php.net source, so its version number moves to 8.3.37 and so on. A custom image that starts from debian or ubuntu and installs PHP with apt gets the distribution’s package instead. Those packages keep their old number and carry a backported fix, and they follow the distribution’s advisories, not the php.net numbers. Updating PHP on a Linux server after a security fix explains how to read those.

Step-by-step

  1. List the PHP version inside every running container. This loop asks each running container for its PHP version. Containers without PHP, such as a database or an nginx proxy, print no php:

    for c in $(docker ps --format '{{.Names}}'); do
      v=$(docker exec "$c" php -r 'echo PHP_VERSION;' 2>/dev/null || echo 'no php')
      printf '%-24s %s\n' "$c" "$v"
    done

    Example output:

    shop-wordpress-1         8.3.36
    shop-db-1                no php
    intranet-php-1           8.2.30
    api-worker-1             8.4.28

    As of 21 November 2026, any version below 8.2.36, 8.3.37, 8.4.28 or 8.5.13 in its own branch is missing a fix. A version from 8.1 or older is also unfixed, with no fixed official tag to move to (step 3 covers it). For one container, docker exec <container> php -v prints the full banner, including the build date.

  2. Check where each image got its PHP. Official php images, and the wordpress image built on them, record the version in an environment variable:

    docker image inspect --format '{{range .Config.Env}}{{println .}}{{end}}' shop-wordpress:latest | grep '^PHP_VERSION='

    Example output:

    PHP_VERSION=8.3.36

    If this prints nothing, PHP came from a distribution package. Check the package inside the container with docker exec <container> dpkg -l 'php*' on Debian or Ubuntu, or docker exec <container> apk info -v on Alpine. Then compare the package version with that distribution’s security advisory.

  3. Pick a fixed official tag. You can read the PHP version of any tag before you pull it:

    docker buildx imagetools inspect php:8.3.37-fpm-bookworm --format '{{json .Image}}' | grep -o 'PHP_VERSION=[0-9.]*' | sort -u

    Expected output:

    PHP_VERSION=8.3.37

    Keep the same PHP branch, variant and operating system you use today, and change only the version. If you run php:8.3-fpm-bookworm, move to php:8.3.37-fpm-bookworm. For php:8.4-apache, move to a tag such as php:8.4.28-apache-bookworm. Alpine users keep -alpine, as in php:8.3.37-fpm-alpine. Name the Debian release (bookworm or trixie) on purpose. Tags without one follow the image’s default Debian release, trixie as of 21 November 2026, so an unsuffixed tag can change your operating system during a security update. For the wordpress image, use a PHP-specific tag such as wordpress:php8.3-fpm, which on 21 November 2026 reported PHP_VERSION=8.3.37 for amd64 and arm64.

    Older branches are a dead end here. As of 21 November 2026, the official php image lists supported tags only for 8.2, 8.3, 8.4, 8.5 and 8.6. The php:8.1-fpm tag still exists, but it was last rebuilt in December 2025 and reports 8.1.34, which has no PHP2Shell fix. The PHP project shipped no fixed 8.1, 8.0 or 7.4 release, so there is no fixed official tag for them. Move those applications to 8.3 or 8.4. Avoid 8.2 as a landing spot too, because its security support ends on 31 December 2026.

  4. Pin the base image by digest. A digest is the content fingerprint of one exact image, a long sha256: value that never changes, unlike a tag. Get it for the tag you chose:

    docker buildx imagetools inspect php:8.3.37-fpm-bookworm

    Example output (abridged, fetched on 21 November 2026):

    Name:      docker.io/library/php:8.3.37-fpm-bookworm
    MediaType: application/vnd.oci.image.index.v1+json
    Digest:    sha256:5b9440ebac23314bb42d33338918c1c2c852469e5b0a7f0a9493448d827bab35

    Use the Digest: line at the top. It names the multi-architecture index, so the same pin works on Intel and ARM hosts. If the image is already pulled, docker image inspect --format '{{index .RepoDigests 0}}' php:8.3.37-fpm-bookworm prints the same value as php@sha256: followed by the digest. Put the tag and the digest on the FROM line of your Dockerfile:

    FROM php:8.3.37-fpm-bookworm@sha256:5b9440ebac23314bb42d33338918c1c2c852469e5b0a7f0a9493448d827bab35

    When both are present, Docker uses the digest and keeps the tag only for people reading the file. Fetch your own digest rather than copying this one. The image behind a tag is rebuilt from time to time, and Docker Hub shows this one was last pushed on 19 November 2026.

  5. Bake the CVE-2026-115560 setting into the image. CVE-2026-115560, published by the PHP project on 23 October 2026, is a separate flaw in the same session upload progress code. The October releases, 8.3.36 included, are exposed to it. PHP 8.5.13, 8.4.28, 8.3.37 and 8.2.36, released on 19 November 2026, fix it (php.net), so rebuild on one of those or newer. Switching the feature off is still worth keeping in the image. Session upload progress lets a page report how far a file upload has got, and few applications use it. Create a file named zz-php2shell.ini next to the Dockerfile:

    session.upload_progress.enabled = 0

    Then copy it into PHP’s configuration directory. Official images store that path in $PHP_INI_DIR, which is /usr/local/etc/php, and read every .ini file in its conf.d folder:

    COPY zz-php2shell.ini "$PHP_INI_DIR/conf.d/"

    The zz- prefix makes the file load last, so no earlier file can switch the feature back on. If your Dockerfile does not do it already, consider adding RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini". Official images ship without an active php.ini, which leaves PHP on its built-in defaults.

  6. Rebuild without the cache. Build with a fresh base image and no reused layers:

    docker compose build --pull --no-cache

    Without Compose, use docker build --pull --no-cache -t shop-wordpress:latest . in the directory with the Dockerfile. The success signal is a line such as Image shop-wordpress:latest Built from Compose, or naming to docker.io/library/shop-wordpress:latest done near the end of the docker build output. --pull fetches the base image even if an older copy exists locally. --no-cache matters most for images that install PHP with apt or apk. A cached RUN apt-get install layer would otherwise keep last month’s packages.

    For services that use a ready-made image with no build: section, such as an unmodified wordpress:php8.3-fpm, update the tag in compose.yaml and download it instead:

    docker compose pull
  7. Recreate the containers. Start new containers from the new images:

    docker compose up -d --force-recreate

    Example output (abridged):

     Container shop-db-1 Recreate
     Container shop-wordpress-1 Recreate
     Container shop-wordpress-1 Recreated
     Container shop-db-1 Recreated
     Container shop-db-1 Starting
     Container shop-wordpress-1 Starting
     Container shop-db-1 Started
     Container shop-wordpress-1 Started

    docker compose up -d on its own already recreates services whose image changed. --force-recreate removes any doubt, at the cost of also restarting unchanged services such as the database, so expect a short interruption. To limit it to one service, add the service name at the end, as in docker compose up -d --force-recreate wordpress. For a container started by hand with docker run, stop and remove it, then run the same docker run command again with the new tag. Named volumes survive this, but anything written inside the container’s own filesystem does not.

Validate it works

  1. Compare each container’s image ID with its current image. This loop flags any container still running an older image than the one its tag now points to. It also prints the PHP version next to it:

    for c in $(docker ps --format '{{.Names}}'); do
      ref=$(docker inspect --format '{{.Config.Image}}' "$c")
      running=$(docker inspect --format '{{.Image}}' "$c")
      current=$(docker image inspect --format '{{.Id}}' "$ref" 2>/dev/null)
      if [ "$running" = "$current" ]; then s='current'; else s='STALE'; fi
      v=$(docker exec "$c" php -r 'echo PHP_VERSION;' 2>/dev/null || echo 'no php')
      printf '%-24s %-30s %-8s %s\n' "$c" "$ref" "$v" "$s"
    done

    Example output:

    shop-wordpress-1         shop-wordpress:latest          8.3.37   current
    shop-db-1                mariadb:11.4                   no php   current
    intranet-php-1           intranet-php:latest            8.2.30   STALE

    Every PHP container must read current with a fixed version. A STALE row means the image was rebuilt but the container was not recreated, so repeat step 7 for it.

  2. Check the version that PHP-FPM or Apache serves. docker exec … php runs a new command-line process. The web side is served by PHP-FPM (FastCGI Process Manager, the pool of PHP workers behind your web server) or by the Apache process that started with the container. In official images both come from the same build, so a recreated container is enough. To see it from the web anyway, write a throwaway file into the document root, request it through your site, then delete it. For the wordpress image, the document root is /var/www/html:

    docker exec shop-wordpress-1 sh -c 'echo "<?php echo PHP_VERSION, \" \", PHP_SAPI;" > /var/www/html/kb-ver-7f3a.php'
    curl -s https://shop.example.com/kb-ver-7f3a.php; echo
    docker exec shop-wordpress-1 rm /var/www/html/kb-ver-7f3a.php

    Expected output: 8.3.37 fpm-fcgi for PHP-FPM, or 8.3.37 apache2handler for the Apache variant. WordPress users can skip the file. The PHP version also appears under Tools » Site Health » Info » Server.

  3. Confirm the mitigation is active. Ask the PHP-FPM binary, which reads the same conf.d folder as the web workers:

    docker exec shop-wordpress-1 php-fpm -i | grep session.upload_progress.enabled

    Expected output:

    session.upload_progress.enabled => Off => Off

    On the Apache variant, run php -i instead of php-fpm -i. PHP-FPM and Apache read .ini files only when they start. If you ever copy the file into a running container, it has no effect until the container restarts, and a recreate is cleaner.

Troubleshooting

  • The container still reports the old version after docker compose up -d. Compose recreates a service only when it sees a change. Run docker compose up -d --force-recreate <service>, then the validation loop again. If the version still does not move, the image: line in compose.yaml probably points to an old tag, so read it before you rebuild.
  • The rebuilt image still has the old PHP. A digest pin wins over the tag. If you changed the tag but kept an old @sha256: value, Docker builds from the old image. Fetch the new digest with docker buildx imagetools inspect and update the FROM line.
  • PHP_VERSION is fixed but docker exec … php -v shows something else. Your Dockerfile installs a second PHP, usually from apt, after the official base. Check with docker exec <container> sh -c 'command -v php; ls /usr/bin/php*'. Keep one PHP per image.
  • STALE appears for a container you did recreate. Another build ran afterwards and moved the tag again, for example a continuous integration (CI) job. Recreate once more after the last build, and pin your deploys to an image tag or digest that a later build cannot reuse.
  • A container fails to start after the recreate. Read docker compose logs --tail 50 <service>. If your old tag had no release suffix, check whether the base operating system moved from bookworm to trixie. If it did, put -bookworm back in the tag and rebuild.

Keep it fixed

A digest pin stops silent drift, but it also stops automatic security rebuilds. Let a bot propose the next digest as a pull request. Dependabot’s docker package ecosystem and Renovate both update FROM lines that carry a tag and a digest. Renovate can also add digests to unpinned lines with its pinDigests option. Each time one lands, build, recreate and run the validation loop.

When this is the wrong approach

If a hosting platform runs your containers for you, it may rebuild and restart them on its own schedule. Ask the provider which image it uses and run the validation from its console instead. If your application still needs PHP 7.4, 8.0 or 8.1, no official image fixes it. Your options are a paid extended-support build from a third-party vendor, or upgrading the application. If you cannot rebuild today, the settings in the mitigation article reduce exposure in the meantime. They are not a fix.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.