wddx_deserialize null dereference with invalid xml
The wddx_deserialize function in PHP 5.6 did not check whether a stack entry was null before dereferencing it, so invalid XML input could cause a null pointer dereference and crash the PHP interpreter. An attacker could trigger a denial of service by supplying malformed WDDX data.
- Disclosed after 3.2 years
Upstream Bug
2016-08-09 02:53 UTC https://bugs.php.net/bug.php?id=72790
Summary
wddx_deserialize allows to unserializes a WDDX packet that usually comes from external input, php interpreter crashes while processing invalid XML input with wddx_deserialize
https://github.com/php/php-src/blob/PHP-5.6/ext/wddx/wddx.c#L1170
wddx_stack_top(&stack, (void**)&ent);
*return_value = *(ent->data);
ent value is null but is not checked and then used to assign the return value. This doesn't happen with PHP-7.0, but the code here changed a little, I guess some of these macro check the value and prevent it from happening:
https://github.com/php/php-src/blob/PHP-7.0.9/ext/wddx/wddx.c#L1075
wddx_stack_top(&stack, (void**)&ent);
ZVAL_COPY(return_value, &ent->data);
Patch
http://git.php.net/?p=php-src.git;a=commit;h=1f6078e4a5c67733bfdbd20bb2706501ac56a344
Fixed for PHP 5.6.25,
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 a missing null check on the result of wddx_stack_top before dereferencing the pointer to copy the return value.
Impact
An attacker could cause a denial of service by crashing the PHP interpreter with invalid XML input; the text does not claim remote code execution or data exposure.
What the attacker needed
Ability to supply WDDX input to wddx_deserialize
The fix
The bug was fixed for PHP 5.6.25, per the changelog.
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.
WDDX is an old format for exchanging data between applications, similar to XML. The PHP function that reads WDDX data assumed the data was always well-formed and did not check for a missing piece, so a malformed input made the program crash. This is a denial-of-service bug: the attacker cannot run code, but they can stop the service from working.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.