PoC Archive PoC Archive
CVE-2026-17544 / GHSA-x692-q9x7-8c3f category: web CVSS 9.8 (CRITICAL)
Unverified

PHP bcmath bccomp() Out-of-Bounds Write (CVE-2026-17544)

Published: 2026-08-16 • Researcher: Boreas37

Target software PHP (ext/bcmath)
Affected versions PHP 8.4.x before 8.4.24, PHP 8.5.x before 8.5.9
Status Patched (PHP 8.4.24 / 8.5.9)
Severity Critical · CVSS 9.8
CVSS 9.8/10
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
On this page

Metadata

FieldValue
Date Added2026-08-16
Last Updated2026-08-16
Author / ResearcherBoreas37
CVE / AdvisoryCVE-2026-17544 / GHSA-x692-q9x7-8c3f
Categoryweb
SeverityCritical
CVSS Score9.8 (NVD)
StatusPatched (PHP 8.4.24 / 8.5.9)
Tagsphp, bcmath, oob-write, stack-smashing, rce, cwe-787, CVE-2026-17544
Related

Affected Target

FieldValue
Software / SystemPHP (ext/bcmath)
Versions AffectedPHP 8.4.x before 8.4.24, PHP 8.5.x before 8.5.9
Language / PlatformPHP
Authentication RequiredDepends on application context
Network Access RequiredRemote 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

  1. Trigger: Call bccomp() (or bcadd/bcsub/bcmul/bcdiv) with a number like “1.9” followed by 300 zeros and “1”, with scale=300
  2. Overflow: The trailing-zero trim shortens the allocated buffer but the copy writes the full untrimmed length
  3. Impact: Stack buffer overflow leading to stack canary corruption (SIGABRT) or potential RCE

Source Repository

FieldValue
Original URLhttps://github.com/Boreas37/CVE-2026-17544-PoC
Archive Date2026-08-16
Stars at Archive1