Логотип exploitDog
Консоль
Логотип exploitDog

exploitDog

github логотип

GHSA-x692-q9x7-8c3f

Опубликовано: 30 июл. 2026
Источник: github
Github: Не прошло ревью

Описание

Out-of-bounds write in bccomp() via crafted operand and scale

A call to bccomp() with attacker-supplied inputs can lead to an out-of-bounds write to either stack or heap memory. The bug occurs in bc_str2num() when the scale truncates a number whose trailing zeros are subsequently trimmed.

https://github.com/php/php-src/blob/a480965c90b4f4948f211c8b139788371e031838/ext/bcmath/libbcmath/src/str2num.c#L169-L185

str_scale later determines the number of digits after the decimal point in the resulting string.

https://github.com/php/php-src/blob/a480965c90b4f4948f211c8b139788371e031838/ext/bcmath/libbcmath/src/str2num.c#L203

The string is later populated using bc_copy_and_toggle_bcd(nptr, fractional_ptr, fractional_end).

https://github.com/php/php-src/blob/a480965c90b4f4948f211c8b139788371e031838/ext/bcmath/libbcmath/src/str2num.c#L213

Note that we have shortened the allocated string (str_scale -= fractional_end - fractional_new_end;) but have not adjusted fractional_end itself. Consequently, bc_copy_and_toggle_bcd(nptr, fractional_ptr, fractional_end) will copy the original, untruncated string into a buffer that is too small, leading to an out-of-bounds write.

BCMath uses a small stack-allocated arena for numbers before falling back to heap allocation, enabling both stack and heap corruption, depending on where the buffer is allocated.

The patch adds fractional_end = fractional_new_end; after the zero truncation.

Пакеты

Наименование

php

php
Затронутые версииВерсия исправления

>=8.4.0, <8.4.24

8.4.24

Наименование

php

php
Затронутые версииВерсия исправления

>=8.5.0, <8.5.9

8.5.9

EPSS

Процентиль: 42%
0.00522
Низкий

Дефекты

CWE-121
CWE-787

Связанные уязвимости

CVSS3: 9.8
ubuntu
18 дней назад

Attacker-provided inputs to bccomp() could lead to an out-of-bounds write with stack and heap corruption in PHP versions from 8.4.* before 8.4.24 and from 8.5.* before 8.5.9.

CVSS3: 8.1
redhat
18 дней назад

Attacker-provided inputs to bccomp() could lead to an out-of-bounds write with stack and heap corruption in PHP versions from 8.4.* before 8.4.24 and from 8.5.* before 8.5.9.

CVSS3: 9.8
nvd
18 дней назад

Attacker-provided inputs to bccomp() could lead to an out-of-bounds write with stack and heap corruption in PHP versions from 8.4.* before 8.4.24 and from 8.5.* before 8.5.9.

CVSS3: 9.8
debian
18 дней назад

Attacker-provided inputs to bccomp() could lead to an out-of-bounds wr ...

suse-cvrf
13 дней назад

Security update for php8

EPSS

Процентиль: 42%
0.00522
Низкий

Дефекты

CWE-121
CWE-787