CVE-2015-3307: Buffer Overflow
A vulnerability in PHP was reported whereby the Heap header gets misaligned resulting in the corruption of the heap chunk's metadata.
A heap chunk is allocated in ext/phar/tar.c:167
metadata = (char ) safeemalloc(1, entry->uncompressedfilesize, 1);
A reference to this heap chunk is passed into pharparsemetadata() at ext/phar/tar.c:176
if (pharparsemetadata(&metadata, &entry->metadata, entry->uncompressedfilesize TSRMLSCC) == FAILURE) {
The following gets called within pharparsemetadata:611 when zipmetadatalen==0
PHARGET32(buffer, buflen);
This moves the pointer referencing the heap chunk by 4 bytes.
When the heap chunk gets freeed at at tar.c:177:
efree(metadata);
The heap chunk is now misaligned by 4 bytes. In other words: ZENDMMHEADEROF(metadata).info.size is now ZENDMMHEADEROF(metadata).info.prev and ZENDMMHEADEROF(metadata).info.prev is tainted with the body's data.
Upstream bug: https://bugs.php.net/bug.php?id=69443
Upstream patch: http://git.php.net/?p=php-src.git;a=commitdiff;h=17cbd0b5b78a7500f185b3781a2149881bfff8ae
This patch was for CVE-2015-2783 (bug 1213446), but it inadvertently resolved this vulnerability as well. The vulnerable line that was removed was on ext/phar/phar.c:611
PHARGET32(buffer, buflen);
Other sources
The pharparsemetadata function in ext/phar/phar.c in PHP before 5.4.40, 5.5.x before 5.5.24, and 5.6.x before 5.6.8 allows remote attackers to cause a denial of service (heap metadata corruption) or possibly have unspecified other impact via a crafted tar archive.
— MITRE
Affected Software
Remediation
Patch Available
Patch Available
Event History
Frequently Asked Questions
What is the severity of CVE-2015-3307?
CVE-2015-3307 has a moderate severity rating, which indicates a potential impact on the affected systems.
How do I fix CVE-2015-3307?
To fix CVE-2015-3307, update PHP to a version higher than 5.4.40 or 5.5.24 or 5.6.8 depending on your installed version.
What versions of PHP are affected by CVE-2015-3307?
CVE-2015-3307 affects PHP versions earlier than 5.4.40, 5.5.24, and 5.6.8.
How does CVE-2015-3307 affect PHP applications?
CVE-2015-3307 can lead to heap corruption, which may result in unexpected behavior or crashes in PHP applications.
Is there a workaround for CVE-2015-3307?
There is no official workaround for CVE-2015-3307; the best mitigation is to update to a fixed version.