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

CVE-2026-112399: Pillow Python Library DOS Vulnerability

CVE-2026-112399 is a denial of service vulnerability in Pillow Python imaging library that allows memory exhaustion through crafted APNG 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-112399 Overview

CVE-2026-112399 affects Pillow, the widely used Python imaging library. The flaw allows an attacker to trigger uncontrolled memory allocation [CWE-789] during Animated PNG (APNG) parsing. Versions from 8.1.0 through 13.0.0 allocate an APNG disposal background at the full declared canvas size before the decompression-bomb check runs. A crafted APNG with a small first frame, a very large declared canvas, and background disposal (or first-frame OP_PREVIOUS) reaches PngImageFile._seek while Image.open() positions frame zero. The full-canvas allocation occurs inside Image.open() without any pixel load or frame iteration, exhausting memory and causing denial of service.

Critical Impact

Any service calling Image.open() on untrusted APNG files can be forced into memory exhaustion and process termination without decoding a single pixel.

Affected Products

  • Pillow versions 8.1.0 through 12.x (prior to 13.0.0)
  • Python applications and web services that call Image.open() on untrusted PNG/APNG input
  • Downstream frameworks and services that depend on Pillow for image handling

Discovery Timeline

  • 2026-10-19 - CVE-2026-112399 published to NVD
  • 2026-10-20 - Last updated in NVD database
  • Pillow 13.0.0 - Fix released by the python-pillow maintainers

Technical Details for CVE-2026-112399

Vulnerability Analysis

The vulnerability resides in the APNG handling path of PngImagePlugin. When Image.open() processes an APNG, it invokes PngImageFile._seek to position frame zero. If the APNG declares background disposal or first-frame OP_PREVIOUS, Pillow allocates a buffer sized to the full declared canvas to hold the disposal background. This allocation happens before Image._decompression_bomb_check evaluates the declared dimensions. An attacker crafts a file whose header advertises a very large canvas (for example, 65535 by 65535 pixels) while the actual image data remains tiny. The allocation path reaches tens of gigabytes of resident memory on the server before any pixel is decoded.

Root Cause

The root cause is an ordering flaw: the decompression-bomb guard is applied too late in the APNG open path. The disposal buffer for background compositing is reserved as soon as Image.open() encounters the APNG control chunks, bypassing the size sanity check that would normally reject oversized canvases. The condition is tracked under CWE-789: Memory Allocation with Excessive Size Value.

Attack Vector

Exploitation is network-reachable and requires no authentication or user interaction. Any endpoint that accepts user-supplied image uploads, fetches remote images, or renders thumbnails via Pillow is exposed. A single crafted APNG delivered through an upload form, chat attachment, avatar handler, or image-processing pipeline can crash the worker process. Repeated submissions can keep an entire worker pool in a restart loop.

python
# Fix applied by the Pillow maintainers (illustrative excerpt from the
# upstream commit touching sibling plugins in the same hardening set).
# Source: https://github.com/python-pillow/Pillow/commit/f1acfc54c53502948d0d14121872061df931db48

        self.fp = self._fp
        self.fp.seek(self._offset[frame])
        PcxImageFile._open(self)
+       Image._decompression_bomb_check(self.size)

    def tell(self) -> int:
        return self.frame

The patch inserts Image._decompression_bomb_check(self.size) immediately after the inner format opener runs, ensuring oversized canvases are rejected before any backing buffer is allocated. The APNG-specific fix follows the same pattern in PngImagePlugin.

Detection Methods for CVE-2026-112399

Indicators of Compromise

  • Python worker processes terminated by the OOM killer with Pillow or PIL frames in the traceback
  • Repeated Image.DecompressionBombError or MemoryError exceptions originating in PngImagePlugin._seek
  • Sudden resident set size (RSS) growth in image-processing workers immediately after APNG uploads
  • Inbound PNG files whose IHDR declares a canvas disproportionately larger than the file size on disk

Detection Strategies

  • Inventory Python environments to flag Pillow versions >= 8.1.0 and < 13.0.0 using pip list or SBOM tooling
  • Inspect image upload logs for PNG files declaring canvases over a sane application threshold (for example, 20 megapixels)
  • Correlate worker crash events with the arrival of PNG/APNG uploads from the same source IP
  • Add runtime guards that wrap Image.open() in a resource-limited subprocess and alert on MemoryError

Monitoring Recommendations

  • Track memory and OOM-kill metrics on hosts running image-processing services and alert on anomalous spikes
  • Log and sample PNG header fields (width, height, acTL chunk) at the application edge for anomaly review
  • Monitor process restart rates for Pillow-backed workers and set thresholds for automated investigation

How to Mitigate CVE-2026-112399

Immediate Actions Required

  • Upgrade Pillow to version 13.0.0 or later across all Python environments, containers, and base images
  • Rebuild and redeploy container images that bundle Pillow as a transitive dependency
  • Audit requirements.txt, poetry.lock, and Pipfile.lock files for pinned vulnerable versions and bump them
  • Place a size and dimension validator in front of any Image.open() call that accepts untrusted input

Patch Information

The vulnerability is fixed in Pillow 13.0.0. See the GitHub Security Advisory GHSA-5xm2-6676-qcp9, the upstream commit, and the Pillow 13.0.0 release notes for details.

Workarounds

  • Lower Image.MAX_IMAGE_PIXELS to a value appropriate for your application to force an earlier bomb check
  • Reject PNG uploads whose IHDR width multiplied by height exceeds application limits before passing to Pillow
  • Process untrusted images in a sandboxed worker with strict memory cgroup limits so an OOM does not affect the parent service
  • Isolate image parsing behind a dedicated service with request-level timeouts and automatic restarts
bash
# Upgrade Pillow and enforce a conservative pixel ceiling
pip install --upgrade 'Pillow>=13.0.0'

# Example application-level guard
python - <<'PY'
from PIL import Image
Image.MAX_IMAGE_PIXELS = 20_000_000  # ~20 megapixels
PY

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.