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-112894 Overview
CVE-2026-112894 is an algorithmic complexity vulnerability [CWE-407] in the Pillow Python imaging library. The flaw affects versions 5.1.0 through 13.0.0 and resides in the PdfParser.next_object_id() function. When saving multi-frame images with save_all enabled, Pillow takes quadratic time to reserve PDF object identifiers because it rebuilds and scans all previously reserved identifiers for every object.
An attacker can supply a crafted multi-frame image, such as a small APNG declaring a large frame count, to any application that converts images to multipage PDFs. The result is excessive CPU consumption that denies service to legitimate users. The issue is fixed in Pillow version 13.0.0.
Critical Impact
Remote attackers can trigger sustained CPU exhaustion on PDF-conversion services by submitting a tiny APNG with a large declared frame count.
Affected Products
- Pillow versions 5.1.0 through 12.x (prior to 13.0.0)
- Python applications that invoke Pillow's PDF save path with save_all=True
- Services converting user-supplied multi-frame images (APNG, GIF, TIFF) to multipage PDF
Discovery Timeline
- 2026-10-19 - CVE-2026-112894 published to NVD
- 2026-10-20 - Last updated in NVD database
Technical Details for CVE-2026-112894
Vulnerability Analysis
The vulnerability is an algorithmic complexity denial of service in Pillow's PDF writer. When Pillow saves a multi-frame image to PDF, it reserves a unique object identifier for each frame-related PDF object. The PdfParser.next_object_id() helper determines the next free identifier by iterating over the full set of existing entries on every call.
For an image with N frames, Pillow invokes this routine proportionally N times, and each call scans O(N) entries. The total work is therefore O(N²). Small inputs can declare large frame counts, so a few kilobytes of attacker input translate into minutes of CPU time. The impact is confined to availability; no memory corruption or data exposure occurs.
Root Cause
The root cause is the absence of a running maximum of reserved object identifiers in the PdfParser state. Each call to next_object_id() recomputed the maximum by traversing every entry in existing_entries, new_entries, and deleted_entries. Combined with per-frame invocation, this yielded quadratic complexity on frame count.
Attack Vector
The attack vector is network-reachable image upload endpoints that invoke Pillow's PDF conversion. An attacker uploads a crafted multi-frame image, typically an APNG with a fraudulently large num_frames field, to a service that calls Image.save(..., save_all=True, format='PDF'). Because the input file remains small, standard upload size limits do not block the request. The server then spends disproportionate CPU time reserving PDF object IDs.
# Security patch in src/PIL/PdfParser.py
# Assign next PDF object ID in constant time (#10133)
) # object ID => (offset, generation)
self.deleted_entries = {0: 65536} # object ID => generation
self.reading_finished = False
+ self._max_object_id = 0
def __setitem__(self, key: int, value: tuple[int, int]) -> None:
if self.reading_finished:
self.new_entries[key] = value
else:
self.existing_entries[key] = value
+ if key > self._max_object_id:
+ self._max_object_id = key
if key in self.deleted_entries:
del self.deleted_entries[key]
Source: GitHub Pillow Commit f6a8525. The patch tracks the maximum assigned object ID as entries are inserted, replacing the O(N) scan in next_object_id() with a constant-time lookup.
Detection Methods for CVE-2026-112894
Indicators of Compromise
- Python worker processes sustaining 100% CPU on a single core while handling image uploads
- Request latency spikes correlated with uploads of small APNG, GIF, or TIFF files
- Stack traces or profiler samples showing extended time in PIL.PdfParser.next_object_id
- Growing queue depth in image-conversion workers without matching input volume
Detection Strategies
- Instrument the image-conversion pipeline to log input frame counts and conversion wall-clock time, alerting on outliers.
- Inspect uploaded APNG files for declared num_frames values that disagree with actual frame data chunks.
- Compare file size against declared frame count; a ratio exceeding reasonable thresholds indicates a crafted input.
Monitoring Recommendations
- Monitor per-request CPU time for endpoints that call Pillow with save_all=True.
- Track the Pillow version in deployed container images and virtual environments through software bill of materials tooling.
- Alert on repeated requests from the same source that trigger conversion timeouts.
How to Mitigate CVE-2026-112894
Immediate Actions Required
- Upgrade Pillow to version 13.0.0 or later in all production and development environments.
- Audit application code for calls to Image.save() with save_all=True and format='PDF' that accept untrusted input.
- Impose request timeouts and CPU limits on worker processes performing image conversion.
- Reject input images whose declared frame count exceeds a sane application-specific threshold.
Patch Information
The fix is included in Pillow 13.0.0, released upstream with commit f6a8525. See the GitHub Pillow Release 13.0.0 notes and the GitHub Security Advisory GHSA-jg86-v3jv-hrpm for full remediation details.
Workarounds
- Disable PDF export for multi-frame images until the upgrade is complete.
- Validate and cap frame counts before invoking Pillow's PDF writer.
- Run image conversion in sandboxed workers with strict CPU and wall-clock limits enforced by the operating system or orchestrator.
# Upgrade Pillow to the patched release
pip install --upgrade 'Pillow>=13.0.0'
# Verify installed version
python -c "import PIL; print(PIL.__version__)"
# Enforce a CPU time limit on conversion workers (Linux)
ulimit -t 10
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

