Tetrak
GitHub ↗
Security · Pillow

Pillow's PDF parser recurses without limit when appending

PdfParser can recurse without limit in get_value() and linearize_page_tree().

Advisory
CVE-2026-112391 (also GHSA-254f-3936-288h)
Library
Pillow, pillow on PyPI
Published
Severity
6.3 out of 10, as published
Affected
>= 5.1.0, < 13.0.0
Fixed in
13.0.0
Reaches you
on a save path

What triggers it

Image.save(..., format="PDF", append=True) onto an attacker-controlled existing PDF.

What sillybos does

Needs decoding to detect

The flaw is in the pixel data or the compressed stream, which only a decoder can see. Nothing before the decoder can refuse it; updating the decoder is the fix.

The existing PDF is the input, so the check belongs in front of it: the format gate and pdfinfo's time limit apply. But the trigger is a value nested thousands of levels deep in the Root object's own dictionary, in the object graph, which a bounded check does not parse and pdfinfo's summary does not show. Out of a pre-decode check's reach.

Re-read on 2026-11-03 against the question of what rides from an opened file into a save: the file is the input.

How to protect yourself

In general. Upgrade to Pillow 13.0.0. Do not append to PDFs you did not make.

Specifically. Run the check on a PDF before appending to it, for what it does see; append only to PDFs the program wrote itself; upgrade to a Pillow with the fix.

The general advice applies to every row here.

Sources