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-112401 Overview
CVE-2026-112401 is a denial of service vulnerability in Pillow, the widely used Python imaging library. The flaw affects versions 5.4.0 through 12.x and is fixed in version 13.0.0. Pillow performs quadratic copying while parsing GIF comment extensions, causing excessive CPU consumption during image loading. An attacker can craft a small-dimension GIF file containing many comment extensions and submit it to any application that opens the image. Because frame zero is parsed during Image.open(), the resource exhaustion occurs before the application has a chance to inspect or validate the file. The weakness is categorized under CWE-407: Inefficient Algorithmic Complexity.
Critical Impact
A small, attacker-crafted GIF can exhaust CPU resources on any service that opens untrusted images with Pillow, enabling pre-validation denial of service.
Affected Products
- Pillow versions 5.4.0 through 12.x
- Python applications that call Image.open() on untrusted GIF input
- Web services and image processing pipelines using vulnerable Pillow releases
Discovery Timeline
- 2026-10-19 - CVE-2026-112401 published to NVD
- 2026-10-20 - Last updated in NVD database
Technical Details for CVE-2026-112401
Vulnerability Analysis
The vulnerability resides in GifImageFile._seek() within src/PIL/GifImagePlugin.py. During GIF parsing, Pillow processes comment extensions that may contain multiple sub-blocks. The parser repeatedly appends sub-block bytes to an immutable bytes object, triggering a new allocation and full copy on each append. This produces O(n²) time and memory behavior relative to the number and size of comment blocks.
An attacker exploits this by embedding many comment extensions in a GIF with trivial image dimensions. Because comment parsing occurs during Image.open() when frame zero is loaded, the CPU burn happens before any application-level size or content check can intervene. The attack requires no authentication and no user interaction beyond submitting the file.
Root Cause
The root cause is the use of immutable bytes concatenation inside a parsing loop. Each comment += sub_block operation copies the entire accumulated buffer, which scales quadratically with input length and block count.
Attack Vector
The vector is network-reachable. Any endpoint that accepts user-supplied images and invokes Pillow — such as avatar uploaders, document processors, thumbnail generators, or OCR pipelines — is exploitable. The attacker uploads a crafted GIF and the worker process consumes CPU parsing it, degrading or halting service for other requests.
# Patch excerpt from src/PIL/GifImagePlugin.py
palette: ImagePalette.ImagePalette | Literal[False] | None = None
info: dict[str, Any] = {}
+ comment_blocks: list[bytes] = []
frame_transparency = None
interlace = None
frame_dispose_extent = None
The fix replaces repeated bytes concatenation with a list[bytes] accumulator joined once at the end, converting the operation from O(n²) to O(n). Source: GitHub Commit 68a3fe9.
Detection Methods for CVE-2026-112401
Indicators of Compromise
- Sustained CPU saturation in Python worker processes handling image uploads, especially when correlated with GIF content types.
- Request timeouts or worker restarts triggered during Image.open() or _seek() calls in stack traces.
- Uploaded GIF files with small canvas dimensions but anomalously large file sizes or many 0x21 0xFE (comment extension) markers.
Detection Strategies
- Inventory Python environments and identify installed Pillow versions below 13.0.0 using pip list or software composition analysis tooling.
- Instrument image processing workers with per-request CPU time limits and log anomalies that exceed expected baselines.
- Inspect ingress GIFs at a WAF or upload gateway for an unusually high count of comment extension blocks.
Monitoring Recommendations
- Alert on Python worker CPU utilization spikes correlated with image upload endpoints.
- Monitor application logs for repeated PIL.GifImagePlugin stack frames in slow-request or timeout traces.
- Track SCA findings for Pillow and flag any deployment that remains below the patched version.
How to Mitigate CVE-2026-112401
Immediate Actions Required
- Upgrade Pillow to version 13.0.0 or later in all Python environments that process untrusted images.
- Audit container images, serverless functions, and virtual environments for pinned vulnerable Pillow versions.
- Apply request-level CPU and wall-clock timeouts to image processing workers to contain exploitation attempts.
Patch Information
The issue is resolved in Pillow 13.0.0. The fix is published in GitHub Release 13.0.0 and detailed in GHSA-74r2-7ff9-mjj2.
Workarounds
- Reject GIF uploads at the gateway if patching is not immediately feasible.
- Pre-scan uploaded files and drop GIFs containing an excessive number of comment extensions before passing them to Pillow.
- Isolate image parsing in short-lived subprocesses with strict CPU and memory limits using resource.setrlimit or container-level cgroup constraints.
# Upgrade Pillow to the patched 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

