MGB
MGB // Cyber security notes
--:--:-- GMT
← All posts

PHP2Shell: one upload, full server

Two critical flaws in the PHP engine itself let an unauthenticated attacker run code on a web server with a single crafted upload, before your application gets a say. Here's how it works, who's exposed, and what to do about it.

TL;DR
  • What: CVE-2026-109618 and CVE-2026-109619, together known as PHP2Shell. Both rated CVSS v4.0 9.2.
  • Impact: unauthenticated remote code execution. No login, no application bug needed.
  • Affected: PHP back to 5.4, across PHP-FPM, Apache mod_php, php-cgi, FrankenPHP and LiteSpeed.
  • Fix: upgrade to 8.5.12, 8.4.27, 8.3.36 or 8.2.35, then restart PHP workers.
  • Can't patch today? Set session.upload_progress.enabled = 0 and block multipart uploads where you don't need them.
  • Status: actively exploited, with public proof-of-concept code.
9.2CVSS v4.0
2CVEs · 4 bugs
5.4+PHP versions hit
0Auth required

What is PHP2Shell?

PHP2Shell is the nickname for two memory-safety vulnerabilities in the core PHP engine, patched on 21 October 2026. The important word there is engine. This isn't a bug in WordPress, a plugin or someone's sloppy code. It sits in the runtime that parses every incoming request, so it can be triggered before any of your application's authentication or input validation runs.

That's why it matters so much. A perfectly written, fully patched PHP application is still exposed if the PHP underneath it is vulnerable. Researchers demonstrated code execution against current container images of WordPress, Drupal and Joomla.

How it works

The short version: make PHP run out of memory at exactly the wrong moment, and it leaves dangling pointers behind for the next request to trip over.

  1. The attacker sends a crafted multipart/form-data upload that includes a session upload-progress field (PHP_SESSION_UPLOAD_PROGRESS).
  2. The multipart structure is built to consume far more memory than its size suggests, pushing PHP past its memory_limit while it's still parsing the request.
  3. The resulting fatal error kills the request before the worker's normal clean-up runs. Some engine-level pointers are left pointing at memory that has already been freed.
  4. PHP workers are reused between requests. When the next request lands on the same worker, it can be steered into using that freed memory: a classic use-after-free, which an attacker can shape into code execution.

The disclosure describes four underlying bugs, grouped into the two CVEs:

  • Memory disclosure: leaked process memory comes back to the attacker inside the PHPSESSID cookie. Handy for defeating ASLR, and a reason to treat secrets in memory as exposed.
  • Unserialiser use-after-free: memory corruption leading to RCE.
  • Fatal-error backtrace use-after-free: the same outcome via a different stale pointer.
  • OPcache type confusion across workers: an allocation failure can leave OPcache's shared tracking out of sync between workers.

In CVE terms, CVE-2026-109618 covers the out-of-memory handling, where clean-up code processes half-initialised request memory. CVE-2026-109619 covers the stale global state that survives into the next request on a reused worker.

Who's affected

  • Versions: every PHP release back to 5.4.
  • Server setups: PHP-FPM, Apache mod_php, php-cgi, FrankenPHP and LiteSpeed. Apache with mod_php is the highest-risk configuration for the demonstrated attack path.
  • PHP 8.1 and older are out of upstream support and get no official fix. Some Linux distributions backport patches, so check your vendor's security bulletin rather than assuming.
  • Hidden PHP: don't forget appliances, vendor products, admin panels, internal tools and container base images that quietly bundle PHP.

Timeline

  1. Security firm Calif finds the bugs while working on OpenAI's Patch the Planet initiative. Wiz Research later finds them independently, also with AI assistance.
  2. Calif reports the issues to the PHP project.
  3. Amazon's MadPot honeypots record an exploitation attempt, four days before public disclosure.
  4. Scanning starts at 08:36 UTC, more than five hours before the advisories go out. PHP then releases emergency patches.
  5. F5 Labs reports thousands of exploit attempts within the first 24 hours.
  6. PHP discloses a third, related RCE (CVE-2026-115560). It needs an unlikely configuration and will be fixed in the next regular release.

