Skip to main content
Vulnerability Database/CVE-2026-96643

CVE-2026-96643: Pillow Python Library DOS Vulnerability

CVE-2026-96643 is a denial of service vulnerability in Pillow Python imaging library affecting versions 11.0.0 to 13.0.0. Malicious PNG files with repeated EXIF headers cause quadratic CPU consumption. This article covers technical details, affected versions, impact assessment, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2026-96643 Overview

CVE-2026-96643 is a denial-of-service vulnerability in the Pillow Python imaging library affecting versions 11.0.0 through 12.x. The flaw resides in Exif.load() within src/PIL/Image.py, which repeatedly slices remaining EXIF data while it starts with the six-byte Exif header. Combined with src/PIL/PngImagePlugin.py accepting an uncapped PNG eXIf chunk, a crafted file containing repeated headers forces a new shrinking copy on every iteration, producing quadratic CPU work. The condition is reachable through Image.getexif(), Image._getexif(), and ImageOps.exif_transpose(), including photo-upload rotation workflows common in web applications.

Critical Impact

Remote attackers can upload a malicious image to trigger quadratic CPU consumption, exhausting server resources and causing denial of service in any Pillow-backed image processing pipeline.

Affected Products

  • Pillow versions 11.0.0 through 12.x (prior to 13.0.0)
  • Python applications using Image.getexif() or Image._getexif() for EXIF parsing
  • Web services calling ImageOps.exif_transpose() for photo upload rotation

Discovery Timeline

  • 2026-10-21 - CVE CVE-2026-96643 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2026-96643

Vulnerability Analysis

The vulnerability is an algorithmic complexity flaw [CWE-407] in Pillow's EXIF metadata parser. When Pillow encounters EXIF data prefixed with the six-byte header Exif\\x00\\x00, the parser strips those bytes and reassigns the remainder in a loop. Each slice operation allocates a new bytes object containing the remaining data. An attacker who submits a PNG file whose eXIf chunk is filled with many consecutive copies of the Exif header forces the parser to perform repeated large allocations, yielding O(n²) behavior relative to chunk size.

Because PngImagePlugin.py does not cap the size of the eXIf chunk, the attacker controls the loop count directly through chunk length. The resulting CPU exhaustion blocks worker threads handling image uploads.

Root Cause

The root cause is the unbounded while data and data.startswith(b"Exif\\x00\\x00"): data = data[6:] construct. Python bytes slicing produces a full copy, so repeated slicing of a large buffer costs memory and CPU proportional to the remaining length multiplied by the number of iterations.

Attack Vector

Exploitation requires an attacker to deliver a crafted image to any endpoint that invokes Pillow's EXIF handling. Typical targets include profile picture uploads, image hosting services, and automated thumbnail or rotation pipelines using ImageOps.exif_transpose(). No authentication is required when upload endpoints are publicly reachable, and user interaction is limited to the victim service parsing the file.

python
# Patch excerpt from src/PIL/Image.py (Pillow PR #10073)
         self._data.clear()
         self._hidden_data.clear()
         self._ifds.clear()
-        while data and data.startswith(b"Exif\\x00\\x00"):
-            data = data[6:]
+        data = re.sub(b"^(Exif\\x00\\x00){1,2}", b"", data)
         if not data:
             self._info = None
             return
# Source: https://github.com/python-pillow/Pillow/commit/806e38381c781f32bbd22f4cd026678acd40fd6c

The fix replaces the unbounded loop with a regular expression that strips at most two Exif header prefixes, eliminating the quadratic path.

Detection Methods for CVE-2026-96643

Indicators of Compromise

  • Sustained high CPU usage on image-processing workers immediately after image upload requests
  • HTTP request timeouts or 5xx errors from endpoints that call Pillow EXIF functions
  • PNG files containing abnormally large eXIf chunks or chunks composed of repeated Exif\\x00\\x00 sequences

Detection Strategies

  • Scan uploaded images for PNG eXIf chunks whose size exceeds a reasonable threshold (for example, 64 KB) before passing them to Pillow.
  • Monitor Python worker processes for anomalous CPU time per image request using application performance monitoring.
  • Add structured logging around Image.getexif() and ImageOps.exif_transpose() calls to flag parsing durations above a baseline.

Monitoring Recommendations

  • Alert on image upload endpoints when per-request CPU time exceeds the 99th percentile baseline.
  • Track Pillow version inventory across containers and services to confirm patch coverage.
  • Correlate upload request source IPs with repeated worker exhaustion events to identify abusive clients.

How to Mitigate CVE-2026-96643

Immediate Actions Required

  • Upgrade Pillow to version 13.0.0 or later across all application and container images.
  • Audit dependency manifests (requirements.txt, pyproject.toml, Pipfile.lock) for pinned Pillow versions in the vulnerable 11.0.0–12.x range.
  • Add per-request CPU and wall-clock timeouts to image processing workers to contain abuse until patching completes.

Patch Information

The fix shipped in Pillow 13.0.0 via pull request python-pillow/Pillow#10073 and commit 806e383. Additional context is available in the GitHub Security Advisory GHSA-g4qv-2jxx-769h and the Pillow 13.0.0 release notes.

Workarounds

  • Enforce a maximum file size and reject PNGs whose eXIf chunk length exceeds a safe limit before invoking Pillow.
  • Run image processing in isolated worker processes with strict CPU and memory cgroup limits so a single malicious upload cannot exhaust the host.
  • Disable automatic EXIF transposition in upload workflows that do not require image rotation.
bash
# Pin the fixed Pillow version in your Python environment
pip install --upgrade "Pillow>=13.0.0"

# Verify the installed version
python -c "import PIL; print(PIL.__version__)"

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.