Variant analysis: 1 unfixed sibling safety gap in php-src
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ó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Bắt đầu trong ext/mbstring/libmbfl/mbfilter.c tại mbfl_name2encoding_ex(), đặc biệt là lệnh gọi strncasecmp dùng để tra cứu hash gần dòng 335. So sánh nó với hai vị trí lệnh gọi cùng cấp có bảo vệ và chạy harness php_php-fuzz-parser hoặc các thao tác mbstring liên quan để điều tra đường dẫn đã được báo cáo. Được xem là hoàn tất khi vị trí gọi cùng cấp bị bỏ sót được xử lý nhất quán và hành vi đọc ngoài phạm vi đã được báo cáo được xác minh hoặc bác bỏ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
Variant analysis of historical fixes in php-src identified 1 code site where an integer-overflow guard, bounds check, or safe-allocation wrapper exists at one location but is missing at a structurally identical sibling location (same file, same function, or same pattern family) elsewhere in the codebase.
Each finding below is code-confirmed against the current HEAD (verified by cloning the repository fresh and checking the pattern is still present), with the exact file/line locations, the root cause, a description of the trigger path, and — where available — ASan/execution verification output or a proof-of-concept.
Note on origin: these were surfaced by an automated variant-analysis pipeline that diffs historical fix commits against sibling code paths, then has each candidate manually reviewed. I'm posting them together per-project rather than as separate issues to respect maintainer time. Happy to split, close, or reprioritize any of these as you see fit.
Finding 1: PHP — mbfl_name2encoding_ex() hash-path OOB read (sibling of strncasecmp strlen fix)
Verified against HEAD: e64029962d0e3378a41e6948557992c7ddae503d (2026-09-25)
*- Project: PHP (php/php-src)
- Class: Heap-buffer-overflow read (strncasecmp past buffer end via hash-path bypass of strlen guard)
- Status: Code-confirmed, exec-blocked
- Sibling of: CVE-2026-6104 fix — added strlen guards to 2 of 3
strncasecmpcall sites in same function*
Discovery method
Variant analysis. The CVE-2026-6104 fix added strlen() guards before strncasecmp() calls in mbfl_name2encoding_ex() to prevent reading past the input string. Two of the three call sites were fixed — the third, in the hash-lookup fast path, was missed.
Vulnerable code
ext/mbstring/libmbfl/mbfl/mbfilter.c, line ~335 — mbfl_name2encoding_ex():
// VULNERABLE — hash-lookup fast path:
const mbfl_encoding *mbfl_name2encoding_ex(const char *name, size_t name_len) {
// ... hash computation on name ...
// FIXED paths (2 call sites): guard with strlen(name) before strncasecmp
// MISSED path (1 call site, line ~335):
if (!strncasecmp(name, enc->name, name_len)) { // OOB read!
// enc->name could be shorter than name_len
// strncasecmp reads min(strlen(name), name_len, strlen(enc->name)) bytes
// if enc->name is "\0" (1 byte) and name_len = 23, reads 1 byte past enc->name
}
}
FIXED siblings (same function, other call sites):
// SAFE — explicit strlen guard:
if (strlen(enc_name) == name_len && !strncasecmp(name, enc_name, name_len)) {
// strlen guard prevents OOB
}
Root cause
strncasecmp(s1, s2, n) reads up to n bytes from BOTH s1 and s2. It stops early if either string is shorter — but only AFTER comparing the shorter string's bytes. If s2 (encoding name from the table) is shorter than name_len, strncasecmp reads strlen(s2) bytes and stops. This is safe. But the hash path resolves to a name WITHOUT checking that enc->name length >= name_len. If the hash collision produces an encoding entry whose name is longer or equal, it's safe. If shorter, OOB read of whatever bytes follow enc->name in the data section.
The existing fixes added strlen(enc_name) == name_len before the strncasecmp call — a mechanical guard that the hash path lacks.
Trigger path
- Crafted
mb_convert_encoding()ormb_detect_encoding()call with a specifically chosen encoding name - → name hashes to an encoding table entry with a shorter name
- →
strncasecmpreads pastenc->nameinto adjacent static data → OOB read
Fuzz harness: php_php-fuzz-parser (an OSS-Fuzz/fuzzbench harness) — exercises PHP parsing including mbstring operations.
Sibling-gap quality
Excellent. Same function, same strncasecmp pattern, same strlen guard. Two call sites fixed, one missed. The fix is a one-line copy.
Analysis date: 2026-09-22. Code-confirmed, not execution-verified.
Methodology
For each historical vulnerability fix in the codebase, we identified the safe pattern the fix introduced (an overflow guard, a safe allocator wrapper, a bounds check) and searched the rest of the codebase for structurally identical code that predates or postdates the fix but never received it. Each candidate was then manually verified against the current HEAD listed above.
Happy to provide anything else that would help triage — additional PoC inputs, a minimal patch following the existing safe-sibling pattern, or a written reproduction script.
- Ngôn ngữ chính
- C
- Star
- 40.4k
- Fork
- 8.2k
- Merge trung bình
- 3 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 150
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
-
Bug Status: Needs Triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
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 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Flaky hrtime.phpt testĐang mởBug Category: Tests Status: Verified
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug SAPI: fpm Status: Needs Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
php/php-src#21740 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Feature OS: Windows 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#21209 · 2 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
DaveGamble/cJSON#1094 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
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 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Status: Opened
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Issue-Bug Needs-Triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày