Skip to content
Pablo Huertas
Go back

PHP2Shell: When the language itself is the vulnerability

Most of the time, when I write up a vulnerability, the problem lives in something sitting on top of the stack. An outdated plugin. A misconfigured endpoint. A theme nobody has touched in two years. The language running underneath it all is boring, stable infrastructure, the part you don’t think about.

This one is different, and that’s exactly why it caught my attention.

On October 21st, 2026, the PHP project shipped an emergency security release for two critical vulnerabilities, now going by the nickname PHP2Shell, tracked as CVE-2026-109618 and CVE-2026-109619. Both are rated 9.2 on CVSS v4.0 by the PHP team (watchTowr went further and rated it a flat 10.0). Both allow unauthenticated remote code execution. And here’s the part that should make you sit up: the flaws are in the PHP engine itself, not in WordPress, not in Laravel, not in Magento, not in your custom code. If PHP parses an attacker’s request before any of your application logic runs, your application’s authentication, input validation, and clever hardening never get a chance to matter.

I’ve spent a good chunk of my career cleaning up WordPress breaches and hardening Linux boxes, and the mental model I keep coming back to is defense in depth: assume any single layer can fail, and make sure its failure isn’t the end of the world. PHP2Shell is a sharp reminder of why that model exists. When the interpreter underneath every one of those layers is the thing that’s broken, a lot of your carefully stacked controls get bypassed in a single POST request. So let’s break it down properly: what these bugs actually are, who’s exposed, how the attack works in practice, and what to do about it this week.


What PHP2Shell actually is

“PHP2Shell” is a marketing friendly nickname (it comes from a leaked exploit tool, not from PHP), but it bundles two genuinely distinct bugs that hit different stages of the request lifecycle. They get lumped together because the leaked proof-of-concept folded them into one payload, which, as we’ll see, caused some real confusion in the early coverage. Let me keep them separate, because the stopgap mitigations are different for each one and conflating them will leave you half protected.

Both are confirmed by PHP’s own advisories as exploitable without authentication, and both are reached while PHP is still parsing the incoming request before your application code executes. The official source is the PHP news archive for 2026, and the full technical write-ups live in the two GitHub Security Advisories, GHSA-w8hw-w9fx-j79w and GHSA-6wmf-4rv5-p3rp.

CVE-2026-109618 — RCE via OOM corruption

The first bug is about what happens when PHP runs out of memory at the wrong moment.

When a PHP allocation fails mid-request, the engine jumps straight out of the allocator. That abrupt exit can leave internal request data only partially initialized. The problem is that request cleanup then runs over that half-built state and treats it as if it were valid. Corrupt-but-trusted internal state is the kind of thing that, with enough care, turns into attacker-controlled code execution.

The clever (and nasty) part is that the attacker gets to decide when memory runs out. They do it through the multipart form parser, the thing that handles multipart/form-data POST bodies. A request with no usable declared length, hundreds of empty file controls that don’t count against upload limits, many headers crammed into a single part, or field names nested dozens of levels deep can push the engine into memory exhaustion on demand. No session needed, no particular form field required. PHP confirmed this one as exploitable against Apache with mod_php on default settings.

CVE-2026-109619 — RCE via stale global state

The second bug is a classic use-after-free, dressed up in web-server clothing.

PHP, in most production setups, uses long-lived worker processes that handle one request after another. The idea is that each new request starts from a clean slate. CVE-2026-109619 breaks that assumption. A request that dies at the wrong moment, through a fatal error, an execution timeout, or an out-of-memory condition, can leave request-owned state behind in the worker after its backing memory has been freed. The next request that lands on that same worker can then read the stale state before normal initialization resets it.

One of the code paths that reads this state is session upload progress, which is why the PHP_SESSION_UPLOAD_PROGRESS form field keeps showing up in exploitation attempts. PHP validated this path against both mod_php and PHP-FPM.

One correction worth flagging: a lot of the first-day coverage attached the “turn off session upload progress” advice to CVE-2026-109618. That’s wrong. In PHP’s own advisories the upload-progress path belongs to CVE-2026-109619 alone, the 109618 advisory never even mentions sessions. The distinction isn’t a formalism: the two bugs need two different stopgaps, and if you only apply one, you’ve only closed one door.


Platforms exposed

This is the section where, normally, I’d tell you to check your plugin versions. Not this time. The vulnerable code is PHP itself, so the blast radius is basically “every PHP application you run.”

Affected versions. According to the researchers who found it (Wiz) and corroborated by multiple vendors, the flaws reach all the way back to PHP 5.4 and affect every release through PHP 8. In other words, if it says “PHP” on the tin, assume it’s in scope until proven otherwise.

