chore: repo skeleton + grounded NOTES

This commit is contained in:
ZSecurity
2026-10-24 14:07:06 +07:00
commit 0f942cdb1f
7 changed files with 241 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
out/
__pycache__/
*.pyc
research/upstream/
research/captures/*.resp
research/captures/*.bin
research/libphp.so
+175
View File
@@ -0,0 +1,175 @@
# 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 (`[email protected]`), 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
| field | value |
|---|---|
| image | php:8.4.26-apache |
| amd64 manifest digest | sha256:b0ae0e0d4a3b7f0e800017482752b94f58ab049f2d7fcd108e5452afce3f50d1 (pre-pull, Docker Hub tag query) |
| image id | |
| libphp.so path | /usr/lib/apache2/modules/libphp.so |
| libphp.so sha256 | |
| php version / build date | |
| apache version | |
| profile selected | |
| zval_ptr_dtor offset | |
| zif_system offset | |
| main_bucket_count | |
| delta range | |
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
View File
@@ -0,0 +1,10 @@
KeepAlive Off
<IfModule mpm_prefork_module>
StartServers 1
MinSpareServers 1
MaxSpareServers 1
MaxRequestWorkers 1
ServerLimit 1
MaxConnectionsPerChild 0
</IfModule>
+4
View File
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
set -eu
docker rm -f "${NAME:-p2s-lab}" >/dev/null 2>&1 || true
echo "down"
+1
View File
@@ -0,0 +1 @@
<?php echo "OK\n";
+9
View File
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -eu
NAME=${NAME:-p2s-lab}
docker exec "$NAME" php -v | head -1
docker exec "$NAME" php -i 2>/dev/null | grep -E '^(display_errors|memory_limit|post_max_size|output_buffering|max_file_uploads|max_input_vars|session.upload_progress.enabled|session.save_handler|session.serialize_handler)'
docker exec "$NAME" sha256sum /usr/lib/apache2/modules/libphp.so
docker exec "$NAME" apache2 -v | head -1
docker exec "$NAME" sh -c "grep -v '^#' /etc/apache2/conf-enabled/zz-p2s.conf | grep -v '^$'"
docker exec "$NAME" sh -c 'pgrep -c apache2'
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -eu
HERE=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -W)
ROOT=$(cd "$HERE/.." && pwd -W)
IMAGE=${IMAGE:-php:8.4.26-apache}
NAME=${NAME:-p2s-lab}
PORT=${PORT:-18110}
NET=${NET:-}
docker rm -f "$NAME" >/dev/null 2>&1 || true
mkdir -p "$ROOT/out"
NETARG=""
if [ -n "$NET" ]; then
docker network create "$NET" >/dev/null 2>&1 || true
NETARG="--network $NET"
fi
# shellcheck disable=SC2086
docker run -d --name "$NAME" $NETARG \
-p "127.0.0.1:$PORT:80" \
-v "$HERE/index.php:/var/www/html/index.php:ro" \
-v "$HERE/apache-single-worker.conf:/etc/apache2/conf-enabled/zz-p2s.conf:ro" \
-v "$ROOT/out:/out" \
"$IMAGE" /bin/sh -c 'cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
chown -R www-data:www-data /out 2>/dev/null || true
exec apache2-foreground' >/dev/null
for _ in $(seq 1 60); do
if curl -s -m 2 "http://127.0.0.1:$PORT/index.php" >/dev/null 2>&1; then
break
fi
sleep 0.5
done
echo "target: $(curl -s -m 3 "http://127.0.0.1:$PORT/index.php")"