CVE-2026-109619 (PHP2Shell): Pre-Auth Remote Code Execution (RCE) via PHP-FPM Stale Global State Deserialization UAF. Reproducible Docker lab, interactive shell, reverse shell & WAF/IDS rules.
A comprehensive research lab and exploit reproduction toolkit for CVE-2026-109619 (also known as PHP2Shell), a critical vulnerability in PHP's deserialization subsystem affecting persistent worker architectures (such as PHP-FPM), enabling pre-auth cross-request use-after-free and arbitrary remote code execution under the privileges of the web process.
ext/standard/var_unserializer.re)8.2.0–8.2.34, 8.3.0–8.3.35, 8.4.0–8.4.26, 8.5.0–8.5.11Unchecked Bailout in Deserialization:
During deserialization, php_var_unserialize_init() initializes reference tracking structures and destruction chains in BG(unserialize).data, incrementing BG(unserialize).level = 1. If an in-script fatal error or memory exhaustion occurs (e.g. inside __wakeup() or class constructor), PHP executes zend_bailout(). Ordinary request cleanup routines (php_var_unserialize_destroy()) are skipped, leaving dirty global pointers and unzeroed reference counters in the worker's memory space.
Persistent Worker Survival (PHP-FPM):
In persistent multi-request architectures like PHP-FPM (pm = static or dynamic), child worker processes survive in-script fatal errors across HTTP requests without terminating. When a subsequent HTTP request arrives at the same worker process, it inherits the dirty BG(unserialize) parser state from the preceding aborted request.
Cross-Request Reference Poisoning & Memory Corruption:
When the surviving worker enters unserialize() again, it detects BG(unserialize).level > 0 and mistakes the new payload for a nested call within an already-active deserialization session.
R:1), the deserializer resolves pointers into previously freed memory.first_dtor structure in Zend MM through controlled POST allocations, the attacker constructs a fake HashTable whose pDestructor points directly to zif_system.www-data privileges.├── lab/
│ ├── nginx-fpm/ # Vulnerable Nginx 1.27 + PHP-FPM 8.4.26 environment
│ │ ├── nginx.conf # FastCGI reverse proxy configuration
│ │ ├── php.ini # PHP runtime configuration (memory_limit = 8M)
│ │ ├── fpm-pool.conf # PHP-FPM static pool configuration (1 worker)
│ │ ├── lab.sh # Container management script (up, down, status, logs)
│ │ ├── test_behavior.py # Diagnostic script verifying worker survival
│ │ └── webroot/ # Target web application endpoints
│ │ ├── cve_109619_poc.php # Two-stage exploitation endpoint
│ │ ├── cve_109619_demo.php # Diagnostic demonstration
│ │ └── index.php # Worker status and PID baseline
│ ├── docker-compose.yml # Multi-container lab orchestration
│ ├── run_lab.sh # Lab startup script
│ └── stop_lab.sh # Lab teardown script
├── poc/
│ ├── poc.py # Full-featured network PoC (arbitrary RCE, interactive shell, reverse shell)
│ ├── universal.py # Universal pre-RINIT exploit engine targeting session.upload_progress
│ ├── discover.py # Dynamic endpoint crawler and parameter discovery engine
│ ├── scan.py # Non-destructive passive vulnerability assessment scanner
│ ├── poc_raw.py # Low-level Zend MM memory corruption exploit (zif_system)
│ ├── revshell.py # Standalone reverse TCP shell handler
│ ├── profiles.json # Affected version catalog and fix matrix
│ └── ui.py # Terminal output and status helpers
├── rules/
│ ├── suricata.rules # Suricata / Snort network IDS detection signatures
│ ├── modsecurity.conf # ModSecurity / OWASP CRS perimeter WAF rules
│ └── semgrep.yml # Semgrep SAST rule for unsafe unserialize calls
├── assets/
│ ├── showcase.gif # Terminal demonstration GIF
│ └── showcase.webm # High-definition screencast
├── docs/
│ ├── analysis.md # In-depth technical root cause analysis
│ └── licensing.md # License details
├── test_all.sh # Automated verification suite for all lab services
├── php2shell.py # Root CLI entrypoint
├── Makefile # Automation recipes
└── README.md # Research report and documentation
Docker is required to run the local lab environment.
# Start lab containers (Nginx 1.27 + PHP-FPM 8.4.26)
./lab/run_lab.sh
# or: make lab-up
Once running, the following endpoints are exposed:
http://127.0.0.1:8180/index.php (SAPI & PID verification)http://127.0.0.1:8180/cve_109619_poc.phphttp://127.0.0.1:8180/cve_109619_demo.phpTo shut down the lab:
./lab/stop_lab.sh
# or: make lab-down
To reset the lab with clean logs and fresh worker memory:
make lab-restart
scan.py)Performs fingerprinting of PHP version, FastCGI SAPI, worker survival during in-script memory exhaustion, and cross-request state reuse without executing arbitrary commands.
python3 poc/scan.py -u http://127.0.0.1:8180/
# or: ./php2shell.py -u http://127.0.0.1:8180/ --check
Example Output:
target: http://127.0.0.1:8180
version: php 8.4.26 (vulnerable, php 8.4.26 < 8.4.27)
worker: pid 7
survival: ok (pid 7)
stale state: clean
verdict: vulnerable to cve-2026-109619
poc.py / php2shell.py)Exploits the stale deserializer state across requests. Stage 1 triggers memory exhaustion inside __wakeup(), leaving BG(unserialize) dirty (level > 0) while the persistent PHP-FPM worker survives. Stage 2 supplies cross-request reference R:1 to resolve stale pointers in Zend MM.
[!NOTE] The exploit operates entirely at the PHP interpreter and Zend Engine layer without requiring application-level gadgets. For low-level memory corruption targeting native engine function pointers (
zif_system), seepoc/poc_raw.pyand the pre-RINIT exploit engine inpoc/universal.py.
The PoC accepts arbitrary targets (-u) and commands (-c):