**Lab reproduction, exposure probe and detection content for CVE-2026-109618 and CVE-2026-109619 ("PHP2Shell").**
`.
* `php2shell-repro` reproduces **only the availability symptom**: a fatal out-of-memory error raised while PHP is still parsing the request body. That is enough to prove a target runs a vulnerable interpreter, and it is the signal defenders actually hunt for.
* The lab containers are deliberately misconfigured (`memory_limit = 16M`) so the failure is easy to observe. Never copy `lab/*/php.ini` into anything real.
* Run the tooling **only against systems you own or have explicit written authorisation to test**.
The exploit chains themselves were published by [Calif]( [Wiz]( and analysed by [Datadog Security Labs]( Go read those if you want the offensive detail. This repo deliberately stays on the other side of the line.
`PHP2Shell` is a pair of use-after-free bugs in the PHP engine itself, disclosed on 21 October 2026 with a CVSS v4.0 of 9.2 each. They affect every PHP since **5.4.0 (2012)** and are reachable *before any application code runs* — authentication, WAF rules inside the app, and framework-level filtering are all irrelevant.
That combination makes it a good case study, because it forces you to answer questions that a plain exploit dump does not:
1. **Inventory** — which PHP runtime actually serves traffic? (CLI version is not the answer.)
2. **Exposure** — which of the two CVEs' preconditions are present on a given host?
3. **Detection** — what does an attempt look like in logs, given that a successful exploit can return HTTP 200 and leave the worker alive?
4. **Root cause** — why does updating hash-table counters before allocating the key turn an OOM into memory corruption?
This repo is my attempt at answering all four in a reproducible way.
| Class | Interrupted initialisation → UAF | Stale per-worker state → UAF / type confusion |
| Trigger | Allocation failure (OOM) mid-request-parse | Fatal error or late shutdown diagnostic |
| Impact | Memory disclosure + RCE | RCE |
| Precondition | `memory_limit` reachable by a request body | `session.upload_progress` (default on); on 8.5 also fatal-error backtraces |
| Fixed in | 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12 | same |
Affected: Apache `mod_php`, PHP-FPM, `php-cgi`, FrankenPHP, LiteSpeed — anything that serves HTTP through PHP.
Full technical write-up: [`docs/analysis.md`](docs/analysis.md).
| `php2shell_lab/versions.py` | Version classification against the fixed-release table |
| `php2shell_lab/probe.py` | Non-destructive exposure probe (`php2shell-probe`) |
| `php2shell_lab/repro.py` | Availability-only reproduction harness (`php2shell-repro`) |
| `php2shell_lab/triage.py` | Log triage for exploitation indicators (`php2shell-triage`) |
| `lab/vuln`, `lab/patched` | PHP 8.5.11 vs 8.5.12 containers, identical app |
| `detections/` | Sigma rule, nginx/Apache mitigation snippets |
| `docs/` | Root-cause analysis, detection notes, references |
| `tests/` | Unit tests for classification and log triage |
Zero runtime dependencies — everything is Python standard library.
* ` — PHP **8.5.11**, vulnerable, `memory_limit = 16M`
* ` — PHP **8.5.12**, patched, same configuration
Both serve an identical three-line `index.php`. That is the point: the bug is in the interpreter, not the app.
If `pip` puts the console scripts somewhere outside your `PATH` (common on
Windows), the modules are runnable directly:
python -m php2shell_lab.probe
upload progress enabled (precondition for the 109619 upload path)
php2shell-repro --i-understand-this-kills-workers
The acknowledgement flag is not decoration: a vulnerable worker **will** die
and be respawned by Apache. The harness sweeps field-name lengths, sends
`application/x-www-form-urlencoded` bodies, and reports which length produces
PHP Fatal error: Allowed memory size of 16777216 bytes exhausted
(tried to allocate 3500032 bytes) in Unknown on line 0
`Unknown on line 0` is the fingerprint — the failure happened during request initialisation, before a single byte of application code executed. Against `:8081` the same sweep should not produce a clean corruption path.
php2shell-triage /var/log/apache2/error.log --access-log /var/log/apache2/access.log
A successful `PHP2Shell` exploit may return **HTTP 200**, may not crash the worker, and leaves the process tree looking almost normal. So detection cannot rely on a single request signature. The reliable approach is correlation across three layers: oversized/structurally weird form submissions, `memory_limit` exhaustion logged at `Unknown on line 0`, and a shell spawned as a child of the web worker. See [`docs/detection.md`](docs/detection.md) and the Sigma rule in [`detections/sigma/`](detections/sigma/).
The one-line temporary mitigation that actually holds at the boundary:
# nginx: reject multipart before it reaches the PHP parser.
if ($http_content_type ~* "multipart/form-data") {
It breaks legitimate uploads. It buys time. It is not a fix. **Patch PHP.**
│ ├── versions.py # fixed-release table + classification
│ ├── probe.py # exposure probe (non-destructive)
│ ├── repro.py # availability-only harness (lab)
│ ├── vuln/ # PHP 8.5.11 + mod_php
│ └── patched/ # PHP 8.5.12 + mod_php
│ ├── analysis.md # root cause + patch diff
**Standard library only.** A portfolio tool that needs `requests`, `rich` and `click` to print four lines is a liability on an incident responder's laptop. Everything here runs on a bare Python 3.9+.
**Availability-only reproduction.** The interesting engineering problem in `PHP2Shell` is the *root cause*, not the shell. Reproducing the OOM-at-initialisation path demonstrates that the interpreter is unpatched and gives defenders a concrete log signature to test their rules against — without shipping a weapon.
**Version classification is branch-aware.** `8.5.11` is affected, `8.5.12` is not, but `8.1.34` is affected *and has no upstream fixed release* — EOL branches only got source backports. Collapsing that into a boolean is how inventories go wrong.
See [`docs/references.md`](docs/references.md).
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
