Buffer Over flow when parsing tar/zip/phar in phar_set_inode
The phar_set_inode function in PHP contained multiple stack-based buffer overflows when parsing tar, phar, or ZIP archives. A remote attacker could supply a crafted length value in an archive to execute arbitrary code.
- Fixed in 3 months
- Paid in 3 months
- Disclosed after under an hour
https://bugs.php.net/bug.php?id=69441
Multiple stack-based buffer overflows in the phar_set_inode function in phar_internal.h in PHP before 5.4.40, 5.5.x before 5.5.24, and 5.6.x before 5.6.8 allow remote attackers to execute arbitrary code via a crafted length value in a (1) tar, (2) phar, or (3) ZIP archive.
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 phar_set_inode function did not validate a length value taken from the archive before copying data into a fixed-size stack buffer.
Impact
A remote attacker could execute arbitrary code on the server by getting a crafted tar, phar, or ZIP archive processed.
What the attacker needed
Crafted tar, phar, or ZIP archive; victim processes the archive with PHP
The fix
The issue affected PHP before 5.4.40, 5.5.x before 5.5.24, and 5.6.x before 5.6.8.
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 buffer overflow happens when a program writes more data into a fixed-size memory area than it can hold, so nearby memory gets overwritten. Here, PHP's code for reading archive files trusted a length value from the file without checking it, so a malicious archive could overwrite memory and let an attacker run their own code.
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.