GHSA-3237-qqm7-mfv7 / CVE-2025-14177: Information Leak of Memory in getimagesize
- Published:
- Fetched:
- Updated:
- Affects:
- php php-src
https://github.com/php/php-src/security/advisories/GHSA-3237-qqm7-mfv7 ↗
Information Leak of Memory in getimagesize # Information Leak of Memory Product: PHP EXT/STANDARD Version: 8.6.0 CWE-ID: • [CWE-524: Use of Cache Containing Sensitive Information](https://cwe.mitre.org/data/definitions/524.html) • [CAPEC-204: Lifting Sensitive Data Embedded in Cache](https://capec.mitre.org/data/definitions/204.html) CVSS vector v.4.0: 6.3 (AV:N/AC:L/AT:P/PR:N/UI:N/VC:L/VI:N/VA:N/SC:N/SI:N/SA:N) Description: The application insufficiently controls access to information processed by the application data caching tool. As a result, an attacker can gain access to cached data. Mitigation: Restrict access to information processed by the application data caching tool. Additionally, avoid caching information when unnecessary and, where possible, ensure cache encryption. **Researcher: Nikita Sveshnikov (Positive Technologies)** ## Research Researcher discovered zero-day vulnerability «Information Leak of Memory» in PHP EXT/STANDARD. This report includes a minimal proof‑of‑concept that demonstrates a bug in php-src/ext/standard/image.c where APPn data read for getimagesize(..., $info) may be corrupted and contain uninitialized heap bytes. poc.php is a minimal Proof of Concept (Listing 1). Writes a small JPEG (min.jpg), reads it through php://filter to force multi‑chunk reads and prints a human‑readable verdict with an inline leak marker snippet when found. ### Vulnerability reproduction The steps below outline the vulnerability reproduction. • Use the last PHP cli: ./php8.5.1 poc.php • Output shows: - Expected/actual APP1 length - Expected vs returned APP1 head (hex) - Result: VULNERABLE … or Result: OK … - If vulnerable: Leak marker found: offset=… and a short ASCII/HEX snippet with the marker highlighted in []. Note, the issue triggers under multi‑chunk reads. Reading directly from file or from a string often returns in one read and may not reproduce. The PoC uses php://filter/... specifically to ensure chunked reading. ### Vulnerability analysis php_read_stream_all_chunks() writes every chunk into the start of the buffer without advancing the destination pointer. The function then reports success as if the full buffer were filled, so the tail may contain uninitialized memory and the head is overwritten by the last chunk. That buffer is stored into $info['APPn']. Listing 1. PoC Source Code ``` <?php // Minimal PoC: corruption/uninitialized memory leak when reading APP1 via php://filter $file = __DIR__ . '/min.jpg'; // Make APP1 large enough so it is read in multiple chunks $chunk = 8192; $tail = 123; $payload = str_repeat('A', $chunk) . str_repeat('B', $chunk) . str_repeat('Z', $tail); $app1Len = 2 + strlen($payload); // Minimal JPEG: SOI + APP1 + SOF0(1x1) + EOI $sof = "\xFF\xC0" . pack('n', 11) . "\x08" . pack('n',1) . pack('n',1) . "\x01\x11\x00"; $jpeg = "\xFF\xD8" . "\xFF\xE1" . pack('n', $app1Len) . $payload . $sof . "\xFF\xD9"; file_put_contents($file, $jpeg); // Mini heap-spray: fill heap w Patched: 8.1.34, 8.2.30, 8.3.29, 8.4.16, 8.5.1