Pillow 13.0.0 Patch Stops CVE-2026-112895 RecursionError DoS in PDF Appends
A high-severity flaw in the Pillow library allows attackers to crash Python services by appending malicious PDF files, a vulnerability resolved in the latest release.
Key points
- CVE-2026-112895 affects Pillow versions 5.1.0 through 12.9.x
- The flaw causes resource exhaustion and RecursionError during PDF append operations
- Version 13.0.0 addresses the issue and is available for deployment
Security teams should patch Python applications using the Pillow imaging library to prevent denial-of-service attacks via malformed PDF files. An attacker who can supply a crafted document to a service that appends pages gains the ability to exhaust system resources or crash the application entirely. This capability exists because the library’s parsing logic lacks sufficient safeguards against recursive structures within the PDF format.
In plain English
The vulnerability allows an attacker to trigger a denial-of-service condition in any application that uses Pillow to modify existing PDF documents. By providing a specially constructed file, the attacker forces the software to perform infinite or excessive recursive operations. This behavior consumes available CPU cycles and memory until the process fails, often raising an uncaught RecursionError. The impact is immediate service disruption for the affected host.
The background
The flaw is tracked as CVE-2026-112895 and carries a CVSS score of 8.7, classified as high severity. It affects all Pillow releases from version 5.1.0 up to, but not including, version 13.0.0. The issue stems from how the library handles page-tree references and trailer chains when parsing documents for append operations. Previous security updates did not address these specific recursive paths, leaving the recursion guards ineffective against certain file structures.
What changes now
The Pillow development team has released version 13.0.0 to resolve this vulnerability. Organizations running affected versions must upgrade to this release to eliminate the risk. No other remediation steps are necessary once the update is applied, as the fix addresses the underlying parsing logic flaws. Teams should verify their deployment pipelines include the new version before exposing PDF processing endpoints to external input.
What made it possible
This class of vulnerability arises when parsing logic trusts file structures without enforcing depth or cycle limits. Attackers exploit the assumption that document trees are finite and acyclic. When recursion guards are missing or insufficient, a single file can trigger exponential resource consumption. Such flaws typically serve the initial access or impact phase of an intrusion, allowing remote denial of service without authentication. Teams usually mitigate this by validating file integrity before processing and enforcing strict timeout limits on parsing tasks. Check whether your application’s input validation covers structural anomalies in binary formats.
What to do and how to stay safe
- Inventory all Python services that use Pillow to process or append PDF documents
- Verify the current installed version against the vulnerable range (5.1.0 to <13.0.0)
- Update affected systems to Pillow 13.0.0 or later as soon as possible
- Monitor application logs for RecursionError spikes or unusual resource consumption during PDF handling
Step-by-step guide: Automatic Updates Mistakes That Leave Systems Exposed
General security guidance from the RedTeam Monitor newsroom. It is not confirmed advice from the organisations named in this story.