Exploitation in the wild

This one moved fast. Activity began before the patches were even public, and within a day F5 Labs was seeing thousands of attempts. Roughly 98% targeted CVE-2026-109619, with the remaining 2% using the heavier out-of-memory payloads for CVE-2026-109618.

Honeypot operators have since recorded successful exploitation, including root access on test servers within milliseconds of the attack landing. Working exploits have been confirmed by Rapid7, Trail of Bits and VulnCheck, and proof-of-concept code is on GitHub. Exploit tooling has also turned up on an exposed attacker server, including a "one-click" chain for PHP 8.4.26 under Apache mod_php.

Assume you're being scanned If you run internet-facing PHP and weren't patched by 21 October, treat this as a potential incident, not just a patching task. Review logs from before the disclosure date, as activity started early.

What to do

1. Patch, then restart

BranchFixed inStatus
PHP 8.58.5.12Patched
PHP 8.48.4.27Patched
PHP 8.38.3.36Patched
PHP 8.28.2.35Patched
PHP 8.1 and olderNone upstreamUpgrade or use vendor backport

Updating the package on disk isn't enough. Restart PHP-FPM, Apache or whatever runs your workers, and rebuild and redeploy container images, because running processes keep the vulnerable code in memory. Prioritise internet-facing systems.

# Check the running version and the upload-progress setting
php -v
php -i | grep session.upload_progress.enabled

# Then restart workers, e.g.
sudo systemctl restart php8.4-fpm
sudo systemctl restart apache2

2. If you can't patch yet

These reduce exposure but don't fix the runtime, so treat them as a bridge to patching:

; php.ini — disable session upload progress tracking
session.upload_progress.enabled = 0
  • Disable session upload progress, as above. This also mitigates the third CVE, so leave it off afterwards unless you genuinely need it.
  • Block multipart/form-data at the edge on sites that don't accept uploads.
  • Add a WAF rule to flag or block multipart requests containing PHP_SESSION_UPLOAD_PROGRESS.
  • Tighten request-body size limits. This won't stop every memory-amplification trick, but it raises the bar.
  • On PHP 8.5, disable fatal-error backtraces as described in the official advisory.

3. Hunt for compromise

Signals worth looking for in web server, proxy, WAF and EDR telemetry:

  • POST requests to / or /index.php with multipart bodies containing PHP_SESSION_UPLOAD_PROGRESS.
  • Bursts of memory-limit errors or HTTP 500s following unusual uploads.
  • High-frequency empty or near-empty uploads, or oversized uploads from clients that keep rotating PHPSESSID values.
  • Oversized or malformed PHPSESSID values in responses, which may indicate memory being leaked.
  • User agents such as php2shell-scan, php2shell-scanner or php2shell-poc. Useful, but don't rely on them, as plenty of attempts use normal browser strings.
  • A PHP worker spawning a child process (a shell, curl, wget) during upload handling. This is the high-confidence signal, and exactly what EDR is good at catching.
  • New or modified files in the web root, unfamiliar executables and unexplained outbound connections.

If you find signs of compromise, preserve logs and volatile evidence before restarting anything. Because the bug can leak worker memory, rotate secrets held by exposed servers: database credentials, API keys, cloud workload identities and session signing keys.

The bigger picture

Two things stand out. First, this is a reminder that "our code is secure" isn't the same as "our stack is secure". The runtime, the web server and the base image are all part of your attack surface, and they need the same inventory and patch discipline as your applications.

Second, AI-assisted vulnerability research found these bugs, independently, twice. Expect the gap between disclosure and exploitation to keep shrinking, and plan your patching SLAs for critical, internet-facing issues in hours rather than weeks.