Negative size parameter in mb_split
The mb_split function in PHP mishandled strings ending in an incomplete multibyte character, computing a negative length that was passed to an internal string-creation routine. This could cause a crash and potentially memory corruption or leakage.
- Triaged in 4 months
- Fixed in 21 months
- Paid in 21 months
- Disclosed after 22 months
https://bugs.php.net/bug.php?id=77367
mb_split doesn't correctly detect the length when the $string has an unfinished multibyte character at the end of the string. This causes a crash due to a negative parameter to add_next_index_stringl, which calls zend_string_init and memcpy.
Could reproduce on master.
Impact
This could be used to cause memory corruption/leakage.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the length calculation in mb_split did not account for a trailing incomplete multibyte sequence, producing a negative length that was passed unchecked to add_next_index_stringl.
Impact
This could be used to cause memory corruption or leakage, and the text reports a crash.
What the attacker needed
Call mb_split on a string ending mid-character
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A multibyte character is a single letter that takes more than one byte to store, such as many non-English characters. If a string ends halfway through such a character, the splitting function miscounts the length and ends up with a negative number, which it then uses as if it were a real size. That can crash the program and may let an attacker corrupt or read memory.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.