PHP bcmath bccomp() Out-of-Bounds Write (CVE-2026-17544)
Published: 2026-08-16 • Researcher: Boreas37
- Severity
- Critical
- CVE
- CVE-2026-17544 / GHSA-x692-q9x7-8c3f
- Category
- web
- Affected product
- PHP (ext/bcmath)
- Affected versions
- PHP 8.4.x before 8.4.24, PHP 8.5.x before 8.5.9
- Disclosed
- 2026-08-16
- Patch status
- Unverified
Archive entry
intelseclab/poc-archiveOn this page
Metadata
| Field | Value |
|---|---|
| Date Added | 2026-08-16 |
| Last Updated | 2026-08-16 |
| Author / Researcher | Boreas37 |
| CVE / Advisory | CVE-2026-17544 / GHSA-x692-q9x7-8c3f |
| Category | web |
| Severity | Critical |
| CVSS Score | 9.8 (NVD) |
| Status | Patched (PHP 8.4.24 / 8.5.9) |
| Tags | php, bcmath, oob-write, stack-smashing, rce, cwe-787, CVE-2026-17544 |
| Related |
Affected Target
| Field | Value |
|---|---|
| Software / System | PHP (ext/bcmath) |
| Versions Affected | PHP 8.4.x before 8.4.24, PHP 8.5.x before 8.5.9 |
| Language / Platform | PHP |
| Authentication Required | Depends on application context |
| Network Access Required | Remote if bcmath functions are reachable via web input |
Summary
CVE-2026-17544 is an out-of-bounds write vulnerability in the PHP bcmath extension, specifically in the bc_str2num() function in ext/bcmath/libbcmath/src/str2num.c. When the manual scale is smaller than the auto scale, the fraction is truncated and a trailing-zero trim runs, but the fractional_end pointer is not updated. The subsequent bc_new_num_nonzeroed() allocates a buffer sized for the trimmed number, but bc_copy_and_toggle_bcd() copies the untrimmed length, causing a stack buffer overflow.
The trigger PoC calls bccomp() with a crafted number containing trailing zeros that cause the length mismatch. On vulnerable builds, this results in a stack smashing detection (SIGABRT). In a weaponized scenario, this could lead to arbitrary code execution.
Vulnerability Details
Root Cause
In bc_str2num(), after truncating the fraction to match the manual scale and trimming trailing zeros, str_scale is decremented but fractional_end is not updated. The allocation uses the shorter str_scale but the copy uses the original (longer) fractional range, writing past the allocated buffer.
Attack Flow
- Trigger: Call bccomp() (or bcadd/bcsub/bcmul/bcdiv) with a number like “1.9” followed by 300 zeros and “1”, with scale=300
- Overflow: The trailing-zero trim shortens the allocated buffer but the copy writes the full untrimmed length
- Impact: Stack buffer overflow leading to stack canary corruption (SIGABRT) or potential RCE
Source Repository
| Field | Value |
|---|---|
| Original URL | https://github.com/Boreas37/CVE-2026-17544-PoC |
| Archive Date | 2026-08-16 |
| Stars at Archive | 1 |