Executive brief
A vulnerability exists in PHP's BCMath extension, which is used for high-precision mathematical calculations. An attacker can provide specially crafted inputs to certain math functions to crash the application or potentially execute unauthorized code. This could lead to a total compromise of the server's data and availability.
Technical details
An out-of-bounds write vulnerability exists in the bc_str2num() function within PHP's BCMath extension (ext-bcmath). The flaw occurs when a user-provided scale truncates a number and trailing zeros are subsequently trimmed; the code fails to update the 'fractional_end' pointer after adjusting 'str_scale'. When bc_copy_and_toggle_bcd() is later called, it copies the original untruncated string into a buffer sized for the truncated version. Depending on the size of the input, this results in either stack-based or heap-based memory corruption. The issue is fixed in PHP versions 8.4.24 and 8.5.9.
Affected products
- PHP Group PHP 8.4.* before 8.4.24, 8.5.* before 8.5.9
Timeline
- 2026-07-30: advisory
- 2026-07-30: disclosed