VAITP Dataset

← Back to the dataset

CVE-2026-129230

RecursionError via uncontrolled WordNet hypernym graph traversal in NLTK, causing API crashes

  • CVSS 5.5
  • CWE-400
  • 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.max_depth, min_depth, hypernym_paths, and hypernym_distances recursively follow attacker-controlled corpus pointers without a visited-node set or depth cap. A cyclic or excessively deep hypernym graph can raise RecursionError and terminate traversal APIs and similarity operations that depend on them. This issue is fixed in version 3.10.4.

CVSS base score
5.5
Published
2026-11-19
OWASP
A04 Insecure Design
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 nltk
from nltk.corpus import wordnet as wn

def max_hypernym_depth(synset):
    # VULNERABLE: unbounded recursion on cyclic hypernym graph
    if not synset.hypernyms():
        return 0
    return 1 + max(max_hypernym_depth(h) for h in synset.hypernyms())

def example():
    # trigger recursion on a crafted synset graph (e.g., via custom corpus)
    syn = wn.synset('entity.n.01')
    return max_hypernym_depth(syn)

Patched code sample

import nltk
from nltk.corpus import wordnet as wn

def max_hypernym_depth(synset, _visited=None):
    # FIX: track visited nodes to prevent infinite recursion
    if _visited is None:
        _visited = set()
    if synset in _visited:
        return 0
    _visited.add(synset)
    if not synset.hypernyms():
        return 0
    return 1 + max(max_hypernym_depth(h, _visited) for h in synset.hypernyms())

def example():
    syn = wn.synset('entity.n.01')
    return max_hypernym_depth(syn)

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.

  • Bound WordNet hypernym recursion and linearize the lemma-marker regex (nltk/nltk)
    nltk/corpus/reader/wordnet.py, nltk/corpus/reader/wordnet.py · Synset.hypernym_distances, nltk/corpus/reader/wordnet.py · Synset.hypernym_paths, nltk/corpus/reader/wordnet.py · Synset.max_depth, nltk/corpus/reader/wordnet.py · Synset.min_depth, nltk/corpus/reader/wordnet.py · WordNetCorpusReader._synset_from_pos_and_line

Cite this entry

@misc{vaitp:cve2026129230,
  title        = {{RecursionError via uncontrolled WordNet hypernym graph traversal in NLTK, causing API crashes}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-129230},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-129230/}}
}

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.