UAF in zend_reference write path leads to write-what-where (PHP 8.6.0)
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 36/100
Hướng nghiên cứu
The write path is in zend_execute.c around line 2199, in zend_assign_to_string_offset; read that function first and trace where GC_ADDREF is taken on the string but not on the zend_reference. Reproduce with the PoC from the issue on an ASAN build to see the heap-use-after-free reported by zend_reference_destroy. Done means the reference survives the error handler and the container type is revalidated before the write, with the PoC no longer crashing.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi,
PHP 8.6.0 (official Windows NTS x64 build, 18/11/2026) has a use-after-free in the string offset write path when the container is a reference.
zend_assign_to_string_offset() keeps the string alive with GC_ADDREF, but it does not keep the zend_reference alive. If the error handler keeps the string with (string)$s and unsets both variables, the reference is freed and the engine writes through the stale pointer (zend_execute.c:2199): and dword [V+4], ..., mov qword [V+8], 0, mov byte [V+24+offset], c, where V is a controlled integer.
PoC:
<?php
$a = str_repeat("A", 24);
$s = &$a;
set_error_handler(function ($no, $msg) {
$GLOBALS['k'] = (string)$GLOBALS['s'];
unset($GLOBALS['s']);
unset($GLOBALS['a']);
$GLOBALS['x'] = 0x4141414141414141;
$GLOBALS['y'] = &$GLOBALS['x'];
return true;
});
$s["1x"] = "Z";
On the official 8.6.0 build: exit 0xC0000005 (2/2), with RAX=0x4141414141414141 and RBP=0x5A ('Z').
ASAN: heap-use-after-free, READ of size 8, zend_execute.c:2199 in zend_assign_to_string_offset, freed by zend_reference_destroy.
This is a different bug from GH-25329 (febae1cbfd only touches the read path).
I know SECURITY.md treats malicious error handlers as bugs, not security issues, so this is a bug report, not a CVE request.
Suggested fix: keep the zend_reference alive across the callback and revalidate the container type before writing.
- Ngôn ngữ chính
- C
- Star
- 41.8k
- Fork
- 8.6k
- Merge trung bình
- 2 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 125
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của php/php-src
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ext/openssl: 8.2.31+/8.3.31+ fail to build against OpenSSL 1.0.2 (ASN1_STRING_get0_data in xp_ssl.c)Đang mởExtension: openssl Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
php/php-src#25402 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
php/php-src#25397 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
SNMP accepts malformed remote portsCó thể đã có người làm @somethingwithproof đã nhận 21 ngày trước. Đang mở
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 62/100
php/php-src#25137 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
ZIP/ZIPS decode dereferences NULL when the cached libdeflate decompressor can't be allocated (3.5 regression)Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
AcademySoftwareFoundation/openexr#2884 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
python-pillow/Pillow#10590 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
status: needs-triage type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
openwrt/packages#31407 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày