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-112891 Overview
CVE-2026-112891 is a denial of service vulnerability in Pillow, the widely used Python imaging library. The flaw affects versions from 9.2.0 up to (but not including) 13.0.0. Pillow performs quadratic copying when saving a GIF image that contains a long comment. The _get_global_header() function repeatedly copies portions of comment data while assembling the global header, including comments retained from an untrusted input image. An attacker who supplies an image with a large GIF comment to an application that saves it as GIF can consume excessive CPU time and delay or deny service. The issue is categorized under CWE-407: Inefficient Algorithmic Complexity.
Critical Impact
Any Python application that accepts untrusted images and re-saves them as GIF using Pillow can be forced into prolonged CPU-bound processing, enabling resource exhaustion attacks against image-processing services.
Affected Products
- Pillow versions 9.2.0 through 12.x (fixed in 13.0.0)
- Python applications and web services using Pillow for image conversion to GIF
- Downstream frameworks and services that embed Pillow for user-supplied image handling
Discovery Timeline
- 2026-10-19 - CVE-2026-112891 published to NVD
- 2026-10-20 - Last updated in NVD database
- Fix released - Pillow release 13.0.0 addresses the issue via commit 68a3fe9 and GHSA-fc9g-5qg7-mf45
Technical Details for CVE-2026-112891
Vulnerability Analysis
The vulnerability lives in the GIF plugin at src/PIL/GifImagePlugin.py, specifically in _get_global_header(). When Pillow assembles the GIF global header during a save operation, it repeatedly concatenates comment data into a growing byte string. Each concatenation allocates a new buffer and copies all prior content, yielding O(n²) time complexity relative to the comment length. A sufficiently large comment turns a routine save call into a long-running CPU-bound operation. Because GIF comments are preserved from input images, an attacker only needs to upload a crafted GIF (or any image carrying a large retained comment) and trigger a GIF save path.
Root Cause
The root cause is inefficient algorithmic complexity in header assembly. The pre-patch implementation built the comment blocks via repeated bytes concatenation inside a loop, causing quadratic copying. The patch introduces a comment_blocks: list[bytes] accumulator and joins fragments once, replacing O(n²) copying with linear-time construction.
Attack Vector
Exploitation is network-reachable, requires no authentication, and no user interaction. An attacker uploads an image containing a large GIF comment to any service that uses Pillow to re-encode or convert images to GIF. The server-side save call stalls, consuming CPU and worker threads. Repeated submissions amplify impact, exhausting the processing pool.
palette: ImagePalette.ImagePalette | Literal[False] | None = None
info: dict[str, Any] = {}
+ comment_blocks: list[bytes] = []
frame_transparency = None
interlace = None
frame_dispose_extent = None
Source: Pillow commit 68a3fe9 — the fix replaces repeated byte concatenation with a list accumulator joined once, eliminating the quadratic copy pattern.
Detection Methods for CVE-2026-112891
Indicators of Compromise
- Prolonged CPU utilization by Python worker processes handling image uploads, often correlated with a single request ID
- HTTP request timeouts or 5xx errors from image conversion endpoints following GIF upload traffic
- Uploaded GIF files with abnormally large comment extension blocks (GIF extension introducer 0x21 0xFE)
- Worker process memory growth during GIF save operations originating from PIL.GifImagePlugin._get_global_header
Detection Strategies
- Instrument image-processing endpoints with per-request CPU and wall-clock budgets, alerting when GIF save calls exceed baseline thresholds
- Perform static dependency scanning for Pillow versions >=9.2.0,<13.0.0 across build pipelines and container images
- Inspect uploaded images for oversized GIF comment blocks before passing them to Pillow
Monitoring Recommendations
- Track application performance monitoring (APM) traces for PIL.GifImagePlugin functions and flag outliers
- Monitor web application firewall (WAF) logs for repeated large image uploads from a single source
- Alert on worker pool saturation and request queue depth increases for image services
How to Mitigate CVE-2026-112891
Immediate Actions Required
- Upgrade Pillow to version 13.0.0 or later across all applications, containers, and virtual environments
- Enforce input size limits on uploaded images and reject files whose embedded metadata or comment blocks exceed sane thresholds
- Apply request-level CPU and timeout controls to image conversion workers to contain algorithmic complexity attacks
Patch Information
The fix is included in Pillow 13.0.0. Technical details are documented in GHSA-fc9g-5qg7-mf45 and the corresponding source commit.
Workarounds
- Strip or truncate GIF comment metadata from input images before invoking Image.save(..., format="GIF")
- Disallow GIF as an output format in user-facing conversion endpoints until Pillow is upgraded
- Isolate image processing in sandboxed workers with strict CPU time and memory limits
# 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

