VAITP Dataset

← Back to the dataset

CVE-2026-129225

Recursive parsing of malicious dependency graphs can cause stack overflow

  • CVSS 5.3
  • CWE-674
  • Resource Management
  • Local

NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. In 3.10.3 and earlier, DependencyGraph._tree and triples recurse once per dependency edge without a depth bound, and get_cycle_path also lacks a visited-set termination guard. A deeply chained or cyclic attacker-controlled CoNLL or Malt-TAB dependency structure can raise RecursionError and abort a parse worker. This issue is fixed in version 3.10.4.

CVSS base score
5.3
Published
2026-11-19
OWASP
A06 Vulnerable and Outdated Components
Orthogonal defect classification
Algorithm
Code defect classification
Incorrect Algorithm
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Local
Impact
Denial of Service (DoS)
Affected component
NLTK
Fixed by upgrading
Yes

Solution

Upgrade NLTK to version 3.10.4 or later.

Vulnerable code sample

import sys
from nltk.parse import DependencyGraph

def extract_tree(conll_str):
    """
    Build a DependencyGraph from a CoNLL string and return its tree representation.
    """
    dg = DependencyGraph(conll_str)
    # VULNERABLE: unbounded recursion in DependencyGraph._tree can cause RecursionError
    return list(dg._tree())

Patched code sample

import sys
from nltk.parse import DependencyGraph

def _bounded_tree(node, depth, max_depth):
    """
    Helper that mirrors DependencyGraph._tree but aborts after max_depth levels.
    """
    if depth > max_depth:
        raise RecursionError("Maximum tree depth exceeded")
    children = []
    for child in node['deps'].values():
        children.append(_bounded_tree(child, depth + 1, max_depth))
    return (node['rel'], node['word'], children)

def extract_tree(conll_str, max_depth=1000):
    """
    Build a DependencyGraph from a CoNLL string and return a safely bounded tree.
    """
    dg = DependencyGraph(conll_str)
    # FIX: replace unbounded DependencyGraph._tree with depth‑limited traversal
    return _bounded_tree(dg.nodes[dg.root], 0, max_depth)

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.

  • Fix dependencygraph.py (nltk/nltk)
    nltk/parse/dependencygraph.py, nltk/parse/dependencygraph.py · DependencyGraph.tree, nltk/parse/dependencygraph.py · DependencyGraph.triples, nltk/parse/dependencygraph.py · DependencyGraph._tree

Cite this entry

@misc{vaitp:cve2026129225,
  title        = {{Recursive parsing of malicious dependency graphs can cause stack overflow}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-129225},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129225/}}
}

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.