Uncontrolled Recursion Affecting nltk package, versions [,3.10.4)


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.61% (44th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Uncontrolled Recursion vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PYTHON-NLTK-22733191
  • published22 Nov 2026
  • disclosed19 Nov 2026
  • creditYazan Balawneh

Introduced: 19 Nov 2026

NewCVE-2026-129223  (opens in a new tab)
CWE-674  (opens in a new tab)

How to fix?

Upgrade nltk to version 3.10.4 or higher.

Overview

nltk is a Natural Language Toolkit (NLTK) is a Python package for natural language processing.

Affected versions of this package are vulnerable to Uncontrolled Recursion via acyclic_depth_first() and acyclic_branches_depth_first() in nltk/util.py, which are called by Synset.tree() and Synset.acyclic_tree() in nltk/corpus/reader/wordnet.py. Both functions recurse once per graph edge and default to depth=-1 (unlimited). Although they maintain a traversed set to prevent revisiting nodes, this only blocks literal cycles and does not bound the number of distinct nodes a single call chain may pass through. A long but genuinely acyclic relation chain exhausts the Python call stack, producing an unhandled RecursionError crash.

Note: This is only exploitable when the host application loads a custom or foreign WordNet-format lexical resource via WordNetCorpusReader and calls .tree() or .acyclic_tree() with the default unbounded depth; the standard bundled WordNet 3.0 corpus has no relation chain long enough to reach the crash threshold.

PoC

Generated a syntactically valid, minimal, real Princeton-WordNet-DB-format lexical database (`data.noun`/`index.noun`/`lexnames`/etc., with correct byte-offset-indexed synset records) encoding a 1500-node strictly-linear (genuinely acyclic) hypernym chain. Loaded it via the real, unmodified `WordNetCorpusReader(root, None)`, obtained a real `Synset`, and called the real, documented, public `synset.tree(lambda s: s.hypernyms())` — crashed with an uncaught `RecursionError: maximum recursion depth exceeded`, as did `synset.acyclic_tree(...)`. `synset.closure(...)` on the identical data returned cleanly (1499 nodes, no crash), confirming the closure()/tree() distinction above.

CVSS Base Scores

version 4.0
version 3.1