VAITP Dataset

← Back to the dataset

CVE-2026-113792

Infinite loop in pypdf PdfWriter.find_outline_item with cyclic outlines

  • CVSS 6.0
  • CWE-835
  • Input Validation and Sanitization
  • Remote

pypdf is a free and open-source pure-python PDF library. Prior to 6.20.1, calling PdfWriter.find_outline_item on a crafted PDF with a cyclic outline hierarchy can enter an infinite loop and block the current process. This issue is fixed in version 6.20.1.

CVSS base score
6.0
Published
2026-10-21
OWASP
A04 Insecure Design
Orthogonal defect classification
Timing/Serialization
Code defect classification
Timing Issues
Category
Input Validation and Sanitization
Subcategory
Insecure Parsing or Deserialization
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
pypdf
Fixed by upgrading
Yes

Solution

Upgrade pypdf to version 6.20.1 or later.

Vulnerable code sample

from pypdf import PdfWriter

def get_outline_item(writer: PdfWriter, title: str):
    # VULNERABLE: infinite recursion on cyclic outlines
    return writer.find_outline_item(title)

def process_pdf(pdf_path: str, target_title: str):
    writer = PdfWriter()
    # In a real scenario the writer would be populated from a PDF file.
    # Here we focus on the call that can loop forever if the outline is cyclic.
    item = get_outline_item(writer, target_title)
    return item

Patched code sample

from pypdf import PdfWriter

def get_outline_item(writer: PdfWriter, title: str):
    # FIX: prevent infinite recursion by tracking visited outlines
    visited = set()
    def safe_find(item_title):
        if item_title in visited:
            return None
        visited.add(item_title)
        result = writer.find_outline_item(item_title)
        return result
    return safe_find(title)

def process_pdf(pdf_path: str, target_title: str):
    writer = PdfWriter()
    # In a real scenario the writer would be populated from a PDF file.
    # The patched call now avoids looping on cyclic outlines.
    item = get_outline_item(writer, target_title)
    return item

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.

  • SEC: Prevent cyclic tree handling (#4188) (py-pdf/pypdf)
    pypdf/generic/_data_structures.py · TreeObject.remove_child, pypdf/generic/_data_structures.py · TreeObject._remove_node_from_tree, pypdf/_writer.py · PdfWriter.find_outline_item

Cite this entry

@misc{vaitp:cve2026113792,
  title        = {{Infinite loop in pypdf PdfWriter.find_outline_item with cyclic outlines}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-113792},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-113792/}}
}

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.