Fixed versions (released October 21, 2026):

BranchFirst fixed releaseNotes
PHP 8.58.5.12Active support
PHP 8.48.4.27Active support
PHP 8.38.3.36Security fixes
PHP 8.28.2.35Security fixes; EOL 31 Dec 2026

PHP 8.1 and older, including all of PHP 7 and PHP 5, get no official patch from the PHP project. They’re end of life. Some distributions and LTS vendors are backporting fixes, and PHP did publish minimal source backports for 7.4, 8.0 and 8.1 to help people building from source, but if you’re sitting on an unsupported branch, the real remediation is upgrading to a supported version, not patching. Treat that as this week’s problem, not next quarter’s.

Which server setups are at risk? All of the common ones. PHP’s advisory names PHP-FPM, Apache with mod_php, php-cgi, FrankenPHP and LiteSpeed. The team considers the risk highest for mod_php, where there’s a demonstrated exploit: an unauthenticated request triggers the bug before any application code runs.

And because the flaw is in the engine, the application on top doesn’t matter. Researchers reportedly confirmed unauthenticated RCE against a long list of mainstream PHP software: Magento, WordPress, Drupal, Joomla, MediaWiki, Roundcube, phpMyAdmin, Nextcloud and others, not because those projects did anything wrong, but because they all run on PHP. If your WooCommerce store’s own code is spotless, you’re still exposed. That’s the uncomfortable part.


The attack vector: how this plays out in the real world

I always think the threat model lands better when you walk it like an attacker would, so here’s the shape of a real attack, deliberately at the level of what defenders will see in their logs, not a working exploit. Here’s the whole flow at a glance, from an attacker who has never seen your site before to a worker running their command:

flowchart TD
    A["🌐 Attacker<br/>no login, no recon<br/>just needs a PHP host<br/>that accepts a POST"]

    A --> B{{"Which bug<br/>to drive?"}}

    B -->|"OOM corruption<br/>CVE-2026-109618"| C["Craft multipart/form-data body<br/>hundreds of empty file fields<br/>field names nested deep<br/>no usable Content-Length"]
    B -->|"stale global state<br/>CVE-2026-109619"| D["Craft multipart POST carrying<br/>PHP_SESSION_UPLOAD_PROGRESS<br/>timed to a dying worker"]

    C --> E["💥 Allocation fails mid-request<br/>PHP bails out of the allocator<br/>request data left half-initialized"]
    D --> F["♻️ Freed request state survives<br/>in the long-lived worker"]

    E --> G["Request cleanup runs over<br/>the corrupt state as if valid"]
    F --> H["Next request on the SAME worker<br/>reads the stale, freed state"]

    G --> X["🐚 Attacker's command runs<br/>DURING request teardown<br/>before any app code executes"]
    H --> X

    X --> Y{{"App auth / WAF /<br/>input validation?"}}
    Y -->|"never in the execution path"| Z["☠️ Unauthenticated RCE<br/>+ Heartbleed-style memory leak"]

    Z --> W["🤖 Weaponized within hours<br/>mass scanners + botnet droppers<br/>Mirai-style loader on first hit"]

    PATCH["✅ The only real fix:<br/>PHP 8.5.12 / 8.4.27 / 8.3.36 / 8.2.35<br/>+ restart every worker"]
    PATCH -.->|"closes both paths"| X

    style A fill:#2d1214,stroke:#f85149,color:#e6edf3
    style B fill:#1a1a10,stroke:#e3b341,color:#e6edf3
    style C fill:#1c2230,stroke:#58a6ff,color:#e6edf3
    style D fill:#1c2230,stroke:#58a6ff,color:#e6edf3
    style E fill:#1a1030,stroke:#a371f7,color:#e6edf3
    style F fill:#1a1030,stroke:#a371f7,color:#e6edf3
    style G fill:#1a1030,stroke:#a371f7,color:#e6edf3
    style H fill:#1a1030,stroke:#a371f7,color:#e6edf3
    style X fill:#2d1214,stroke:#f85149,color:#e6edf3
    style Y fill:#1a1a10,stroke:#e3b341,color:#e6edf3
    style Z fill:#2d1214,stroke:#f85149,color:#e6edf3
    style W fill:#2d1214,stroke:#f85149,color:#e6edf3
    style PATCH fill:#1a3a22,stroke:#3fb950,color:#e6edf3

