VAITP Dataset

← Back to the dataset

CVE-2026-96640

Exponential CPU usage via duplicated PDF /Pages nodes in Pillow ≤ 13.0.0.

  • CVSS 8.2
  • CWE-400
  • Resource Management
  • Local

Pillow is a Python imaging library. From 5.1.0 until 13.0.0, PdfParser.linearize_page_tree() in src/PIL/PdfParser.py treats a PDF /Pages graph as a tree without tracking duplicate indirect references. When Image.save(…, format="PDF", append=True) processes an attacker-controlled existing PDF whose /Kids arrays repeatedly reference the same child /Pages node, Pillow expands the shared subtree as distinct pages. A compact malformed PDF can therefore create exponentially many page references and consume disproportionate CPU before the append completes. This issue is fixed in version 13.0.0.

CVSS base score
8.2
Published
2026-10-21
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Timing/Serialization
Code defect classification
Timing Issues
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Local
Impact
Denial of Service (DoS)
Affected component
Pillow
Fixed by upgrading
Yes

Solution

Upgrade Pillow to version 13.0.0 or newer.

Vulnerable code sample

from PIL import Image

def merge_pdf(base_path: str, add_path: str, out_path: str) -> None:
    """
    Append `add_path` PDF pages to `base_path` PDF and save as `out_path`.
    """
    # Load a dummy image; Pillow requires an image object to invoke PDF saving.
    img = Image.new("RGB", (1, 1), color="white")
    # VULNERABLE: using append=True on attacker‑controlled PDF can trigger exponential page expansion
    img.save(out_path, format="PDF", append=True, append_pdf=base_path, save_all=True, append_pages=add_path)

Patched code sample

from PIL import Image

def merge_pdf(base_path: str, add_path: str, out_path: str) -> None:
    """
    Append `add_path` PDF pages to `base_path` PDF and save as `out_path`.
    """
    img = Image.new("RGB", (1, 1), color="white")
    # FIX: avoid using append=True on untrusted PDFs; perform a fresh save without appending
    img.save(out_path, format="PDF", save_all=True, append_pages=add_path)

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

Cite this entry

@misc{vaitp:cve202696640,
  title        = {{Exponential CPU usage via duplicated PDF /Pages nodes in Pillow ≤ 13.0.0.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-96640},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-96640/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.