Pillow EXIF Parser Vulnerability Causes CPU Exhaustion in PNG Processing
A quadratic time bug in Pillow’s EXIF parser allows attackers to freeze applications by inserting repeated markers into PNG image files.
Key points
- CVE-2026-96643 affects Pillow versions 11.0.0 through 12.9.9
- The flaw enables CPU exhaustion via specially crafted PNG eXIf chunks
- Patch version 13.0.0 resolves the issue
Pillow version 13.0.0 resolves CVE-2026-96643, a high severity resource consumption flaw in the Python Imaging Library. The vulnerability allows attackers to exhaust CPU resources by embedding repeated markers in PNG image metadata. Applications using vulnerable versions of Pillow to process untrusted images face potential denial of service conditions.
Root cause
The vulnerability stems from how Pillow handles EXIF data within PNG files. The `Exif.load()` function in `src/PIL/Image.py` strips markers from EXIF data using a loop that copies remaining data in each iteration. This design creates a quadratic time complexity when processing large chunks of repeated markers.
The `chunk_eXIf()` function in `src/PIL/PngImagePlugin.py` passes raw PNG eXIf chunk data directly into the EXIF parser without size limits. Unlike text chunks that have memory caps, eXIf chunks lack such restrictions. This allows attackers to inject large payloads that trigger excessive processing.
Attack path
Attackers craft PNG files containing eXIf chunks filled with repeated six-byte markers instead of valid EXIF data. When a vulnerable application processes these images, the parser executes a copying operation for each marker. The processing time grows quadratically with chunk size, causing significant delays.
A small image file can cause real delays because the cost scales with the square of the chunk size. No external file download is required to reproduce the issue, as the payload can be generated in memory. This makes automated exploitation straightforward for attackers targeting web services.
Affected versions
- Pillow versions 11.0.0 and later up to 13.0.0 are vulnerable
- Version 13.0.0 includes the fix for CVE-2026-96643
- The vulnerability is tracked as GHSA-g4qv-2jxx-769h
Mitigation
- Upgrade Pillow to version 13.0.0 or later to resolve the vulnerability
- Validate and limit the size of EXIF data before processing images
- Implement timeouts for image processing operations to prevent long-running tasks
- Monitor CPU usage spikes during image processing activities
Signals worth monitoring
Teams usually detect resource exhaustion attacks through unexpected CPU spikes on servers processing user uploads. Check whether image processing services show increased latency or hanging threads during normal operations. Monitor for repeated patterns in metadata parsing logs that indicate quadratic behavior. Verify that input validation covers all metadata chunk types, not just standard text fields.
Ensure alerting thresholds account for normal processing variations while catching sustained high CPU usage. Review application logs for errors related to timeout exceptions during image parsing. Confirm that monitoring tools capture resource metrics at the process level rather than just system aggregate data.
What to do and how to stay safe: Pillow
- Update Pillow to version 13.0.0 once the vendor provides an update to resolve the vulnerability
- Implement size limits for image metadata processing to reduce exposure to resource exhaustion attacks
- Monitor application performance metrics for unusual CPU spikes during image processing operations
- Validate image metadata before parsing to ensure it contains expected structures and reasonable sizes
Step-by-step guide: Attack Surface Management: 6 Common Misreadings and Correct Views
General security guidance from the NetSec Observer newsroom. It is not confirmed advice from the organisations named in this story.
Frequently asked questions
What versions of Pillow are affected by this vulnerability?
Pillow versions 11.0.0 and later up to 13.0.0 are vulnerable to CVE-2026-96643.
How do attackers exploit this vulnerability?
Attackers craft PNG files with eXIf chunks filled with repeated markers that trigger quadratic processing time.
What is the recommended fix?
Upgrade to Pillow version 13.0.0 which includes the patch for this vulnerability.




