NLTKのDependencyGraphに脆弱性、細工したファイルでプロセスが停止するおそれ
Summary
NLTKのDependencyGraph.tree()とtriples()には、再帰処理の上限がないため、細工したCoNLLまたはMalt-TABの依存関係ファイルを読み込むとRecursionErrorが発生し、実行中のプロセスが停止するおそれがあります。影響を受けるのは3.10.4より前のバージョンで、3.10.4で修正されています。CVSSは7.5で、利用中のバージョンを確認し、3.10.4以降へ更新してください。
AI summary
Produced by SecPulse using an external AI model; it may contain mistakes. Check the original description and references below before acting on it.
NLTKのDependencyGraph.tree()とtriples()には、再帰処理の上限がないため、細工したCoNLLまたはMalt-TABの依存関係ファイルを読み込むとRecursionErrorが発生し、実行中のプロセスが停止するおそれがあります。影響を受けるのは3.10.4より前のバージョンで、3.10.4で修正されています。CVSSは7.5で、利用中のバージョンを確認し、3.10.4以降へ更新してください。
Affected packages
| Package | Affected → Fixed | |
|---|---|---|
| nltknltk | — | Not listed |
| PyPInltk |
< 3.10.4→ 3.10.4 |
3.10.4 |
| pipnltk |
< 3.10.4→ 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.
- Debian DEBIAN-CVE-2026-129222 nltk No fixed version in this record
- Ubuntu UBUNTU-CVE-2026-129222 nltk No fixed version in this record
Original description The description as published by the source.
Summary
DependencyGraph.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.
Details
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.
This 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 bracke…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- package github.com
- web github.com
- web github.com
- web github.com
- web github.com
- web nvd.nist.gov
- web github.com