# Grounding — CVE-2026-109618 / CVE-2026-109619 ("php2shell") All facts below were pulled from primary sources on 2026-10-24, not from PoC README prose. Every URL listed in §4 was actually fetched; the NVD records were parsed from the API JSON. ## 1. Identifiers | Item | Value | Source | |---|---|---| | CVE-2026-109618 | "RCE via OOM corruption" | NVD 2.0, `vulnStatus: Analyzed`, published 2026-10-21T14:17:09 | | CVE-2026-109619 | "RCE via stale global state" | NVD 2.0, `vulnStatus: Analyzed`, published 2026-10-21T14:17:09 | | Vendor advisory 109618 | GHSA-w8hw-w9fx-j79w (php-src), critical | GitHub Security Advisory API | | Vendor advisory 109619 | GHSA-6wmf-4rv5-p3rp (php-src), critical | GitHub Security Advisory API | | CNA | PHP Group (`security@php.net`), assigner short name `php` | cveawg.mitre.org API | | CVSS | 4.0 = 9.2 `AV:N/AC:H/AT:P/PR:N/UI:N/VC:H/VI:H/VA:H`; NVD 3.1 = 9.8 `AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H` | NVD metrics | | CWE | 416 (UAF), 755 (improper handling of exceptional conditions), 824 (access of uninitialized pointer), 1325 (improperly controlled sequential memory allocation), 1419 (incorrect initialization of resource) | NVD weaknesses | | CAPEC | CAPEC-234 hijacking a privileged process | CVE record `impacts` | ## 2. Affected versions (from NVD `cpeMatch`, not from prose) CVE-2026-109618: | Range | Fixed | |---|---| | 7.3.0 ≤ v < 8.2.35 | 8.2.35 | | 8.3.0 ≤ v < 8.3.36 | 8.3.36 | | 8.4.0 ≤ v < 8.4.27 | 8.4.27 | | 8.5.0 ≤ v < 8.5.12 | 8.5.12 | CVE-2026-109619: same upper bounds, lower bound `5.4.0` for the 8.2 branch. CPE also lists Siemens Ruggedcom APE1808 and Palo Alto PAN-OS (both embed PHP), which is why the CVE has industrial/enterprise impact beyond web hosting. ## 3. Mechanism (vendor advisories) ### CVE-2026-109618 — OOM corruption PHP uses `longjmp()` to escape on out-of-memory. Some contexts make request memory reachable before it is fully initialized; if an allocation fails there, PHP does not account for the early exit and leaves request memory invalid. The failed allocation need not be related to the invalid memory. Request shutdown may then read or branch on it. Documented OOM strategies that stay within apparent PHP limits: - multipart request without a usable declared content length → passes the initial `post_max_size` check, keeps supplying decoded body; - a multipart part with an unrestricted number of headers → in-memory representation costs far more than the wire form, so a body inside `post_max_size` still exhausts `memory_limit`; - empty file controls do not count toward `max_file_uploads` but still create the metadata arrays; nested field names multiply the generated array work. Susceptibility by SAPI: Apache mod_php invokes request shutdown **unconditionally**, even when request startup failed → application-independent, pre-auth. FPM exits the child when startup fails, so that sequence dies; FPM remains susceptible after successful startup but no complete FPM exploit was demonstrated. FrankenPHP likely mirrors mod_php. LSAPI models FPM, unvalidated. Patch: removes `longjmp()` for OOM, replaced by a delayed soft OOM at the next VM safe point plus an immediate hard OOM via `_exit()` above a second, higher threshold. ### CVE-2026-109619 — stale global state Worker-retained globals (error, session, object, extension state) point into one request's memory and must be reset before that memory is released. Some operations run before normal initialization of the next request and touch state the previous request did not reset → UAF. Exploitation needs a **producer** (state published and left behind) and a **consumer** (an operation acting on it before RINIT resets it). Producers: fatal error abandoned mid-operation (parse/compile failure, uncaught error, `require` failure, `Maximum execution time exceeded`), or OOM after state was published. Nonfatal diagnostics during late shutdown can also repopulate error state after it was cleared. Confirmed consumers before normal init: 1. **INI diagnostics** — warnings from invalid/deprecated INI applied before `php_request_startup()` (`auto_detect_line_endings`, `filter.default`, legacy `assert.*`, legacy session settings, `report_memleaks=0`, `intl.error_level`, explicit `mbstring.*`/`iconv.*`, malformed `memory_limit`/timeouts, `open_basedir`-rejected paths). `error_reporting`, `@`, and `display_errors=Off` do **not** protect. Reachable via `.htaccess` / `php_value` on mod_php, or `PHP_VALUE`/`PHP_ADMIN_VALUE` from a FastCGI frontend. 2. **Session upload progress** — reaches session handling before ordinary session init, needs no `session_start()` call, enabled by default. Confirmed concrete cases: PHP 8.5 fatal-error backtrace UAF (`EG(last_fatal_error_backtrace)`, requires `fatal_error_backtraces`), and session upload-progress lifecycle (`BG(unserialize)` / `PS(id)`). ## 4. Primitives published by Wiz (four, grouped under the two CVEs) 1. Upload-progress **unserializer UAF** — `BG(unserialize)` left published after a fatal OOM; a later request consumes attacker-reclaimed memory as live bookkeeping. 2. Remote process-**memory disclosure** — stale `PS(id)` treated as a live `zend_string`, contents URL-encoded into a `PHPSESSID` response cookie; works with no `session_start()` in the app. 3. `EG(last_fatal_error_backtrace)` UAF — 8.5 only. 4. OPcache **type confusion** — `CG(map_ptr_last)` advanced locally but published late in `zend_accel_script_persist()`, cross-worker slot reuse, wrong-type pointer. **This PoC implements 1 + 2 plus the OOM producer.** 3 and 4 are out of scope. FPM, FrankenPHP, and LSAPI paths are unvalidated here. ## 5. Stage → CVE mapping (ANALYTICAL — not vendor-published) The vendor does not label which primitive belongs to which CVE. Our reading: | Stage | Role | CVE | |---|---|---| | A1 (multipart OOM at END cleanup) | producer: leaves dangling `PS(id)` / `PS(mod_data)`, `send_cookie=1` | 109618 | | B1 (second request URL-encodes stale `PS(id)`) | consumer: memory disclosure | 109619 | | A2 (cheap OOM via nested fields) | producer: leaves dangling `PS(hash_serialize_verifier)` | 109618 | | B2 (fake reference → fake `zend_array`) | consumer: `zend_hash_destroy` calls `pDestructor` = `zif_system` | 109619 | Treat this table as an explanation, not a citation. ## 6. Sources actually used - `https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2026-109618` - `https://services.nvd.nist.gov/rest/json/cves/2.0?cveId=CVE-2026-109619` - `https://cveawg.mitre.org/api/cve/CVE-2026-109618` - `https://api.github.com/repos/php/php-src/security-advisories/GHSA-w8hw-w9fx-j79w` - `https://api.github.com/repos/php/php-src/security-advisories/GHSA-6wmf-4rv5-p3rp` - `https://www.openwall.com/lists/oss-security/2026/10/21/6` (Jakub Zelenka, PHP security team) - `https://www.openwall.com/lists/oss-security/2026/10/23/5` (Christian Fischer, Greenbone — notes the 7.3.0 lower bound and links CrowdStrike) - `https://www.wiz.io/blog/php2shell-php-rce` (four primitives) - `https://github.com/9bie/php2shell-bypass-aslr-exp` (reference chain + offset table; see caution below) ## 7. Reference chain — caution `9bie/php2shell-bypass-aslr-exp` is the only public chain read in full (A1/B1/A2/B2 + helpers). It is **reference only**: not vendored, not imported, audited read-only, executed once as a control test (T7) to prove the lab build is compatible. Its offsets are build-bound. Reported by that chain, on stock `php:8.4.26-apache` + `php.ini-production`: A1 = chunked multipart with 860 depth-64 nested empty-file fields + 14 × 103-byte fillers + 78 × 8 KB fields + 20 × 4 KB burners + a 4000-byte `PHP_SESSION_UPLOAD_PROGRESS`, OOM at END-cleanup `php_url_encode`; B1 = forged `zend_string` header (`len=0xC8000`) so `Set-Cookie` URL-encodes ~800 KB of following heap; A2 = 880 depth-64 nested fields + 115 short fillers; B2 = 384-byte fake-reference spray (500 before, 495 after) carrying a fake `zend_array`. ## 8. Calibration record Captured 2026-10-24 from `lab/status.sh` on the running target. | field | value | |---|---| | image | php:8.4.26-apache | | image id / config digest | 60111400ff77 (matches the digest recorded in the upstream offsets note) | | libphp.so path | /usr/lib/apache2/modules/libphp.so | | libphp.so sha256 | `51663cf883b1223436d4c99f31dd0225735ea5573665e4242621eee7f4ee679c` — **matches profile** | | php version / build date | 8.4.26 NTS (mod_php), built Oct 21 2026 00:31:19 | | apache version | Apache/2.4.69 (Debian), prefork pinned to 1 child | | profile selected | `php-8.4.26-apache-trixie-amd64` | | ini | display_errors=Off, memory_limit=128M, post_max_size=8M, output_buffering=0, max_file_uploads=20, max_input_vars=1000, session.upload_progress.enabled=On, save_handler=files, serialize_handler=php | | zval_ptr_dtor offset | 0x65EB60 (to be confirmed by `poc offsets` in T6) | | zif_system offset | 0x465370 (same) | | main_bucket_count | 87 | | delta range | 0x1A00000–0x1F00000 | Result: the pulled image is byte-identical to the build the published offsets were derived from, so no recalibration branch was needed. Published reference profile for comparison (from the upstream offsets note): | symbol / location | x86_64 | |---|---| | `zval_ptr_dtor` | `libphp+0x65EB60` (GLOBAL) | | `zif_system` | `libphp+0x465370` (LOCAL — needs `.symtab`, not `.dynsym`) | | `zif_passthru` | `libphp+0x465380` (LOCAL) | | fake `zend_array` `S` | `main+0xF8398` | | post-A2 `hsv` | `main+0x7D720` | | `PS(id)` | `ps_globals+0x10` | | `PS(mod_data)` | `ps_globals+0x60` | | `PS(send_cookie)` | `ps_globals+0x15E` | | `PS(hash_serialize_verifier)` | `ps_globals+0x168` | | main-chunk fingerprint | 87 pointers inside the first 2 MiB | | id / libphp clusters | 7495 / 1095 pointers in the 0xC8000 window | | libphp − main delta | 0x1A00000–0x1F00000 | ## 9. Scope Local Docker lab only. No remote hosts, no scanning, no Shodan/Censys. The artifact is a research harness, not a scanner. ## 10. Host-specific finding — the pointer window must not be hardcoded to `0x7f` The reference chain filters leak-window qwords to `0x7F0000000000 ≤ q ≤ 0x7FFFFFFFFFFF`. On this host that filter rejected every real pointer and the control run failed with "no heap pointers in leak window". Captured offsets observed across four container starts: `0x7327…`, `0x7899…`, `0x7d27…` — all below `0x7f`. The captured window was intact, just mis-filtered. Re-classifying the same 819 208 decoded bytes over canonical user space (`2^36 … 2^47−1`) reproduced the documented fingerprints exactly: | cluster | count | meaning | |---|---|---| | `0x7d27f67aab60` | 1095 | `zval_ptr_dtor` → `libphp = value − 0x65EB60` = `0x7d27f614c000` (page-aligned) | | `0x7d27f3e00000` | 7495 | id chunk | | `0x7d27f4400000` | 87 | main chunk | | `0x7d27f3c00000` | 79 | neighbour chunk | | libphp − main | `0x1D4C000` | inside the documented `0x1A00000–0x1F00000` window | Two consequences for the rebuild: 1. Widen the window to canonical user space; never assume `0x7f`. 2. Widening admits false positives. The window's **most common** in-range qword is `0x0000001600000001` (1282×) — a `zend_string` header (`rc=1`, `type_info=0x16`), which outnumbers `zval_ptr_dtor` (1095×). A "most common qword" heuristic therefore picks the wrong value once the `0x7f` filter is removed. The parser instead requires `(candidate − dtor_offset) % 0x1000 == 0` and a count quorum, then validates `libphp − main` against the profile window. Verification of the diagnosis: the reference chain, copied to `research/control/` with **only** that one literal widened and nothing else changed, produced `uid=33(www-data) gid=33(www-data) groups=33(www-data)` on the first attempt. That is the control test's value — it separates "my rebuild is broken" from "the reference's assumption does not hold in this environment". ## 11. Portability — never shell out to `bash` from the CLI On Windows, `bash` is ambiguous. Python's `shutil.which("bash")` and `CreateProcess` disagree: the former searches `PATH`, the latter searches the application directory, then the working directory, then `System32` — so from a stock PowerShell `PATH`, `bash` resolves to `C:\Windows\System32\bash.exe`, which is **WSL** and cannot open `C:/Users/...` paths. The failure surfaces as `/bin/bash: C:/…/lab/up.sh: No such file or directory` for a file that plainly exists. The same code worked from git-bash purely because git-bash's `PATH` put its own `usr/bin` first. Rule: the CLI must not depend on a shell existing or on which one wins. `poc/lab.py` calls the Docker CLI directly with an argument vector (no shell string, no `bash`), so the identical `python -m poc exploit` works from PowerShell, cmd, git-bash, zsh, and bash. Consequences that are easy to get wrong: - **Volume paths are OS-specific.** Windows needs `C:/Users/...` (forward slashes, drive letter); POSIX needs the path unchanged. `host_path()` converts separators only — it deliberately does not call `os.path.abspath`, because that maps `/srv/x` to `C:\srv\x` on Windows. - **`os.path.join` is host-dependent**, so it is correct to use it with a host root and wrong to use it with a foreign-style root in tests. - **The container entrypoint must not contain `CRLF`.** `INIT` is passed as one argv element to `/bin/sh -c`; a stray `\r` breaks it inside the container. There is a unit test for this. - The `lab/*.sh` files are thin shims (`exec python -m poc …`), so there is one implementation rather than a shell copy and a Python copy that drift apart. ## 12. Readiness probe — socket, not `urllib` `docker run -d` returns before the port is forwarded. The first version of the readiness wait used `urllib.request.urlopen("http://127.0.0.1:/index.php")` and intermittently polled for **4 minutes** before giving up, while a plain `socket.create_connection` reached the same port 0.5 s after `docker run`. There is no proxy in the environment (`getproxies()` is empty), so the difference is `urllib`'s own machinery. The probe is now a raw socket GET whose read loop stops at the header terminator, with `attempts=120, delay=0.25, timeout=1.0` and a 200-status check. Two rules that follow: - Anything the exploit path does to the target should go through the same raw-socket layer the chain uses; mixing an HTTP client library into the control plane adds failure modes that look like "the target is broken". - A readiness loop must be tested against a real local listener (`tests/test_lab_ready.py` runs a throwaway socket server and asserts 200 → body, non-200 → None, closed port → fast None). ## 13. The RCE primitive is one-shot, and connection state is irrelevant The payload lands as `pDestructor = zif_system` on a forged `zend_array`, invoked by `zend_hash_destroy` while the request shuts down. Consequences that decide what "persistence" can mean: - It executes **once per request**, inside the worker, synchronously. `system()` blocks the child until the command exits, so no background process is created unless the command itself forks one. - There is no output channel: `system()` writes to the worker's stdout, which for mod_php under Apache ends up in the error log, not the HTTP response. Anything you want to read must be written to a path you can observe — here the `/out` bind mount. - The forged array is consumed by the destroy pass, so a second command needs a fresh A1 → B1 → A2 → B2 cycle (~2 s). There is no session to resume. - **`Connection: close` on every request is fine.** Cross-request state that matters is the *worker process* (globals + heap), not the TCP connection. Keep-alive buys nothing; landing on a different child loses everything. Measured: five sequential cycles on one worker completed 5/5 with no retries, and a counter file in `/out` incremented 1→5. So repeated exploitation does not by itself kill the worker; the leak-only stage does leave it in a bad state, which is why `poc leak` followed immediately by `poc exploit` can need one retry. ## 14. TLS works at the transport layer, but a reverse proxy breaks stage 2 The wire layer originally refused `https://`. It now wraps the socket with `ssl` (`--tls`, implied by an `https://` url) and verifies certificates by default (`--insecure` for self-signed labs). Measured against an `nginx:alpine` TLS terminator in front of the same lab container (`proxy_http_version 1.1`, `proxy_request_buffering off`, `proxy_buffering off`, `Connection close`): | Path | A1 | B1 | |---|---|---| | direct `http://127.0.0.1:18110` | 500 (real OOM) | 200 + 819208-byte decoded cookie → chain completes, `uid=33(www-data)` | | through nginx over `https://` | 500 (real OOM) | Apache logs a 200 with a truncated body, then `zend_mm_heap corrupted` → child `exit signal Abort (6)`; the proxy returns `502` | So TLS itself is fine, and the OOM producer reaches the target over TLS. The failure is the second stage's *response*: the worker aborts during that request's shutdown, and a proxy cannot forward a response whose upstream died mid-body. A direct client reads what was already flushed and carries on. Practical rule: aim the chain at mod_php's own listener, not at a terminator, a CDN, or a load balancer. Both `Connection` modes (`""` and `close`) and buffering off were tried; neither changed the outcome.