Step 1: No reconnaissance needed. This is what makes PHP2Shell so dangerous compared to the plugin-vulnerability chains I usually write about. There’s no user enumeration, no version fingerprinting, no hunting for a vulnerable endpoint. The attacker doesn’t need to find a weak spot in your app, because the weak spot is in the parser that handles every request. Any URL on your site that PHP serves and that accepts a POST is a candidate.

Step 2: A crafted POST. The attacker sends a multipart/form-data POST request shaped to abuse the bug. For CVE-2026-109618, that means a body engineered to force memory exhaustion at a precise moment, the “amplification shapes” PHP’s advisory calls out: hundreds of empty file fields, field names nested dozens of levels deep, packed into a body of a few hundred kilobytes. For CVE-2026-109619, the request carries a PHP_SESSION_UPLOAD_PROGRESS field to reach the vulnerable session path. The leaked tool, confusingly, carried both at once.

Step 3: Execution before your app wakes up. Here’s the chilling bit, straight from reproductions by teams like Datadog: PHP runs the attacker’s command while it cleans up the failed request. The malicious request never reaches your application’s code. Any PHP script exposes the vulnerable path, even one that does nothing but print “hello.” Your WAF rules keyed on application behavior, your login wall, your input sanitization: none of it is in the execution path yet.

Step 4: Weaponization, fast. This is the part worth planning for, and it’s a pattern I’ve seen in every serious disclosure. A new unauthenticated RCE never stays with whoever wrote the first tool. ELLIO’s sensors recorded the first PHP2Shell request at 08:36 UTC, five and a half hours before the fix was even public, from a scanner built off the leaked PoC. By that evening, bots that were already sweeping the internet for unrelated vulnerabilities (React2Shell, exposed Docker, Spring Boot) had simply bolted PHP2Shell onto their existing runs. Some of those scanners doubled as botnet droppers: a Mirai-style loader that infects the host with the very same request that found it, no second visit required. Separately, Amazon’s threat intelligence reportedly logged an exploitation attempt on October 17th, four days before public disclosure. The window between “disclosed” and “mass-exploited” was measured in hours.

If you’ve read my WordPress incident write-up, you’ll recognize the rhythm: the gap between disclosure and exploitation keeps shrinking, and “I’ll get to it next maintenance window” is how recoverable incidents turn into catastrophes.


Mitigation: what to actually do

Let me be blunt about the order of operations, because PHP itself is blunt about it: only patching is a complete fix. Everything else on this list buys you time; it does not make you safe. Treat the mitigations as a tourniquet while you get the real surgery scheduled.

1. Patch. This is the fix.

Update to PHP 8.5.12, 8.4.27, 8.3.36 or 8.2.35, whichever matches your branch. Source is on php.net’s downloads page; most distributions and LTS vendors received the patches ahead of time, so check your vendor’s updated packages first.

# Find out what you're actually running (per SAPI — they can differ)
php -v                       # CLI
php-fpm8.3 -v                # FPM (adjust the version suffix)

# Debian / Ubuntu
sudo apt update && sudo apt upgrade php8.3 php8.3-fpm php8.3-cli

# RHEL / Alma / Rocky
sudo dnf update php php-fpm

# CRITICAL: a package upgrade updates the binary on disk, but
# long-lived workers keep running the OLD code until restarted.
sudo systemctl restart php8.3-fpm     # FPM
sudo systemctl restart apache2        # mod_php

# Confirm the running version actually changed
php-fpm8.3 -v

One thing I learned the hard way cleaning up after rushed patches: the restart is not optional. PHP-FPM and mod_php run persistent workers. If you apt upgrade and walk away, those workers keep serving requests with the vulnerable code loaded in memory until they’re recycled. You are not patched until every worker has been restarted.

A quick note if you lean on the volunteer-maintained rpms.remirepo.net repo: PHP specifically called it out as not having same-day updates for this release, and recommended switching to distribution packages or building from source so you can apply fixes immediately.

2. If you genuinely cannot patch today, stopgaps, per CVE

These reduce exposure to specific attack paths. They do not make an installation safe. Remember, the two bugs need two different sets of measures.

For CVE-2026-109618 (OOM corruption):

; Remove the controllable memory-limit failure path.
; Enforce it where the application can't override it:
;   php_admin_value in the FPM pool, or Apache config.
memory_limit = -1

Then double-check that no pool, directory, or application setting quietly puts a finite limit back. One important caveat PHP flags: do not reach for RLIMIT_AS or RLIMIT_DATA as a substitute, they can cause the exact allocation failure you’re trying to avoid. If you want an availability boundary, use a container or cgroup memory limit, ideally one that kills only the affected worker.

