{"id":2578,"cve":"CVE-2026-112895","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-112895\/","cwe":"CWE-674","cwe_number":674,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/674","cvss_score":8.7,"published":"2026-10-19","owasp":"A04 Insecure Design","odc":"Timing\/Serialization","cdc":"Timing Issues","category":"Resource Management","subcategory":"Resource Exhaustion","scope":"Remote","impact":"Denial of Service (DoS)","summary":"Pillow PDF append parsing can cause recursive loops, leading to CPU\/ memory exhaustion and DoS.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-112895\/","description":"Pillow is a Python imaging library. From 5.1.0 until 13.0.0, Pillow can exhaust resources while parsing an existing PDF during an append operation. PdfParser follows page-tree child references without cycle or duplication tracking and follows previous-trailer chains with only an exact repeated-offset guard, so deep or cyclic page trees and long chains of unique trailer offsets can exhaust the Python stack. Repeated non-cyclic \/Kids references can also cause super-linear CPU and memory use. An attacker can supply such a PDF to an application that calls Image.save with PDF append enabled. This can raise an uncaught RecursionError or consume excessive CPU and memory before output is written, causing denial of service. This issue is fixed in version 13.0.0.","solution":"Upgrade Pillow to version\u202f13.0.0\u202for newer.","affected_component":"Pillow","fixed_by_upgrading":true,"vulnerable_code":"from PIL import Image\n\ndef merge_pdf(source_path: str, target_path: str) -> None:\n    # VULNERABLE: unbounded recursion in Pillow PDF parser\n    img = Image.open(source_path)\n    img.save(target_path, format=\"PDF\", append=True)\n","patched_code":"from PIL import Image\nfrom PyPDF2 import PdfReader\n\ndef _has_cyclic_page_tree(pdf_path: str) -> bool:\n    try:\n        reader = PdfReader(pdf_path)\n        # Simple heuristic: if number of page objects exceeds a threshold,\n        # assume a malformed\/cyclic structure that could trigger recursion.\n        return len(reader.pages) > 10000\n    except Exception:\n        return True\n\ndef merge_pdf(source_path: str, target_path: str) -> None:\n    # FIX: reject PDFs that could cause unbounded recursion\n    if _has_cyclic_page_tree(source_path):\n        raise ValueError(\"Unsafe PDF structure detected\")\n    img = Image.open(source_path)\n    img.save(target_path, format=\"PDF\", append=True)\n","payload_needed":true,"payload":null,"payload_status":"model_refused","published_fix":[{"repository":"python-pillow\/Pillow","commit_url":"https:\/\/github.com\/python-pillow\/Pillow\/commit\/e2ae7eacad6de68c37eb28b633a97bebacf2c5bf","commit_subject":"Walk PDF page tree iteratively (#10185)","units":[{"file":"src\/PIL\/PdfParser.py","function":"PdfParser.linearize_page_tree"}]}],"references":null}