CVE-2026-112391
Unlimited recursion in Pillow's PDF parser leads to DoS via crafted nested PDFs.
- CVSS 6.3
- CWE-835
- Resource Management
- Remote
Pillow is a Python imaging library. From 5.1.0 until 13.0.0, Pillow's PdfParser.get_value() can recurse without a limit while reading nested PDF objects. The parser follows attacker-controlled arrays and dictionaries when an existing PDF is opened for append. An attacker can provide a deeply nested PDF to an application that saves an image with PDF append enabled. This can raise an uncaught RecursionError or terminate the worker, causing denial of service. This issue is fixed in version 13.0.0.
- CWE
- CWE-835
- CVSS base score
- 6.3
- Published
- 2026-10-19
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Algorithm
- Code defect classification
- Incorrect Algorithm
- 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 later.
Vulnerable code sample
from PIL import Image
def process_pdf(input_path: str, output_path: str) -> None:
# VULNERABLE: unbounded recursion when Pillow parses nested PDF objects during append
img = Image.open(input_path) # opens existing PDF
img.save(output_path, format="PDF", save_all=True, append_images=[img]) # triggers PdfParser recursionPatched code sample
from PIL import Image
import sys
def process_pdf(input_path: str, output_path: str) -> None:
# FIX: limit Python recursion depth before invoking Pillow's PDF parser
sys.setrecursionlimit(1000) # reasonable upper bound prevents RecursionError
img = Image.open(input_path)
img.save(output_path, format="PDF", save_all=True, append_images=[img])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.
- Set PdfParser default max_nesting limit to 900 (#10127) (python-pillow/Pillow)
src/PIL/PdfParser.py · PdfParser.get_value,src/PIL/PdfParser.py · PdfParser.read_indirect
Cite this entry
@misc{vaitp:cve2026112391,
title = {{Unlimited recursion in Pillow's PDF parser leads to DoS via crafted nested PDFs.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-112391},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-112391/}}
}
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 ::
