[**
`php_request_startup()` parses the multipart body, and with it runs the
`session.upload_progress` callback, **before** `PHP_RINIT(basic)` resets
If a session decode runs out of memory, `zend_bailout()` skips
`PHP_VAR_UNSERIALIZE_DESTROY`. The global is left at `level = 1`, pointing into a
request heap that is to be freed. The request on the same worker
reaches the callback before RINIT and **reuses the freed pointer**.
| **Bug class** | Use-after-free (cross-request, stale global state) |
| **Component** | `main/main.c` startup order · `ext/session` · `ext/standard/var_unserializer` |
| **Reachability** | Any endpoint that accepts `multipart/form-data`. No auth, no `session_start()` needed |
| **Deterministic result** | Pre-auth worker crash (SIGSEGV) |
| **RCE** | Conditional: needs a sink, an ASLR/PIE leak and heap grooming |
| **Fix** | `php_basic_early_rinit()` in PHP 8.5.12 (21 Oct 2026) |
Note over A,G: Request 1 · large session (a:1048576:{...})
A->>W: multipart POST + PHP_SESSION_UPLOAD_PROGRESS
W->>G: php_var_unserialize_init() → level=1, data=ptr
W->>W: array_init_size(1M) exceeds memory_limit
W--xW: zend_bailout() skips PHP_VAR_UNSERIALIZE_DESTROY
Note over W,G: request heap freed, but level=1 and data=ptr (dangling)
Note over A,G: Request 2 · small session (x|i:1;)
A->>W: multipart POST + PHP_SESSION_UPLOAD_PROGRESS
Note over W: php_hash_environment() runs BEFORE RINIT
W--xW: tmp_var() reads (*var_hashx)->last_dtor → SIGSEGV
The ASAN stack shows the whole path running inside `php_request_startup()`,
before a single line of application code:
==PID==ERROR: AddressSanitizer: SEGV on unknown address 0x00000000013a
#0 tmp_var ext/standard/var_unserializer.c:173
#1 var_tmp_var ext/standard/var_unserializer.c:195
#2 ps_srlzr_decode_php ext/session/session.c:1149
#3 php_session_decode ext/session/session.c:320
#4 php_session_initialize ext/session/session.c:540
#5 php_session_rfc1867_cleanup ext/session/session.c:3199
#6 php_session_rfc1867_callback ext/session/session.c:3364
#7 rfc1867_post_handler main/rfc1867.c:1273
#13 php_hash_environment main/php_variables.c:794
#14 php_request_startup main/main.c:1945
Full report: [`poc/asan-trace.txt`](poc/asan-trace.txt).
Requirements: Linux, a C compiler, `make`, `curl`, `xz` and Python 3.8+.
git clone
./build.sh # PHP 8.5.11, normal build
./build.sh asan # optional: PHP 8.5.11 with AddressSanitizer
python3 poc/repro_uaf.py --php build-asan/php-8.5.11/sapi/cli/php --verbose
`build.sh` downloads the official tarball, checks its SHA-256 and builds with
`--disable-all --enable-session --enable-cli`. Everything stays inside the repo
[*] php build/php-8.5.11/sapi/cli/php
[*] server memory_limit=16M
[*] req1 seeded session: 4194317 bytes (1048576 elements)
[*] req1 HTTP/1.0 500 Internal Server Error oom=True alive=True
[+] worker crashed: BG(unserialize) reused the freed php_unserialize_data
The script exits `0` only when the worker dies from a signal. On a patched build
the second request returns `200`, the worker survives and the script exits `1`:
python3 poc/repro_uaf.py --php build-patched/php-8.5.12/sapi/cli/php
> The large session is written to `session.save_path` by the script to
> simulate an existing session of that size. This is a lab shortcut that
> isolates the startup-order bug. The server runs on `127.0.0.1` with a
> throwaway temporary directory, which is removed at the end.
| ≤ 8.1, 7.x, 5.x | — | ⚠️ no official fix (EOL) |
Reproduced on **8.5.11**. Other branches are listed according to the official
PHP 8.5.12 adds `php_basic_early_rinit()`, called from `php_request_startup()`
**before** `sapi_activate()` and `php_hash_environment()`. It resets
`BG(serialize_lock)`, `BG(serialize)` and `BG(unserialize)`, so no early
consumer can find stale state from a request.
The same release adds `incomplete_classes_only` while `PS(in_rfc1867_update)`
is set, so objects found in the session during the upload-progress update
become `__PHP_Incomplete_Class` and no magic methods run.
- Upgrade to a fixed release. This is the only full fix.
- If you don't use upload progress, disable it: `session.upload_progress.enabled = Off`.
- Recycle workers regularly (`pm.max_requests` in FPM) to shorten the window.
This reduces the risk but does not remove it.
├── build.sh # downloads, verifies and builds PHP (normal | asan | patched)
│ └── ANALYSIS.md # full write-up: root cause, exploitability, fix
├── repro_uaf.py # two-request reproducer
└── asan-trace.txt # ASAN report from the reproduction
- [GHSA-6wmf-4rv5-p3rp]( *RCE via stale global state* (CVE-2026-109619)
- [GHSA-w8hw-w9fx-j79w]( *RCE via OOM corruption* (CVE-2026-109618)
- [PHP 8.5.12 changelog]( "Avoid state corruption via bailout"
This is an independent reproduction of a publicly disclosed and patched
vulnerability, done in a local lab on my own builds. It is published for
research, education and defense. The reproducer only crashes a local
`php -S` server that it starts itself. Don't run it against systems you don't
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.