Also cap your request sizes at the edge:

; No file uploads needed? Keep bodies small.
post_max_size = 8M
; Uploads required? Be generous but bounded, and keep
; upload_max_filesize below post_max_size.
upload_max_filesize = 6M

Better still, enforce limits at the web server or proxy level, decoded body size, number of multipart parts, header count per part, field count, nesting depth. A raw size cap alone misses malicious bodies that stay under post_max_size, and these limits must also cover requests that arrive without a usable Content-Length.

For CVE-2026-109619 (stale global state):

; Block the confirmed session-upload-progress path.
; Must apply BEFORE request parsing: use php.ini, an FPM pool,
; or server config — NOT ini_set() and NOT an FPM .user.ini.
session.upload_progress.enabled = 0

; PHP 8.5 only: also close the fatal-backtrace path
fatal_error_backtraces = 0

Restart every worker afterward, or the change doesn’t take effect on in-flight processes. And note: hiding diagnostics with error_reporting, display_errors, or the @ operator does nothing here, the vulnerable path triggers regardless of whether you can see the errors.

3. Front-line filtering while you roll out patches

If you run anything in front of your PHP boxes like Nginx, a reverse proxy, Cloudflare, this is where you can blunt the mass-scanning noise:

4. Hunt for the ones who got there first

Patching stops future exploitation. It does nothing about a shell someone dropped last week. If your servers were internet-facing and unpatched during the exposure window, assume probing and check for compromise. From my incident-response playbook, the first things I’d look for:

# PHP workers that spawned a shell or interpreter — the loudest signal
# that exploitation succeeded. A php-fpm parent with a sh/bash/curl child
# has no legitimate reason to exist.
ps -ef --forest | grep -A1 -E 'php-fpm|apache2|php' | grep -E 'sh|bash|curl|wget|/tmp/'

# Bursts of PHP workers dying on memory errors (the OOM bug in action)
sudo grep -iE 'Allowed memory size|Out of memory|child .* exited on signal' \
  /var/log/php*-fpm.log /var/log/syslog 2>/dev/null | tail -50

# Known PHP2Shell scanner user-agents and payload markers in access logs
grep -iE 'php2shell|p2shell|PHP_SESSION_UPLOAD_PROGRESS' \
  /var/log/nginx/access.log /var/log/apache2/access.log 2>/dev/null

# Suspicious large multipart POSTs returning 200 (worth a closer look)
awk '$6 ~ /POST/ && $10 > 100000' /var/log/nginx/access.log | head

# Anything freshly dropped in the usual staging spots
find /tmp /dev/shm /var/tmp -type f -newermt '2026-10-17' -ls 2>/dev/null

If any of that turns up something real, stop reading hardening tips and switch into incident-response mode: preserve evidence first, contain, then clean. Deleting the shell before you understand how it got there is how you end up reinfected by Friday.


Here’s what stays with me about PHP2Shell. For years, the advice I’ve given clients has been some version of “keep the stuff on top of PHP patched”, the plugins, the themes, the frameworks, the application code. That advice is still correct. But this disclosure is a reminder that the layer underneath all of that is software too, maintained by humans, and occasionally it’s the thing that breaks. The interpreter you never think about is as much a part of your attack surface as the newest plugin you installed yesterday.

And honestly, that’s the whole argument for treating security as a practice rather than a checklist. The teams that will shrug this one off aren’t the ones with the fanciest tooling, they’re the ones who already knew which PHP versions run where, who already had a tested way to push a patch and restart their workers, and who were watching their logs closely enough to notice the scanning start. Everyone else spent this week finding out, under pressure, what they didn’t have documented. The bug was the same for both groups. The difference was the process around it.

So: patch now, restart your workers, apply the stopgaps if you genuinely can’t patch yet, and go check whether anyone got there before you did. Then write down what you learned, because there will be a next time.


Not sure whether your servers, applications, or hosting are exposed to PHP2Shell, or whether something already slipped through during the exposure window? This is exactly the kind of thing I help with. I can review your stack, confirm which PHP versions are actually running where, verify the patch landed (workers and all), and check for signs that someone reached in first. If that would take a weight off your shoulders, take a look at the server security review and ongoing care, or just send me an email and tell me what you’re running.

Pablo Huertas is a security operations engineer and team lead with 19 years in enterprise security support. He writes about SIEM operations, incident response and hardening, and takes on freelance projects. More about him.


Share this post:

Previous Post
Transitive trust: When your vendor's vendor is your attack surface
Next Post
DMARC in production: The road to p=reject without breaking your mail