PHP2Shell — lab visualiser

CVE-2026-109618 / CVE-2026-109619 · CVSS 4.0 9.2 · PHP core remote code execution

⚠︎ Educational illustration of data measured in the lab — not a live vulnerable service

Configuration

post_max_size = 256 MiB

Request cost

Wire body—
PHP peak memory—
Amplification—
Wire as % of post_max_size—
—

Memory picture

Wire bytes (what the attacker sends)—
PHP request memory (what it costs the server)—
limit

Measured data (memory_limit 64 MiB)

Part headersWire8.4.26 peak8.4.27 peakOutcome

Values between the measured points are linearly interpolated; values beyond the last measured point are extrapolated along the final slope. Patched builds were flat at 2 MiB across every payload tested.

Stage 2 — what the OOM leaves behind

Stage 1 ends with the request dying. Stage 2 asks what the next request on that worker receives. Session upload progress runs during request startup, before any application code, and PHP echoes the session id back in Set-Cookie — so if the id is read out of recycled memory, the response itself carries the result. Measured on php:8.4.26-fpm-alpine3.23 / 8.4.27-fpm-alpine3.23 as php -S with 4 workers.

ConditionSession id lengthOutcome
8.4.26 · fresh worker32 B, all 8clean
8.4.26 · after one OOM8 B in 18–20 of 20stale memory read
8.4.26 · after one OOM, heap producer geometryno id in 7–10 of 10corrupted allocation size
8.4.27 · after the same payload32 B, all 20clean — producer never exhausts memory

The fresh-worker row is the control that makes the rest mean something: without a preceding OOM the same request shapes are completely clean. Literal bytes observed:

fresh worker : PHPSESSID=7008ad13f65794ab4624eacca122d8b4
after one OOM: PHPSESSID=%01%00%00%00%00%00%00%00
alongside Warning: PHP Request Startup: Session ID is too long or contains illegal characters — the warning PHP's own regression test asserts.

The emitted length follows attacker input. Sweeping the follow-up request's filler value size:

Filler value sizeEmitted session id
16 B16 B
96 B96 B
128 B32 B — no anomaly at this size
256 B256 B
512 B512 B
32, 48, 64, 192 Bno id — the request died first

So the id's length field comes from memory the request recycled, and at these field sizes the bytes are the request's own filler. Superseded 28 Oct 2026: growing the value until a single allocation contains the stale pointer decouples the length from the buffer it is read from — an instrumented build measured a 4660-byte id from an attacker-chosen length, with live heap pointers in the tail. See the Stage 3 card below. Recorded negatives: that PoC's pipelining (this CLI server returns zero responses for any pipelined batch), its 256-byte over-read and its 16-byte code cookie did not reproduce here. Counts vary between runs; the shape of the result is stable, the tally is not.

Stage 3 — decoupling the length from the buffer

The emitted length is a zend_string struct field, so whether PHP reads a truthful length depends on where the stale pointer lands — not on what the payload contains. PS(id)+0x10 is the length PHP will trust; +0x18 is where it reads bytes from. Land at the start of a buffer you control and the length is truthful; land inside it at offset ≥ 0x18 and the length is yours. Neither is visible from the wire, so this was measured from inside the process with an instrumented build.

QuestionMeasurement
Does the stale pointer land inside a buffer we control? Yes — a 1024-byte value contains it (at +0x278 in one run, +0x128 in another: the offset moves, the containment does not), 4096 B at +0x78, 8192 B at +0x78. A 256-byte value does not, which is why the Stage 2 sweep never left its own buffer. stage3.py discovers the shape and the offset at runtime rather than assuming either.
Is the emitted length ours to choose? Yes — claiming 0x1234 produced a 4660-byte session id in every run that completed a rep (2 of 3 reps on fresh pools; 4 of 4 in an earlier run, before the pools were split per rep).
Is the tail memory we did not write? Yes — marker bytes from other allocations appear in the output, plus nine heap-like 0x7… values spaced 0x40 apart, i.e. a HashTable bucket array.

Closed with one inequality rather than an eyeball: the read began in a 1024-byte buffer at V, so it ends at V+0x400, and every leaked pointer lies beyond that address. Masking one to Zend's 2 MiB alignment gives the allocator's chunk base — the input the next two chain steps need. No code pointer, no forged structure, no control-flow change: this is chain step 3.

Where this sits in the exploitation chain

  1. Reach OOM inside the declared limitsdemonstrated
    A small multipart body exhausts memory_limit while staying far inside post_max_size, during request startup.
  2. Read stale state out of the previous request's memorydemonstrated
    After one aborted request, the next request on that worker has its session id taken from recycled memory — 18–20 of 20 runs, against 0 of 20 on a fresh worker and 0 of 20 on the patched build. A different producer geometry makes the same worker die on an allocation size taken from stale memory instead.
  3. Control content, location and timing of the corrupted memorydemonstrated
    Via an instrumented build: the stale pointer can be made to land inside a buffer we control, so the emitted length is attacker-chosen (4660 bytes from a claimed 0x1234, 4/4 runs) and the read continues past our allocation into heap holding live pointers. Shown on Zend's allocator and a single worker; the glibc malloc pairing and multi-worker reliability are not.
  4. Turn a read into a jumpnot demonstrated
    The stale value must be used as a pointer, length or index — plus an information leak to defeat ASLR/PIE.
  5. Bypass mitigationsnot demonstrated
    NX requires a ROP chain; stack canaries and CET/shadow stack add further constraints.
  6. Make it reliablenot demonstrated
    Consistent exploitation across a multi-worker prefork pool under normal traffic.

A public proof of concept exists for the full chain; it publishes no wire capture, and the parts of it that did not reproduce here are listed above rather than assumed away. A successful RCE yields code execution as the web worker account (www-data), not root — privilege escalation is a separate step.