VAITP Dataset

← Back to the dataset

CVE-2026-129223

Recursive WordNet traversal can cause stack overflow via deep resources

  • CVSS 7.5
  • 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. Prior to 3.10.4, WordNet Synset.tree and acyclic_tree traverse relation graphs through recursive utility helpers without a depth bound. Exploitation requires the host application to load an attacker-influenced custom or foreign WordNet-format lexical resource; no relation in NLTK's bundled WordNet 3.0 corpus reaches the crash threshold. An excessively deep relation graph in such a resource can exceed the Python recursion limit and terminate the traversal or request worker. This issue is fixed in version 3.10.4.

CVSS base score
7.5
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 newer.

Vulnerable code sample

import nltk
from nltk.corpus import wordnet as wn

def get_synset_tree(name: str):
    """Return the hypernym tree for a WordNet synset."""
    syn = wn.synset(name)
    # VULNERABLE: unbounded recursion in Synset.tree()
    return syn.tree()

Patched code sample

import nltk
from nltk.corpus import wordnet as wn

def _bounded_tree(syn, max_depth, _current=0):
    if _current >= max_depth:
        return []
    result = [syn]
    for hyper in syn.hypernyms():
        result.extend(_bounded_tree(hyper, max_depth, _current + 1))
    return result

def get_synset_tree(name: str):
    """Return the hypernym tree for a WordNet synset with depth limit."""
    syn = wn.synset(name)
    # FIX: bound recursion depth to prevent exhaustion
    return _bounded_tree(syn, max_depth=1000)

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.

  • Merge commit from fork (nltk/nltk)
    nltk/util.py, nltk/util.py · acyclic_branches_depth_first, nltk/util.py · acyclic_depth_first, nltk/util.py · acyclic_dic2tree

Cite this entry

@misc{vaitp:cve2026129223,
  title        = {{Recursive WordNet traversal can cause stack overflow via deep resources}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-129223},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129223/}}
}

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.