Impact
Pillow, a widely used Python imaging library, contains an unbounded recursion flaw in its PDF parsing logic during an append operation. When processing a PDF, PdfParser follows page‑tree child references and previous‑trailer chains without performing cycle or duplication tracking. Deep or cyclic page‑trees and long chains of unique trailer offsets can exhaust the Python stack, raising a RecursionError. Additionally, repeated non‑cyclic \/Kids references can trigger super‑linear CPU and memory consumption. The resulting denial of service occurs before any output is written, and the flaw maps to CWE‑674 (Uncontrolled Recursion) and CWE‑835 (Excessive Resource Consumption). This vulnerability existed from Pillow 5.1.0 through 12.x and was fixed in version 13.0.0.
Affected Systems
The flaw exists in all Pillow releases from 5.1.0 up to, but not including, 13.0.0. Any Python environment that imports Pillow and uses Image.save with PDF append enabled is potentially vulnerable. The security advisory lists python-pillow:Pillow as the affected product. An application built with Pillow 5.1.0 through 12.x is impacted until it upgrades to 13.0.0 or later, where the issue is patched.
Risk and Exploitability
The CVSS score of 8.7 indicates a high severity. EPSS is not available, and the vulnerability is not listed in CISA KEV catalog, suggesting no confirmed exploitation as of the latest data. Attackers must supply a crafted PDF to an application that performs Image.save with append mode. Depending on how the application receives PDFs, the exploitation could be local or remote. The lack of cycle/duplication checks enables deep or cyclic page‑trees to exhaust the Python interpreter’s stack (CWE‑674), and repeated \/Kids references can trigger excessive CPU and memory use (CWE‑835). The result is a denial of service before any output is created.
OpenCVE Enrichment
Github GHSA