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

CVE-2026-96637: Pillow Python Library DOS Vulnerability

CVE-2026-96637 is a denial of service vulnerability in Pillow Python imaging library that allows memory exhaustion through malicious SPIDER image files. This post explains its impact, affected versions, and mitigation steps.

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-96637 Overview

CVE-2026-96637 is a resource exhaustion vulnerability [CWE-400] in the Pillow Python imaging library. The flaw resides in SpiderImageFile.seek() within src/PIL/SpiderImagePlugin.py. When seeking to a later SPIDER stack frame, the method reparses the frame and replaces self._size without rerunning Image._decompression_bomb_check(). An attacker can craft a small SPIDER file that uses a safe first frame to pass Image.open() and declare very large dimensions in a later mode F frame. Loading that frame allocates roughly four bytes per attacker-declared pixel, consuming multiple gigabytes of memory. The issue is fixed in Pillow 13.0.0.

Critical Impact

A tiny crafted SPIDER file can trigger multi-gigabyte memory allocation in any Python application that uses Pillow to open and seek through user-supplied images, leading to denial of service.

Affected Products

  • Python Pillow imaging library versions prior to 13.0.0
  • Applications using PIL.SpiderImagePlugin to process SPIDER stack files
  • Web services and pipelines that accept user-supplied image uploads processed via Pillow

Discovery Timeline

  • 2026-10-21 - CVE-2026-96637 published to the National Vulnerability Database
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2026-96637

Vulnerability Analysis

Pillow enforces a decompression bomb check during Image.open() to guard against images that declare oversized dimensions relative to their file size. For SPIDER stack files, that check runs against the first frame only. The SpiderImageFile.seek() method reopens later frames and overwrites self._size with the dimensions declared in the new frame header. Because the check is not re-executed on this path, dimension validation is effectively bypassed for subsequent frames.

When the caller then triggers a load() on the newly seeked frame, Pillow allocates a backing buffer sized to the attacker-controlled dimensions. Mode F frames use 32-bit floating-point samples, so allocation grows at roughly four bytes per declared pixel. A declared resolution on the order of tens of thousands by tens of thousands produces multi-gigabyte allocations from a file that may be only a few kilobytes on disk.

Root Cause

The root cause is a missing invocation of Image._decompression_bomb_check(self.size) after self._open() is called inside SpiderImageFile.seek(). The initial safety control is implemented, but is not applied to the re-parse path for subsequent stack frames. This is a classic Uncontrolled Resource Consumption weakness [CWE-400].

Attack Vector

Exploitation requires an attacker to deliver a malicious SPIDER file to an application that calls Image.open() followed by seek() or iteration across stack frames. User interaction is typically limited to uploading or supplying the file. Image processing pipelines, thumbnail generators, scientific imaging workflows, and any service that iterates frames in a SPIDER stack are exposed. Successful exploitation causes memory exhaustion and process termination.

python
         self.fp = self._fp
         self.fp.seek(self.stkoffset)
         self._open()
+        Image._decompression_bomb_check(self.size)
 
     # returns a byte image after rescaling to 0..255
     def convert2byte(self, depth: int = 255) -> Image.Image:

Source: GitHub Commit 7cb0e02. The patch adds the missing Image._decompression_bomb_check(self.size) call immediately after the frame is reparsed, restoring the dimension safety control on the seek path.

Detection Methods for CVE-2026-96637

Indicators of Compromise

  • Python worker processes terminated by the kernel OOM killer shortly after processing user-supplied images
  • Sudden multi-gigabyte RSS growth in processes that import PIL.SpiderImagePlugin
  • Application logs containing MemoryError traces originating from PIL/Image.py or SpiderImagePlugin.py
  • Inbound files with the SPIDER header where declared frame dimensions are disproportionate to file size

Detection Strategies

  • Inventory Python environments and identify installations of Pillow at versions earlier than 13.0.0 using pip list or software composition analysis tooling.
  • Add input validation in application code that rejects SPIDER files whose declared per-frame dimensions exceed service-specific thresholds before calling seek().
  • Enable Pillow's Image.MAX_IMAGE_PIXELS enforcement and treat Image.DecompressionBombError as a security event in logs.

Monitoring Recommendations

  • Alert on image-processing workers exceeding memory budgets or triggering cgroup OOM events.
  • Monitor for repeated MemoryError or DecompressionBombWarning entries in application telemetry.
  • Track outbound package manifests through CI to detect reintroduction of vulnerable Pillow versions.

How to Mitigate CVE-2026-96637

Immediate Actions Required

  • Upgrade Pillow to version 13.0.0 or later across all Python environments, container images, and build artifacts.
  • Audit application code for use of SpiderImageFile.seek() or frame iteration on untrusted SPIDER files and gate it behind size and dimension checks.
  • Apply per-process memory limits using cgroups, ulimit, or container resource constraints to contain exploitation attempts.

Patch Information

The fix is included in Pillow Release 13.0.0 and tracked in Pull Request #10076. See the project's GHSA-g842-9rc4-69pw advisory for full disclosure details.

Workarounds

  • Disable or remove the SPIDER plugin registration if the format is not required by the application.
  • Lower Image.MAX_IMAGE_PIXELS to a value appropriate for expected content and handle DecompressionBombError exceptions.
  • Reject uploads whose declared SPIDER frame dimensions exceed documented service limits before invoking Pillow.
bash
# Upgrade Pillow to the fixed release
pip install --upgrade "Pillow>=13.0.0"

# Verify 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.