Use After Free Vulnerability in array_walk()/array_walk_recursive()
A use-after-free can occur in PHP's array_walk() when the callback modifies the array being walked, and the reporter says it can still be triggered remotely in some real-world apps.
- Fixed in 45 hours
- Paid in 45 hours
- Disclosed after 3.2 years
https://bugs.php.net/bug.php?id=70713
I think this bugs is still security issue since this bug can be still triggered remotely in some real world&apps.
array_walk($parts, function ($value, $key) use (&$parts) {
if ($value === '..') {
unset($parts[$key], $parts[$key-1]);
$parts = array_values($parts); <== ['x', 'y', '..'] will be changed into ['x'] from the memory, it is possible to lead to use-after-free.
}
});
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 internal pointer used by array_walk() is not updated when the callback modifies the array, so it later accesses freed memory.
Impact
This could allow remote attackers to trigger a use-after-free in applications that pass user-controlled arrays to these functions.
What the attacker needed
Application uses array_walk with user input; callback modifies the array
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.
When a program walks through an array and the callback changes that same array, it can end up using memory that has already been freed. This is a use-after-free bug. The PHP function array_walk is affected when the callback removes items from the array.
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.