{"vuln_id":"CVE-2026-129222","aliases":["GHSA-rh8m-wqhc-qmrf"],"description":"Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in DependencyGraph.tree()/triples()","published_at":"2026-11-19T18:18:07.133000Z","modified_at":"2026-11-22T21:00:05.695799Z","first_seen_at":"2026-11-21T19:15:19.352560Z","severity":"high","severity_source":"nvd","cvss_score":7.5,"cvss_vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","cwe":["CWE-674"],"vendor":null,"product":null,"kev":{"is_kev":false,"date_added":null,"due_date":null,"ransomware":false},"epss":0.00568,"epss_percentile":0.4797,"nvd_status":"Awaiting Analysis","enriched_at":null,"links":{"nvd":"https://nvd.nist.gov/vuln/detail/CVE-2026-129222"},"matched_alias":null,"items":[{"id":10705,"source":{"id":"osv","name":"OSV.dev"},"title":"GHSA-rh8m-wqhc-qmrf: Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in DependencyGraph.tree()/triples()","summary":"Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in DependencyGraph.tree()/triples()\n\n### Summary\nDependencyGraph.tree()/triples() walk the parsed dependency structure using plain, unbounded Python recursion — one stack frame per edge in the graph — and never use the class's own cycle detector. A crafted dependency-parse file with a few thousand chained tokens (an entirely ordinary-looking long sentence) crashes the process with an unhandled RecursionError the moment .tree() or .triples() is called — which is NLTK's own documented usage pattern immediately after loading such a file.\n\n### Details\n`DependencyGraph._tree()` (~lines 393-406), `.tree()` (~408-417), and `.triples()` (~419-432) in `nltk/parse/dependencygraph.py` rebuild/walk the graph with `Tree(word, [self._tree(dep) for dep in deps])` and `yield from self.triples(node=dep)` — ordinary recursive calls, one per edge, with no depth check. `contains_cycle()` is defined on the class (~line 447) but is never invoked by any of these three methods.\n\nThis is exactly the CWE-674 pattern the project has already identified and fixed elsewhere: `nltk/tree/tree.py` adds `MAX_TREE_DEPTH = 500` with a comment stating that an arbitrarily deep tree would make every traversal raise RecursionError, and `nltk/test/unit/test_recursion_dos.py` locks in the identical fix for `FeatStructReader`, `LogicParser`, and `ResolutionProver`. But `DependencyGraph` builds its `Tree` objects **programmatically** (`Tree(word, [...])`), which bypasses `MAX_TREE_DEPTH` entirely — that guard only fires inside `Tree.fromstring()`'s bracket-string parser, never in `Tree.__init__`. `DependencyGraph`'s own recursive walk has no depth limit of its own.\n\nAny Malt-TAB/CoNLL(3/4/7/10)-format text — read via `DependencyCorpusReader` (`nltk/corpus/reader/dependency.py`, lines 62-69, backing the public, documented `nltk.corpus.dependency_treebank` and `nltk.corpus.conll2007` corpora) or via the public classmethod `DependencyGraph.load(filename)` (~line 213) / `DependencyGraph(text)` directly — that chains more tokens than Python's default recursion limit (1000) via consecutive head references crashes with an unhandled `RecursionError` the moment `.tree()`/`.triples()` is called. Calling `.tree()` immediately after `parsed_sents()` is not a contrived edge case — it is NLTK's own documented usage pattern (`nltk/test/corpus.doctest`: `print(conll2007.parsed_sents('esp.train')[0].tree())`; `nltk/test/dependency.doctest`: `dg.tree().pprint()`).\n\n**Related observation:** `contains_cycle()` itself has a separate bug that means it wouldn't help even if it were called on this path — it iterates `node[\"deps\"]` as if it were a flat list of neighbor addresses, but `_parse()`/`add_arc()` actually store `deps` as `{relation_label: [addresses]}`; iterating that dict yields relation-label strings, which then fail the `dep not in self.nodes` check and get silently skipped. So `contains_cycle()` returns `False` (a false negative) on real parsed/`add_arc()`-built graphs even when a genuine cycle exists — it only works on the flat-list sh\n\nAffected: PyPI:nltk\n\nFixed in: 3.10.4\n\nReferences:\nhttps://github.com/nltk/nltk/security/advisories/GHSA-rh8m-wqhc-qmrf\nhttps://nvd.nist.gov/vuln/detail/CVE-2026-129222\nhttps://github.com/nltk/nltk/pull/3885\nhttps://github.com/nltk/nltk/commit/a74682757cee8c11128ad277d2f2bd0b8e1884ff\nhttps://github.com/nltk/nltk\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4","url":"https://osv.dev/vulnerability/GHSA-rh8m-wqhc-qmrf","published_at":"2026-11-19T23:53:41Z","updated_at":"2026-11-20T00:00:04.065535Z","fetched_at":"2026-11-21T19:15:55.946118Z","severity":"high","cvss_score":7.5,"epss":0.00568,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-129222","vuln_ids":["CVE-2026-129222","GHSA-RH8M-WQHC-QMRF"],"tags":["osv","pypi","fix-available"],"cluster_id":2141,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/10705","html":"https://vulnwatch.ve1ve2.com/item/10705"}},{"id":2355,"source":{"id":"ghsa","name":"GitHub Security Advisories"},"title":"GHSA-rh8m-wqhc-qmrf / CVE-2026-129222: Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in DependencyGraph.tree()/triples()","summary":"Natural Language Toolkit (NLTK): Uncontrolled recursion (crash DoS) in DependencyGraph.tree()/triples()\n\n### Summary\nDependencyGraph.tree()/triples() walk the parsed dependency structure using plain, unbounded Python recursion — one stack frame per edge in the graph — and never use the class's own cycle detector. A crafted dependency-parse file with a few thousand chained tokens (an entirely ordinary-looking long sentence) crashes the process with an unhandled RecursionError the moment .tree() or .triples() is called — which is NLTK's own documented usage pattern immediately after loading such a file.\n\n### Details\n`DependencyGraph._tree()` (~lines 393-406), `.tree()` (~408-417), and `.triples()` (~419-432) in `nltk/parse/dependencygraph.py` rebuild/walk the graph with `Tree(word, [self._tree(dep) for dep in deps])` and `yield from self.triples(node=dep)` — ordinary recursive calls, one per edge, with no depth check. `contains_cycle()` is defined on the class (~line 447) but is never invoked by any of these three methods.\n\nThis is exactly the CWE-674 pattern the project has already identified and fixed elsewhere: `nltk/tree/tree.py` adds `MAX_TREE_DEPTH = 500` with a comment stating that an arbitrarily deep tree would make every traversal raise RecursionError, and `nltk/test/unit/test_recursion_dos.py` locks in the identical fix for `FeatStructReader`, `LogicParser`, and `ResolutionProver`. But `DependencyGraph` builds its `Tree` objects **programmatically** (`Tree(word, [...])`), which bypasses `MAX_TREE_DEPTH` entirely — that guard only fires inside `Tree.fromstring()`'s bracket-string parser, never in `Tree.__init__`. `DependencyGraph`'s own recursive walk has no depth limit of its own.\n\nAny Malt-TAB/CoNLL(3/4/7/10)-format text — read via `DependencyCorpusReader` (`nltk/corpus/reader/dependency.py`, lines 62-69, backing the public, documented `nltk.corpus.dependency_treebank` and `nltk.corpus.conll2007` corpora) or via the public classmethod `DependencyGraph.load(filename)` (~line 213) / `DependencyGraph(text)` directly — that chains more tokens than Python's default recursion limit (1000) via consecutive head references crashes with an unhandled `RecursionError` the moment `.tree()`/`.triples()` is called. Calling `.tree()` immediately after `parsed_sents()` is not a contrived edge case — it is NLTK's own documented usage pattern (`nltk/test/corpus.doctest`: `print(conll2007.parsed_sents('esp.train')[0].tree())`; `nltk/test/dependency.doctest`: `dg.tree().pprint()`).\n\n**Related observation:** `contains_cycle()` itself has a separate bug that means it wouldn't help even if it were called on this path — it iterates `node[\"deps\"]` as if it were a flat list of neighbor addresses, but `_parse()`/`add_arc()` actually store `deps` as `{relation_label: [addresses]}`; iterating that dict yields relation-label strings, which then fail the `dep not in self.nodes` check and get silently skipped. So `contains_cycle()` returns `False` (a false negative) on real parsed/`add_arc()`-built graphs even when a genuine cycle exists — it only works on the flat-list sh\n\nAffected packages: pip:nltk\nPatched: nltk 3.10.4","url":"https://github.com/advisories/GHSA-rh8m-wqhc-qmrf","published_at":"2026-11-19T23:53:41Z","updated_at":"2026-11-19T23:53:42Z","fetched_at":"2026-11-21T19:15:18.416773Z","severity":"high","cvss_score":7.5,"epss":0.00568,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":"nltk","vuln_id":"CVE-2026-129222","vuln_ids":["CVE-2026-129222","GHSA-RH8M-WQHC-QMRF"],"tags":["ghsa","pip","CWE-674"],"cluster_id":2141,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/2355","html":"https://vulnwatch.ve1ve2.com/item/2355"}},{"id":15180,"source":{"id":"osv","name":"OSV.dev"},"title":"DEBIAN-CVE-2026-129222: NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Proc…","summary":"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, DependencyGraph.tree and DependencyGraph.triples walk parsed dependency edges through unbounded Python recursion and do not use a working cycle or depth guard. A crafted CoNLL or Malt-TAB dependency file containing a sufficiently long chain can raise RecursionError when the documented traversal APIs are called, aborting the current worker. This issue is fixed in version 3.10.4.\n\nAffected: Debian:12:nltk, Debian:13:nltk, Debian:14:nltk\n\nNo fixed version published yet\n\nReferences:\nhttps://security-tracker.debian.org/tracker/CVE-2026-129222","url":"https://osv.dev/vulnerability/DEBIAN-CVE-2026-129222","published_at":"2026-11-19T18:18:07.133000Z","updated_at":"2026-11-22T21:00:05.695799Z","fetched_at":"2026-11-23T03:05:53.019743Z","severity":"high","cvss_score":7.5,"epss":0.00568,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":"debian","product":"12:nltk","vuln_id":"CVE-2026-129222","vuln_ids":["CVE-2026-129222","DEBIAN-CVE-2026-129222","GHSA-RH8M-WQHC-QMRF"],"tags":["osv","debian","no-fix-yet"],"cluster_id":2142,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/15180","html":"https://vulnwatch.ve1ve2.com/item/15180"}},{"id":9035,"source":{"id":"nvd","name":"NVD CVE API 2.0"},"title":"CVE-2026-129222: NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Proc…","summary":"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, DependencyGraph.tree and DependencyGraph.triples walk parsed dependency edges through unbounded Python recursion and do not use a working cycle or depth guard. A crafted CoNLL or Malt-TAB dependency file containing a sufficiently long chain can raise RecursionError when the documented traversal APIs are called, aborting the current worker. This issue is fixed in version 3.10.4.\n\nReferences:\nhttps://github.com/nltk/nltk/commit/a74682757cee8c11128ad277d2f2bd0b8e1884ff\nhttps://github.com/nltk/nltk/pull/3885\nhttps://github.com/nltk/nltk/releases/tag/v3.10.4\nhttps://github.com/nltk/nltk/security/advisories/GHSA-rh8m-wqhc-qmrf","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-129222","published_at":"2026-11-19T18:18:07.133000Z","updated_at":"2026-11-19T21:17:48.660000Z","fetched_at":"2026-11-21T19:15:31.484688Z","severity":"high","cvss_score":7.5,"epss":0.00568,"is_kev":false,"has_exploit":false,"kev_due_date":null,"vendor":null,"product":null,"vuln_id":"CVE-2026-129222","vuln_ids":["CVE-2026-129222","GHSA-RH8M-WQHC-QMRF"],"tags":["CWE-674"],"cluster_id":2142,"links":{"self":"https://vulnwatch.ve1ve2.com/api/v1/items/9035","html":"https://vulnwatch.ve1ve2.com/item/9035"}}]}