VAITP Dataset

← Back to the dataset

CVE-2026-84309

Infinite loop in pypdf TreeObject.insert_child via crafted cyclic PDF tree.

  • CVSS 6.9
  • CWE-835
  • Resource Management
  • Remote

pypdf is a free and open-source pure-python PDF library. Prior to 6.16.0, an attacker can craft a PDF whose cyclic tree structure causes pypdf/generic/_data_structures.py TreeObject.insert_child to follow /Next links indefinitely when a writing code path inserts a child, producing an infinite loop. This issue is fixed in version 6.16.0.

CVSS base score
6.9
Published
2026-09-01
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Algorithm
Code defect classification
Incorrect Algorithm
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Remote
Impact
Denial of Service (DoS)
Affected component
pypdf
Fixed by upgrading
Yes

Solution

Upgrade pypdf to version 6.16.0 or later.

Vulnerable code sample

from typing import Optional

class TreeNode:
    def __init__(self, name: str):
        self.name = name
        self.first_child: Optional["TreeNode"] = None
        self.next_sibling: Optional["TreeNode"] = None

    # VULNERABLE: infinite loop on cyclic Next links
    def insert_child(self, child: "TreeNode") -> None:
        """Insert child as the last sibling of this node's children."""
        if self.first_child is None:
            self.first_child = child
            return
        cur = self.first_child
        while cur.next_sibling is not None:
            cur = cur.next_sibling
        cur.next_sibling = child

Patched code sample

from typing import Optional, Set

class TreeNode:
    def __init__(self, name: str):
        self.name = name
        self.first_child: Optional["TreeNode"] = None
        self.next_sibling: Optional["TreeNode"] = None

    # FIX: detect cycles in Next links to prevent infinite loop
    def insert_child(self, child: "TreeNode") -> None:
        """Insert child as the last sibling of this node's children."""
        if self.first_child is None:
            self.first_child = child
            return
        cur = self.first_child
        visited: Set[int] = set()
        while cur.next_sibling is not None:
            if id(cur) in visited:
                raise RuntimeError("Cycle detected in Next links")
            visited.add(id(cur))
            cur = cur.next_sibling
        cur.next_sibling = child

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:cve202684309,
  title        = {{Infinite loop in pypdf TreeObject.insert_child via crafted cyclic PDF tree.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-84309},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-84309/}}
}

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.