Back Sploitus Exploit for Improperly Controlled Sequential Memory Allocation in Php
# php2shell: PHP2Shell (CVE-2026-109618, CVE-2026-109619) detection, scanning and exploitation tool
A single-file, standard-library-only Python tool for the pair of PHP core memory-safety issues
disclosed on 2026-10-21 under the name "PHP2Shell".
| CVE-2026-109618 | the out-of-memory `longjmp()` bailout unwinds out of multipart parsing while request memory is still partly initialised, so a hijacked vtable or control flow follows | 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12 | NVD CVSS:3.1 9.8 Critical |
| CVE-2026-109619 | global state survives the request boundary: `PS(id)` yields a stale pointer that is URL-encoded into the `Set-Cookie`, `EG(last_fatal_error_backtrace)` and OPcache entries keep stale type information, which gives remote memory disclosure and then RCE | same releases | same scale |
`php2shell.py versions` prints the built-in advisory database (advisory IDs, KEV status,
mechanism, SAPI notes, Nessus and WAS plugin ids, public PoC references, affected and fixed
version lines, and the exact-image profiles used for RCE).
Python 3.8 or newer, standard library only: no `requests`, no third-party packages. Development
and testing used a dedicated miniforge conda environment named `php2shell`. Inside it, or in any
environment with a comparable Python, the interface is:
# 1. cheap version and behaviour scan, one or many targets
python3 php2shell.py scan -t \
-t --format text
python3 php2shell.py scan -i hosts.txt --workers 16 -P /phpinfo.php --format csv --out scan.csv
# 2. what is reachable from the network right now (safe, single target)
python3 php2shell.py probe -t -v \
--flood-steps 1000,20000,120000 --read-error-log /var/log/php_errors.log
# 3. CVE-2026-109619 cross-request disclosure (needs a PHPSESSID on the target)
python3 php2shell.py disclose -t --attempts 3 -v
python3 php2shell.py exploit -t --mode lfi \
--uri /vuln/lfi.php --lfi-param page --cmd id --attempts 3
python3 php2shell.py exploit -t --mode leak -v
python3 php2shell.py exploit -t --mode rce \
--profile ubuntu-php-8.5.11-modphp --libphp-base 0x7f... --heap-base 0x5d... --cmd id
# 5. the advisory and fix database as machine-readable output
python3 php2shell.py versions --format json
| `scan` | version and behaviour verdict for many targets | reads `Server` and `X-Powered-By`, optional phpinfo pages (`--phpinfo-paths`, `-P`); never sends exploit-sized bodies |
| `probe` | one target, activation checks that do not corrupt memory | multipart reachability, upload-progress differential (cookie, file and error-log delta), header flood, nested names and empty file fields ladder, declared versus chunked size, `oom-reachable` |
| `disclose` | CVE-2026-109619 memory-leak prologue | A1 (OOM producer) then B1 (reclaim plus forged `zend_string`) on the same recycled worker, then reads the overlong `Set-Cookie` |
| `exploit` | `--mode leak`, `lfi` or `rce` | `lfi` uses the RFC1867 upload-progress value and an include sink race, so it needs no offsets; `rce` runs the full OOM and hijack chain and needs a matching profile or explicit `--libphp-base` and `--heap-base` |
| `versions` | offline advisory and fix database | `--format json` for pipelines |
The four network commands `--target/-t` (repeatable), `--file/-i`, `--port/-p`, `--tls`,
`--uri`, `--format text|json|csv`, `--out/-o`, `--phpinfo-paths/-P`, `--no-phpinfo`,
`--insecure`, `--sni`, `--timeout`, `--retries`, `--verbose/-v` and `--quiet/-q`, and `--help`
describes each flag in full. `probe` adds `--flood-steps`, `--empty-parts`, `--chunk-oversize`
and `--read-error-log`. `disclose` and `exploit` add `--pin` and `--no-pin`, `--workers`,
`--workers-max`, `--holder-timeout`, `--oom-timeout`, `--attempts`, `--leak-threshold`,
`--pointer-floor`, `--a1-*`, `--mid-pages`, `--nested-fields`, `--fake-len`, `--forge-page` and
`--query`. `exploit` alone takes `--mode leak|lfi|rce`, `--cmd`, `--profile`, `--libphp-base`,
`--heap-base`, `--zval-ptr-dtor`, `--zif-system`, `--pivot`, `--ret`, `--pop-rdi`, `--pop-rsi`,
`--rce-headers`, `--rce-block-offset`, `--lfi-param`, `--lfi-path`, `--lfi-template`,
`--lfi-fill-size`, `--lfi-slow`, `--lfi-marker-param`, `--lfi-extra-params`, `--sess-prefix`,
`--oob-host`, `--oob-port` and `--proof-url`.
`mode lfi` takes `--uri` as the POST endpoint and, unless `--lfi-path` overrides it, as the
default include sink path, so pass `--uri /the/include/sink.php`.
| 0 | nothing confirmed vulnerable (patched, unaffected, or not applicable) |
| 1 | at least one target confirmed vulnerable, or a leak or RCE verified |
| 2 | no version and no live confirmation, so inconclusive, which is not evidence of a safe host |
The tool separates indication from confirmation, and `confirmed` is a tri-state (`true`, `false`,
`null`). Text output prints `confirmed`, `note` or `note_confirm`, and `errors`; the CSV columns
are `target, php_detected, php_version, php_version_source, status_first, server,
x_powered_by, verdict, code_path, cves, fixed_in, confirmed, leak_bytes, rce_verified, note,
A version below the fixed line is an indication (`verdict: vulnerable`, `confirmed: null`) until
a probe shows the code path live or an exploit lands. `code path: live` requires an observed OOM
fatal error, a worker death or restart event, or an upload-progress differential that was
actually verified, meaning a response cookie, a session file under `--sess-prefix`, or a fresh
Mitigations are listed as seen only when they were verified:
`session.upload_progress.enabled=0` needs the phpinfo row, or the error-log and session-file
evidence that the setting is on, and `fatal_error_backtraces=0` likewise on PHP 8.5.
Size limits change what a response means. A `200` answer to a large body is `post_max_size` or
`upload_max_filesize` truncation, not evidence that the whole body was read into PHP memory. PHP
8.3 and newer also cap multipart parts at an effective 1020 when `max_multipart_body_parts=-1`,
and PHP 8.3 and newer enforce `memory_limit` again, so `memory_limit=-1` is a documented but
incomplete mitigation and `>= 2G` can crash the binary.
Pinning and the full CVE-2026-109618 chain are demonstrated on Apache prefork `mod_php` only. On
PHP-FPM the OOM phase kills workers and breaks lane reuse, so a negative `disclose` or `exploit`
result on FPM is inconclusive rather than proof of a patched host, and the tool prints this as an
error or `errors` entry when the readable SAPI is not Apache.
Do not cap PHP with `RLIMIT_AS` or `RLIMIT_DATA`, because `mmap()` failure on its own triggers
the vulnerable `longjmp()` path. Patching, followed by a restart of PHP-FPM or Apache so workers
reload, is the only complete mitigation; blocking `multipart/form-data` at the frontend removes
the input surface when the application needs no uploads.
`disclose` and `exploit` read the phpinfo ini rows first and state what the limits mean before
spending attempts. On a host with `post_max_size=8M` the roughly 33 MB B1 shape cannot land, and
the tool reports the run as environment-limited instead of presenting "no disclosure" as "patched".
bash lab/lab-up.sh # Apache 2.4.68 prefork and mod_php 8.4.24 on 127.0.0.1:8080, no root needed
`lab/conf/httpd.conf.example` and `lab/conf/php.ini.example` are templates in which `@LAB@`
stands for the lab directory. `lab-up.sh` derives that path from its own location and writes the
runnable `conf/httpd.conf` and `conf/php.ini` when they are missing or older than the templates,
so the machine-specific path never enters git and the lab works after a clone in any directory.
The generated Apache config is self-contained, with `ServerRoot` at the lab tree, prefork
`ServerLimit` and `MaxRequestWorkers` at 32, and `DocumentRoot` at `lab/htdocs`. `lab-up.sh`
exports `PHPRC=lab/conf/php.ini`, so mod_php uses the lab limits `memory_limit=128M`,
`post_max_size=8M`, upload progress on, `display_errors=Off` and `log_errors=On`, with the log at
`lab/logs/php_error_log`. The generated config, `lab/logs/` and `lab/tmp/` are gitignored. The
document root holds `index.php`, `phpinfo.php`, `plain.txt`, `sess.php` and `vuln/lfi.php`, the
last of which runs `include $_GET['page']`.
The PHP is 8.4.24, below the 8.4.27 fix. Measured results follow. `scan` gives
`verdict: vulnerable` and `fix: 8.4.27`, exit 1. `probe` gives `upload-progress on` as verified,
`code path: live`, `sapi: Apache 2 Handler`, the ini block read from `/phpinfo.php`, and notes
that record the 1020-part cap and the `post_max_size` truncation, exit 1. `disclose` discovers
the worker pool from the network (`ceiling = 32`) and ends with `confirmed: false` plus
`errors: post_max_size=8M ... environment-limited`, because the leak geometry needs a larger
`post_max_size`; this is a lab limitation, not a patched host. `exploit --mode lfi` verifies RCE:
`verified=True HTTP 200 113` on attempt 1, exit 1, and the `id` output shows a uid 1000
unprivileged account. `exploit --mode rce` declines: the leak stage produced no dominant pointer
under the same 8 MB truncation, so the RCE stage is never claimed, and the message asks for
`--libphp-base` and `--heap-base`, or for `--mode leak` on a host able to carry the shape. The
lab's `libphp8.4.so` is stripped and has no `jump_fcontext` or `zif_system` symbols, so the
built-in Ubuntu 8.5.11 profile offsets cannot be derived there either.
Three rule families, all written from what this lab produced rather than from guessed strings, so
each file records where its signatures came from.
`rules/nuclei/` holds 6 templates, validated and run against the live lab with nuclei v3.11.1:
nuclei -validate -templates rules/nuclei # "All templates validated successfully"
nuclei -templates rules/nuclei -u -silent
nuclei -templates rules/nuclei -u -silent
| `php2shell-php8-inuse` | header word `PHP/8.` with an extractor, so the running version is reported | matched, `PHP/8.4.24` |
| `php2shell-phpinfo-exposed` | 4 phpinfo paths with `stop-at-first-match`, requiring both `PHP Version ` and `max_multipart_body_parts` | matched on `/phpinfo.php` |
| `php2shell-vulnerable-version-phpinfo` | RE2 alternation of every build below 8.2.35, 8.3.36, 8.4.27 and 8.5.12, plus all PHP 8.1 and older lines | matched, `PHP Version 8.4.24`, severity high |
| `php2shell-upload-progress-handler-on` | the `session.upload_progress.enabled` row followed by `On`, which is the phpinfo table format measured in the lab | matched, severity medium |
| `php2shell-session-cookie-in-use` | header word `PHPSESSID=` | did not match on `/`, which never calls `session_start()`, and matched on `/sess.php` |
| `php2shell-wide-multipart-request-startup-warning` | POSTs 1100 empty parts to `/index.php` and `/`, then matches PHP's own clipping warnings | matched with `display_errors=On`, did not match with `display_errors=Off` |
The last two rows depend on two measured details, which also explain how that template is built.
With `display_errors=On` the 1100-part POST returns both `Multipart body parts limit exceeded
1020` and `Input variables exceeded 1000` in the body. With `display_errors=Off` the same request
still logs both lines and still answers 200 with a clean body, so a nuclei miss on a hardened
host is expected, and the Sigma rule below covers that case. The body is sent as nuclei block
scalars with real newlines on purpose, because nuclei v3.11.1 does not unescape literal `\r\n`
text inside a raw request, and PHP parsed none of the 1100 parts when given that literal text,
which was measured both ways. PHP also accepts LF-only multipart separators, so the template
sends no explicit `Content-Length` and relies on nuclei's own framing.
`rules/sigma/` holds 4 rules, parsed with PyYAML. This machine has no sigma CLI or sigmaker, so
none of them went through a Sigma engine. `php2shell-php-oom-fatal` is level high and keys on the
OOM fatal, whose `in Unknown on line 0` tail shows that it fired during request startup.
`php2shell-php-request-startup-truncation` is level medium and quotes the two clipping warnings
verbatim. `php2shell-apache-worker-pool-saturation` is level medium and uses the `AH00161` line
measured during pinning. `php2shell-oversize-multipart-post-answered-200` stays experimental: the
lab configured no `CustomLog`, so that access-log shape comes from the PHP-side evidence and the
tool's wire sizes. Field names are ECS and need mapping to your own log pipeline.
`rules/waf/php2shell.conf` holds 12 ModSecurity statements, 9 main rules and 3 chained
sub-rules, with ids `202610961801` to `202610961853` and `202610961901` to `202610961902`, all
unique and chosen to avoid collisions with the Core Rule Set. The statements cover a part count
above the measured 1020 cap, header floods inside one part, an oversized request-header count,
nested multipart field names, wide requests with empty file fields, the 16 MB body limit that
stops the 33 MB leak geometry, `Expect: 100-continue` held POSTs, which is the pinning pattern
and detection only, the overlong `PHPSESSID` response cookie that is CVE-2026-109619's leak
output, and a catch-all multipart log. Each line passed a quote-aware SecRule parser that checks
statement count, ids, phases, action tokens and line continuations. `libapache2-mod-security2` is
absent here, so the file was never loaded by a ModSecurity engine; deploy it with
Run it with the interpreter from the `php2shell` conda environment, either by activating the
environment first or by calling its `bin/python` directly:
python -m unittest -v test_php2shell # 49 tests
The suite covers version classification (8.3.x and 8.4.x vulnerable, 8.4.27 patched, end-of-life
lines), CSV and PHP-version parsing, the A1, B1 and RCE body geometry, cookie-decode analysis,
phpinfo ini parsing including `e` and `v` rows, the `Server API ` trailing space and size
suffixes, the limit pre-flight that reports environmental limits, holder wire format, where an
`Expect: 100-continue` plus chunked body must be written before waiting for the interim response,
output formats, and the exit-code contract.
`probe --flood-steps`, `disclose` and `exploit` push a worker to an OOM fatal on purpose, which
on shared hosting can kill a live worker or trip a supervisor. Run one target at a time, watch the
error log, and keep the exploit modes out of production without a change window.
Worker pinning opens `--workers` held connections, so keep `--workers` at the real pool size;
`--workers-max` bounds auto-discovery and `--holder-timeout` bounds each attempt.
Vendor packages need package-level checking, because Debian and Ubuntu backport fixed releases
inside the same `8.x.y` string, which makes a version string alone misleading. `scan` reports the
version verdict, and `probe` or `exploit` decides whether the code path is live.
工具 `php2shell.py` 为纯标准库单文件,提供 `scan`、`probe`、`disclose`、`exploit`、`versions`
五个子命令,覆盖 PHP2Shell 两个漏洞的版本判定、行为指纹检测、跨请求内存泄露验证与利用:
CVE-2026-109618 是 OOM 后 `longjmp()` 跳出多部分解析造成的内存破坏,CVE-2026-109619 是请求间
全局态残留造成的内存泄露进而 RCE。三种利用模式中,`leak` 用于泄露几何,`lfi` 用上传进度值与
包含落点竞态落地,`rce` 走完整 OOM 到劫持链。修复版本为 8.2.35、8.3.36、8.4.27、8.5.12,打补丁
`lab/` 是免 root 的可复现环境(Apache 2.4.68 prefork、mod_php 8.4.24,监听 127.0.0.1:8080)。
实测结果:`probe` 确认 upload-progress 与 code path live;`exploit --mode lfi` 完成 RCE 验证,
`id` 输出为 uid 1000 的非特权账户;`disclose` 与 `--mode rce` 在 `post_max_size=8M` 的主机上
报告"环境受限",约 33 MB 的 B1 形状无法落地,结论记为不可判定,不记为已修复。退出码 0、1、2、3
检测层位于 `rules/`,分三套。`rules/nuclei/` 的 6 条模板通过 nuclei v3.11.1 的 `-validate`,并在
lab 上实测命中;`rules/sigma/` 的 4 条日志规则只经 PyYAML 与结构校验,未经 sigma 引擎编译;
`rules/waf/php2shell.conf` 的 12 条 ModSecurity 语句由自行编写的 quote-aware SecRule 解析器校验,
本机未安装 `libapache2-mod-security2`,上线前建议先以 `SecRuleEngine DetectionOnly` 运行一段
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.
