All posts

PHP2Shell: two critical PHP flaws, explained.

Two critical PHP flaws (CVE-2026-109618 and CVE-2026-109619) can allow unauthenticated remote code execution. What they are, who is affected and how to respond.

Published
Updated
Reading time
9 min
By
Girish Babu GV

What happened#

On 21 October 2026 the PHP project released emergency security updates for two vulnerabilities in the PHP core. They were published as GitHub security advisories (one, two) and both are rated Critical. According to the advisories, a successful attack needs no login: it is a remote, unauthenticated request, and the code runs as whichever account the web worker uses. Both advisories do rate the attack complexity as high, which fits the reports that public exploits so far only work in narrow setups.

The same day, the UK’s National Cyber Security Centre published guidance for organisations that run PHP. It asks them to identify every PHP installation, update internet-facing ones first, apply the PHP Foundation’s mitigations if they can’t update, consider taking a system offline if neither is possible, and check for signs of compromise. It also points out that PHP is bundled inside other products, so appliances and services may need a fix from their vendor.

On exploitation, accounts differ. Rapid7 says it has not itself observed exploitation in the wild, but expects it, and notes that several public proof-of-concept exploits exist. Each one it reviewed only works for a specific mix of operating system, PHP version and web server. BleepingComputer reports that Cloudflare saw early attacks before the patches shipped, and Singapore’s Cyber Security Agency reports widespread exploitation attempts. Whatever the exact picture, the safe assumption is that working exploits are already circulating.

The two bugs, in plain English#

Both bugs are memory-safety problems in how PHP manages the memory of a single web request, and both are about what is left behind when a request goes wrong.

CVE-2026-109618: running out of memory at the wrong moment

When PHP runs out of memory it doesn’t unwind carefully. It uses longjmp() to jump straight out of whatever it was doing. The advisory explains that in some places request memory can be reached before it is fully initialised. If an allocation fails there, the jump skips the setup and leaves the request’s data structures invalid. Later, request shutdown reads that invalid memory as if it were fine. The allocation that fails doesn’t even have to be related to the broken memory.

An attacker needs a cheap way to exhaust memory, and parsing multipart form data offers several. The advisory lists three:

  • A multipart request without a usable declared content length can slip past the initial post_max_size check.
  • A single part can carry an unlimited number of headers, which cost far more memory inside PHP than they do on the wire.
  • Empty file fields don’t count towards max_file_uploads but still allocate file metadata, and nested field names multiply that work.

The fix removes longjmp() for out-of-memory errors. PHP now marks a “soft” out-of-memory and stops at the next safe point in the engine, and if memory use reaches a second, higher threshold it exits the process immediately instead.

CVE-2026-109619: state that outlives its request

PHP workers handle many requests one after another. Some internal state, covering errors, sessions, objects and extensions, belongs to the worker, not to a single request. The advisory describes how that state can keep pointing at memory owned by a previous request, memory that has since been freed. A later request on the same worker can then use it, which is a classic use-after-free.

It takes two requests handled by the same worker: one to leave the stale pointer behind, and one to touch it.

  • The first request ends in a way that skips the usual reset: a fatal error (a parse or compile error, an uncaught error, a failed require, “Maximum execution time exceeded”) or an out-of-memory condition.
  • The second request touches the stale state before normal start-up: a PHP configuration warning, notice or deprecation raised early is enough, whether or not it is shown or logged, or the session upload-progress handling.

The advisory confirms two concrete cases: on PHP 8.5, the fatal_error_backtraces feature leaves state behind and gave remote code execution against Apache’s mod_php; and the session upload-progress path was validated against both mod_php and PHP-FPM.

Who is affected#

The vulnerable code is in PHP, not in your application, so updating a plugin or a framework won’t fix it. What matters is the PHP runtime your server uses. How exposed you are depends on how PHP is run. This table follows the PHP advisories:

Exposure by way of running PHP
How PHP runsCVE-2026-109618 (out of memory)CVE-2026-109619 (stale state)
Apache mod_phpConfirmed. Remote code execution shown over HTTP with default limits.Confirmed path on PHP 8.5. .htaccess and php_value directives apply before start-up, so they can trigger it.
PHP-FPMPossible after a normal start. No complete exploit demonstrated yet.Conditional. The session upload-progress path is validated; so are frontends that pass PHP_VALUE settings that raise a diagnostic.
FrankenPHPLikely, from source analysis only.No early trigger found in the default configuration.
LSAPI (LiteSpeed)Likely. Application-specific exploits not validated.Conditional candidate.

Treat that as a priority order, not a list of safe setups. Rapid7 and BleepingComputer both describe every PHP deployment that serves web requests, including php-cgi, as in scope. Reliability of an attack depends on the PHP build, extensions and memory layout, which may explain why published exploits are narrow today. That’s not a reason to wait.

