UAF in report_class_fetch_error() when the autoloader frees the class name (PHP 8.6.0)
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
研究方向
Start in zend_execute_API.c with zend_lookup_class_ex(), where the class name string is released around line 1355, and with report_class_fetch_error(), which builds the message around line 1785. zend_fetch_class() around line 1828 reaches the same path. Reproduce with the PoC under AddressSanitizer to confirm the heap-use-after-free at main/spprintf.c:367. Done when the not-found message is built from a string that is still alive and ASan reports no error.
由索引模型根據 Issue 內容生成。
描述
Hi,
PHP 8.6.0 (official Windows NTS x64 build, 18/11/2026) reads a freed class-name string in report_class_fetch_error().
When the autoloader frees the variable that holds the class name, zend_lookup_class_ex() drops the last reference at zend_execute_API.c:1355, and report_class_fetch_error() then builds the "Class ... not found" message from the freed string (main/spprintf.c:367).
PoC:
<?php
spl_autoload_register(function ($cls) {
$GLOBALS['cls'] = null;
});
function test() {
global $cls;
$cls::method();
}
$cls = implode("", ["Undefined", "Class"]);
try { test(); } catch (Throwable $e) { echo $e->getMessage(), "\n"; }
On the official 8.6.0 build the message contains freed memory, e.g. Class "UndefineD\x1aB..." not found. With a class name of about 1.45 MB or more, the process crashes with 0xC0000005 (DoS) because the large block is unmapped before the read.
ASAN: heap-use-after-free, READ of size 8 at main/spprintf.c:367; the free is in zend_string_release_ex called from zend_lookup_class_ex:1355; the read is reached from report_class_fetch_error (zend_execute_API.c:1785) and zend_fetch_class:1828.
I could not find an existing report for this call site. PRs #22688 and #22881 cover the dynamic-call paths, not report_class_fetch_error.
I know SECURITY.md treats this family as bugs, not security issues, so this is a bug report.
Suggested fix: keep a reference to class_name until after report_class_fetch_error() has built the message, or copy the name before releasing it.
- 主要語言
- C
- 星號
- 41.8k
- 分支
- 8.6k
- 平均合併
- 2 天 15 小時
- 30 天內合併 PR
- 125
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
php/php-src 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
ext/openssl: 8.2.31+/8.3.31+ fail to build against OpenSSL 1.0.2 (ASN1_STRING_get0_data in xp_ssl.c)未關閉Extension: openssl Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 79/100
維護者通常 1 天內回覆
-
Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 1 天內回覆
-
SNMP accepts malformed remote ports可能已有人在做 @somethingwithproof 於 21 天前認領。 未關閉
難度 2/5 半天 新手友好度 62/100
維護者通常 1 天內回覆
-
Bug Status: Needs Triage
難度 2/5 1-3 小時 新手友好度 64/100
維護者通常 1 天內回覆
相似的 Issue
-
bug
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
ZIP/ZIPS decode dereferences NULL when the cached libdeflate decompressor can't be allocated (3.5 regression)可能已有人在做 關聯的 PR 仍在進行中或已合併。 未關閉
難度 2/5 1-3 小時 新手友好度 74/100
AcademySoftwareFoundation/openexr#2884 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
python-pillow/Pillow#10590 ·
維護者通常 1 天內回覆
-
status: needs-triage type: bug
難度 2/5 1-3 小時 新手友好度 62/100
-
bug
難度 2/5 1-3 小時 新手友好度 62/100
openwrt/packages#31407 · 1 則留言 ·
維護者通常 1 天內回覆