Skip to content
PHP2SHELL exploit

PHP2SHELL exploit

Sploitus • November 18, 2026

This repository contains the lab setup, proof-of-concept code, test harness, and logs from my investigation of PHP2Shell (CVE-2026-109618 and CVE-2026-109619).

I also tested two application-level session attack patterns that remain possible on patched PHP versions.

**This repository contains working exploitation code.** All testing was performed in an isolated lab environment. Read [SECURITY.md](SECURITY.md) before running anything.

> **Correction, 18 November 2026.** Earlier versions of this README, and the validation report, said PHP 8.4.26 showed allocator corruption in 10 of 20 trials. That was a counting error in the validator. The raw log shows the worker aborting with `zend_mm_heap corrupted` in all 20. The details, and seven smaller corrections, are in [ERRATA.md](ERRATA.md).

I've documented the research in a three-part series on **[cybersecly.com](

1. **[Part 1: Internals and sessions]( PHP request lifecycle, sessions, memory management, and OOM handling.

2. **[Part 2: Source analysis and patches]( Comparing PHP 8.4.26 and 8.4.27 to understand the changes.

3. **[Part 3: Reproduction and results]( Lab setup, test results, GDB analysis, and lessons from failed attempts, including the counting error behind the correction above.

This repository contains the code and supporting evidence discussed in the articles.

Five builds, 20 trials each, one configuration: Apache with mod_php, prefork, a single worker, `memory_limit = 16M`, `post_max_size = 64M`, upload progress on.

| OOM reproduced | 20/20 trials on each of the five builds |

| Allocator corruption and worker abort on PHP 8.4.26 | 20/20 trials |

| Allocator corruption on PHP 8.4.27 | 0/20 trials |

| Allocator corruption on PHP 8.3.36 | 0/20 trials |

| Allocator corruption on PHP 8.2.35 | 0/20 trials |

| Allocator corruption on PHP 8.5.12 | 0/20 trials |

| Original corruption site identified | No |

| RCE through memory corruption | Not demonstrated |

The results reflect the conditions of my lab. 20/20 is what one sequence of requests, at one size, did in one configuration, with the trials run one after another against the same container. It is not an exploitation probability. Elsewhere in the same log, two rounds of five trials ended with an abort in only 2 and 3 of them (see [ERRATA.md](ERRATA.md), item 2). Similarly, 0/20 does not mean corruption is impossible on patched builds: it means none was observed, and the logs of the four patched containers contain no abort at all.

8.4.26 and 8.4.27 were run again with the fixed validator on 17 and 18 November 2026, and both runs gave the same result: corruption and a worker abort in 20 of 20 trials on 8.4.26, none in 20 on 8.4.27. The reports and logs are in `evidence/replication-2026-11-17/` and `evidence/replication-2026-11-18/` ([ERRATA.md](ERRATA.md), items 9 and 10). The other three builds were not run again.

The two application-level chains (Categories A and B) ended in command execution inside the lab's deliberately vulnerable apps. On 18 November both were run again against PHP 8.4.27, the patched release, and both ended in command execution as `www-data`; the output and logs are in `evidence/replication-2026-11-18/`. My earlier runs on PHP 7.4.33 and 8.1.34 remain a lab record without logs.

You do not need Docker or the lab for this. It reads the published reports and the published raw logs:

python3 poc/recount.py --report evidence/replication-2026-11-17/REPORT.json --root .

python3 poc/recount.py --report evidence/replication-2026-11-18/REPORT.json --root .

python3 -m unittest discover -s poc/tests -v

`recount.py` matches every trial to the Apache exit notices logged during it, and to the worker's pid where the report recorded one, and prints the report's count beside the raw log's count. The first command shows the October report's under-count of 8.4.26; the two replications agree with their reports. It exits 2, and says INCONCLUSIVE, when a log is missing or cannot support a verdict.

lab/ Dockerfiles, PHP configurations, and test applications

cat-a include sink + upload progress (application-level)

cat-b serialize-handler mismatch (application-level)

cat-c unserialize() baseline for the detection probe

cat-c-vuln the PHP 8.4.26 study environment; takes PHP_VERSION

cat-c-bw PHP 8.4.26 on the Debian bookworm image, same limits

cat-c-def PHP 8.4.26 on bookworm with stock limits

php2shell.py the harness (Categories A, B and C)

c_validate.py N-trial validator for Category C

recount.py recounts a report from its raw logs

logcount.py the abort counter those three

ci_validate.sh gate around c_validate.py

tests/ unit tests; no Docker needed

debug/ gdb command file, trace runner, and notes

archive/ superseded versions, kept as they were run

evidence/ Raw container logs from the five-build run

Every port is published on `127.0.0.1` only. Keep it that way: these apps are deliberately vulnerable.

Start the application-level test environments:

These three build on PHP 8.1 by default. PHP 8.1 is end-of-life and never received the October 2026 fixes. The weakness in Categories A and B is in the application, not the PHP version, so to run them on a patched release pass the version when you build, for example `docker build --build-arg PHP_VERSION=8.4.27 lab/cat-a`.

Build and start the vulnerable PHP 8.4.26 environment separately:

docker run -d --name php2shell-cat-c-vuln -p 127.0.0.1:8084:80 php2shell-cat-c-vuln

The vulnerable environment uses PHP 8.4.26, the last 8.4 release without the fix. For a patched comparison in the same configuration, build the same directory with another version:

docker build --build-arg PHP_VERSION=8.4.27 -t p2s-c8427 .

docker run -d --name p2s-c8427 -p 127.0.0.1:8088:80 p2s-c8427

The October run used ports 8084 (8.4.26), 8088 (8.4.27), 8085 (8.2.35), 8086 (8.3.36) and 8087 (8.5.12).

--target '8.4.26| \

--target '8.4.27| \

--evidence-dir runs/evidence --out runs/c_validation.json

Each target is `name|url|kind|container|probe url`. The validator needs to read the container's log through `docker logs`, so run it on the Docker host. Write to `runs/` as shown, not to `evidence/` or `poc/`, or you will overwrite the archived October files.

This request sequence makes the PHP 8.4.26 worker abort. Run it only against the containers above.

`poc/ARTIFACTS.sha256` and the report record SHA-256 values for the scripts and logs as they were for the October run. [ERRATA.md](ERRATA.md) item 6 goes through that list line by line, including the one entry that does not match a published file. The validator and minimizer that produced the October results are kept unmodified in `poc/archive/`.

`.gitattributes` stops git from converting line endings, so the hashes also verify on a Windows checkout.

- No code execution, and no memory disclosure, through the memory corruption.

- No identification of where the corruption is created. Only the place where the allocator notices it is known.

- No claim that a clean result on a patched build holds for other configurations.

- No claim that Categories A and B are the two CVEs. They need an include sink, or two endpoints with different session serialize handlers plus a loaded gadget class.

Docker with Compose, Python 3.8 or later, and the `requests` package for the harness and validator. `recount.py` and its tests need only the standard library.

Extracted Entities