Skip to content
Medium 5.3

NLTK: Uncontrolled recursion in DependencyGraph traversal causes denial of service via deep dependency chains

CVE-2026-129225 First seen on SecPulse

Affected packages

PackageAffected → Fixed
nltknltk —
PyPInltk
< 3.10.4→ 3.10.4
pipnltk
< 3.10.4→ 3.10.4

Fix status by distribution

Records published by each distribution for this CVE. Fixed versions differ by release; check each link.

Original description The description as published by the source.

Root Cause

The dependency-graph traversal helpers recurse over dependency links without any depth
bound or visited set. DependencyGraph._tree (nltk/parse/dependencygraph.py:404)
recurses once per dependency link, triples (nltk/parse/dependencygraph.py:432) is a
recursive generator, and get_cycle_path (nltk/parse/dependencygraph.py:520) recurses
over dependencies. The neighbouring contains_cycle method was deliberately rewritten as
an iterative depth-first search, but these sibling helpers on the public traversal path
were left recursive with no depth counter.

Impact

An application that parses an untrusted CoNLL/Malt-TAB dependency structure and then walks
it via tree() or triples() aborts with an unhandled RecursionError, terminating the
affected operation or request worker (denial of service, CWE-674). The recursion is pure
Python, so the result is a catchable RecursionError, not memory corruption or code
execution. Confidentiality and integrity are unaffected. get_cycle_path additionally
lacks a visited set and will not terminate on a genuine cycle.

Attack Chain

  1. The application constructs DependencyGraph(conll_str) from attacker-supplied text
    where token k's head is token k+1, forming a linear dependency chain of length N.
    Graph construction (_parse) is iterative and completes without error.
  2. The application calls the public DependencyGraph.tree()
    (nltk/parse/dependencygraph.py:408), which invokes _tree(root).…

Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory

References

We use cookies for analytics and ad measurement. This setting applies to all Game co., Ltd. sites. Details