PHP `getimagesize()` JPEG APPn Parsing Flaw Leaks Heap Memory
Vulnerability Disclosure · 2 sources · Updated 5mo ago · First seen May 25, 2026

PHP disclosed an information disclosure vulnerability in getimagesize(..., $info) affecting JPEG APPn metadata parsing in php-src/ext/standard/image.c. The flaw occurs during multi-chunk reads: php_read_stream_all_chunks() can overwrite the start of the destination buffer without advancing the write pointer, leaving the tail populated with uninitialized or previously freed heap memory. When getimagesize() returns metadata such as $info['APP1'], the application may receive corrupted data containing leaked process memory.
A public proof of concept showed the bug with a crafted JPEG containing a large APP1 segment read through php://filter, using repeated filters to force chunked reads and a heap spray marker to demonstrate memory reuse inside the returned APP1 buffer. The issue was reproduced on a PHP 8.6.0-dev build with AddressSanitizer and debug flags, and the advisory said initial doubts about security impact were revised after maintainers concluded exploitation may also be possible with normal image files if an attacker can predict stream chunk sizes.


