CVE-2026-112894
CPU‑exhaustion DoS via Pillow PDF save_all quadratic ID reservation (pre‑13.0.0).
- CVSS 8.7
- CWE-407
- Resource Management
- Remote
Pillow is a Python imaging library. From 5.1.0 until 13.0.0, Pillow takes quadratic time to reserve PDF object identifiers when saving many frames with save_all enabled. PdfParser.next_object_id() repeatedly rebuilds and scans all previously reserved identifiers for every object. An attacker can supply a multi-frame image, including a small APNG with a large declared frame count, to an application that converts it to a multipage PDF. This can consume excessive CPU and deny service. This issue is fixed in version 13.0.0.
- CWE
- CWE-407
- CVSS base score
- 8.7
- Published
- 2026-10-19
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Timing/Serialization
- Code defect classification
- Timing Issues
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- Pillow
- Fixed by upgrading
- Yes
Solution
Upgrade Pillow to version 13.0.0 or newer.
Vulnerable code sample
from PIL import Image
def convert_to_pdf(frames, out_path):
"""
Convert a sequence of Pillow Image objects to a multipage PDF.
"""
# VULNERABLE: quadratic PDF object reservation when save_all=True
frames[0].save(out_path, format="PDF", save_all=True, append_images=frames[1:])Patched code sample
from PIL import Image
def convert_to_pdf(frames, out_path):
"""
Convert a sequence of Pillow Image objects to a multipage PDF.
"""
# FIX: avoid quadratic reservation by saving pages individually
frames[0].save(out_path, format="PDF")
for i, img in enumerate(frames[1:], start=1):
img.save(out_path, format="PDF", append=True)Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Assign next PDF object ID in constant time (#10133) (python-pillow/Pillow)
src/PIL/PdfParser.py · PdfParser.next_object_id,src/PIL/PdfParser.py · XrefTable.__init__,src/PIL/PdfParser.py · XrefTable.__setitem__
Cite this entry
@misc{vaitp:cve2026112894,
title = {{CPU‑exhaustion DoS via Pillow PDF save_all quadratic ID reservation (pre‑13.0.0).}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-112894},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-112894/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
