Workik.

PHP2Shell Response Guide: Patch, Mitigate and Harden PHP

Build a PHP Patch Management Process

Establish a repeatable PHP patch process with pinned container images, vulnerability scanning, runtime inventories, and an incident runbook.

Emergency patching works once, under pressure, when the whole team drops everything. That is how Brightline Logistics survived the October 2026 PHP2Shell release, but a second critical Common Vulnerabilities and Exposures (CVE) notice next quarter should not require the same scramble. Turning what you did across the last seven lessons into a calm, repeatable patch management process means the next PHP advisory takes an hour instead of a weekend.

Previous lesson: Harden PHP and PHP-FPM Configuration


Watch PHP Security Releases Before They Become Emergencies

You cannot patch what you do not hear about on time. During PHP2Shell, the CVE identifiers leaked on 20 October 2026 and the PHP team released patches on 21 October at 14:00 UTC. Teams that only read weekly newsletters found out days after exploitation had already started.

Set up direct signals from the places that actually publish fixes:

  • The official PHP news page and the low-volume php-announce mailing list, which announce every new release and security fix directly.
  • Security notices from your Linux distribution vendor, such as Ubuntu Security Notices or Red Hat Security Advisories, because distribution packages backport fixes under their own version numbers.
  • Release notifications for your container base images, such as the official php repository on Docker Hub, so you know when php:8.3-fpm or php:8.4-fpm has been rebuilt.

Pro Tip: Route the php-announce list and your Linux vendor advisories into a dedicated channel in your team chat or ticketing tool so one person being on vacation never delays a patch.


Separate PHP Runtime Patching from Composer Audits

Many PHP teams run composer audit in their Continuous Integration (CI) pipeline and assume their PHP stack is covered. Here is the catch: composer audit checks your application's third-party libraries in composer.json against known security advisories. It does not check the PHP runtime binary, the web Server Application Programming Interface (SAPI), or system libraries.

Think of it like checking every tire on a car but never looking at the engine. Both matter, and neither replaces the other.

For brightline-portal, a clean composer audit run on 21 October 2026 would have reported zero vulnerabilities while the container was still running an unpatched PHP 8.3 FastCGI Process Manager (PHP-FPM) binary vulnerable to CVE-2026-109618 and CVE-2026-109619.

Check TypeTool ExamplesWhat It CatchesCatches PHP2Shell?
Dependency auditcomposer auditVulnerable Composer packages in vendor/No
Host package checkapt, dnf, OS vulnerability scannersOutdated PHP, Apache, nginx and C libraries on serversYes
Container image scanTrivy, GrypeVulnerable OS packages inside Docker images, and the PHP runtime when the scanner can identify itNot always, so add a version check

Common Mistake: Treating a green composer audit job in CI as proof that your PHP servers are patched. You need both a dependency check and a runtime check in your pipeline.


Pin Base Images and Automate Rebuilds

When you build a container from a moving tag like php:8.3-fpm, two builds run a month apart can produce different PHP patch levels, or worse, a cached layer on your build runner can keep serving an old, vulnerable image for months.

Pin the exact patch version in your Dockerfile so every engineer and every scanner can see the exact PHP version in git. Alongside pinning, schedule a weekly CI job that updates that tag or rebuilds with --pull so operating system library fixes inside the base image arrive without waiting for a code change.

Here is how Brightline updates the Dockerfile for brightline-portal:

Before:

dockerfile
Copy

After:

dockerfile
Copy

In your CI build step, always pass --pull and scan the built image before pushing it to your registry:

bash
Copy

The official php images compile PHP from source instead of installing it as an operating system package, so an image scanner may not recognize the PHP version at all. The one-line version_compare check is what guarantees the build fails on an unpatched PHP. Update the version number in it whenever you move to a new PHP release.

Generating a Software Bill of Materials (SBOM), which is a machine-readable list of every package inside an image or server, lets you search all your deployed artifacts in minutes the next time a critical CVE drops.


Keep Your PHP Inventory Alive

In Lesson 2, you built an inventory of every PHP binary, web SAPI, and host across Brightline Logistics. If that list sits in a forgotten spreadsheet, it will be wrong within three months.

Keep the inventory in your repository or configuration database as a living table with five required columns: application name, team owner, PHP version, web SAPI, and where it runs.

ApplicationOwnerPHP VersionWeb SAPIHost or Base Image
brightline-wwwMarketing Web8.1 (Ubuntu backport)Apache mod_php (migrating to FPM)Ubuntu 22.04 VM
brightline-portalCustomer Platform8.3.37PHP-FPM behind nginxDocker php:8.3.37-fpm
brightline-invoicingFinance Systems7.4 (isolated, upgrading to 8.4)PHP-FPMRHEL 8 internal VM

Review this table once a month and require every new service or decommissioned server to update it as part of the deployment checklist.


Write a One-Page PHP Incident Runbook

When a CVSS 9.2 vulnerability is announced, nobody wants to read a forty-page policy document. Write a one-page runbook stored in version control that tells the on-call engineer the exact order of operations:

  1. Inventory: Check the live inventory and SBOMs to list every affected system.
  2. Order by exposure: Put internet-facing Apache mod_php servers first, then internet-facing PHP-FPM apps, then internal systems, and finally CLI-only workers.
  3. Mitigate if delayed: If a system cannot be patched immediately, apply the advisory's stopgap settings in php.ini or the FPM pool using php_admin_value and php_admin_flag, tighten request size limits at the proxy or Web Application Firewall (WAF), or isolate the host from the public internet.
  4. Patch: Upgrade OS packages (apt or dnf), rebuild container images from pinned patched tags with --pull, and confirm managed hosting status.
  5. Restart: Restart every PHP-FPM service, Apache, FrankenPHP, LiteSpeed, and long-running queue worker so no process keeps old code in memory.
  6. Verify: Check both php -v and the web SAPI version, and grep the distribution package changelog for the CVE numbers (CVE-2026-109618 and CVE-2026-109619).
  7. Hunt and report: Search access, PHP error, and FPM logs from the earliest known activity date (17 October 2026 for PHP2Shell), check for unexpected files, and record the completion status for each application.

Quick Challenge: Look at your own team's documentation right now. Could an engineer who joined last week find the list of every PHP server and the exact restart commands in under five minutes?

Pro Tip: Artificial intelligence (AI) tools such as Workik can speed up drafting your runbook, reviewing php.ini files, or planning an upgrade from PHP 7.4 to 8.4, as long as an engineer reviews and tests every change before it reaches production.


Try It Yourself

Create a starter runbook and verification script for your own environment in a safe local directory:

bash
Copy

Next, add a three-row inventory table in a PHP-INVENTORY.md file for the applications you maintain, filling in the owner, current PHP version, web SAPI, and how each one gets patched.


You have now worked through the complete PHP2Shell response: understanding CVE-2026-109618 and CVE-2026-109619, finding every PHP runtime and SAPI, applying patches and temporary mitigations, hunting for exploitation in your logs, retiring end-of-life PHP, hardening PHP-FPM, and putting a repeatable patch process in place for whatever comes next.

You have completed the course

Was this lesson helpful?