PHP branches and their fixed versions
BranchFixed inNotes
8.58.5.12Supported.
8.48.4.27Supported.
8.38.3.36Supported.
8.28.2.35Supported.
8.1, 8.0, 7.4No official releaseUnsupported upstream. PHP published minimal source backports; distributions and LTS vendors may ship their own.
Older than 7.4No published fixNot covered by the backports. Migrate to a supported branch.

What to do now#

  1. Take an inventory. Web servers, containers and base images, CI runners, and any product that bundles PHP. Start with anything reachable from the internet. The Dutch NCSC keeps a list of software with a PHP dependency and its fix status, and Rapid7 published a Velociraptor artifact, Generic.Applications.PHPInventory, for finding PHP installs.
  2. Update to a fixed release, matching your branch, or to a vendor package that contains both fixes. The advisories say this is the only complete mitigation.
  3. Restart what runs PHP. Workers started before the update keep running the old code, so restart PHP-FPM or Apache after upgrading, and rebuild and redeploy container images.
  4. Chase your providers. If a host, a platform or an appliance runs PHP for you, ask for their patch status instead of assuming it.
  5. If you can’t tell whether you were hit, look for signs of compromise on internet-facing systems. The advisory warns that clean logs don’t prove safety, so for anything important, involve an incident-response team.

If you can’t patch yet#

These are the measures the advisories describe. Apply them where applications can’t override them, and restart all workers afterwards.

php-fpm pool config (php_admin_value can’t be overridden by applications)
; CVE-2026-109619: the session upload-progress path
php_admin_value[session.upload_progress.enabled] = 0

; CVE-2026-109618: avoid the out-of-memory path. Not complete, and it removes
; PHP's own memory cap, so pair it with the limits listed below.
php_admin_value[memory_limit] = -1

; PHP 8.5 only: removes the confirmed remote code execution producer
php_admin_value[fatal_error_backtraces] = 0
  • Disabling the memory limit has a cost. Set a conservative post_max_size and enforce request size at the frontend (for example client_max_body_size in nginx). Keep the input limits, such as nesting depth, variable count, multipart parts, headers per part and uploads, as low as your application allows.
  • If you don’t use multipart forms, block multipart requests at the frontend.
  • Use container or cgroup memory limits if you need a ceiling, but not RLIMIT_AS or RLIMIT_DATA, which make memory mapping fail and can trigger the vulnerable path.
  • Remove attacker-reachable fatal errors, treat execution timeouts as fatal, and fix configuration that raises warnings at start-up. Hiding error output does not help.
  • If performance allows, pm.max_requests = 1 (PHP-FPM) means a worker never serves a second request, which removes the cross-request path the second bug needs.

Old PHP versions#

PHP 8.1 and older are no longer supported by the PHP project, so there is no regular release for them. The project did publish minimal source backports for 7.4, 8.0 and 8.1, which helps if you build PHP from source. For everyone else the realistic options are a backported package from your Linux distribution or an extended-support vendor, or an upgrade. If you’re on an unsupported branch with no vendor backport, an upgrade stops being a someday task.

How to check your version#

Quick checks
php -v                      # the CLI, which may differ from what the web server uses
php-fpm -v                  # PHP-FPM, if installed
apachectl -M | grep -i php  # is mod_php loaded?
docker run --rm your-image php -v

Two traps. First, the command-line PHP can be a different build from the one serving your site. Check the one the web server actually runs, for instance with phpinfo() in a protected admin page or, on WordPress, Tools → Site Health → Info → Server. Second, Linux distributions often backport fixes without changing the version number, so an “old” version string doesn’t prove you’re vulnerable. Check your distribution’s security tracker or the package changelog for the two CVE numbers.

Lessons for developers#

This is my own take, not something from the advisories.

  • The runtime is part of your attack surface. Many teams track their dependencies closely and the language runtime much less. Know which PHP version every service runs, and who owns updating it.
  • Defaults decide who is exposed. Two of the confirmed triggers are features that are on by default: session upload progress and, on PHP 8.5, fatal error backtraces. Review the defaults you never chose.
  • Reused workers share more than you think. Anything that survives between requests, such as global state, caches or connections, is a place for one user’s request to affect another’s. The error and timeout paths deserve the same care as the happy path.
  • Limits at the edge are cheap insurance. A sensible cap on request size, headers and multipart parts at the proxy blocks a whole class of resource-exhaustion tricks before PHP sees them.
  • Have a plan for end-of-life software. A branch that no longer gets releases has no upstream fix when something like this lands, which is the best argument for planning upgrades before you need them.

A third issue, added on 23 October. Both Rapid7 and CERT-EU mention a further PHP flaw, CVE-2026-115560. It is a remote code execution issue that PHP says only affects web applications configured in an unusual way, and PHP considers the risk unlikely. There was no patch at the time, and a full advisory is due with the next PHP release. CERT-EU says that turning off session.upload_progress (already in the interim measures above) also covers it until then. Keep an eye on the PHP security page.

Sources#

Update log

  1. Added CERT-EU’s advisory and the third issue, CVE-2026-115560, and noted that turning off session upload progress also covers it.

Keep reading

Esc