NLTK: Uncontrolled recursion in CCG lexicon parser causes denial of service via deeply nested category input
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-129224 nltk No fixed version in this record
- Ubuntu UBUNTU-CVE-2026-129224 nltk No fixed version in this record
Original description The description as published by the source.
Root Cause
The CCG lexicon parser recurses on nested parenthesised categories without any depth
bound. matchBrackets (nltk/ccg/lexicon.py:154) calls itself once per nested (, and
augParseCategory (nltk/ccg/lexicon.py:228,242) recurses once per bracketed
sub-category. Neither function tracks recursion depth nor checks
sys.getrecursionlimit(), and the public entry point fromstring
(nltk/ccg/lexicon.py:252, also re-exported via nltk.ccg.chart.fromstring) applies no
length or nesting cap before handing the text to the parser.
Impact
An application that parses an untrusted lexicon string aborts with an unhandled
RecursionError, terminating the affected parse operation or request worker
(denial of service, CWE-674). The recursion is pure Python, so CPython raises a catchable
RecursionError rather than crashing the process; there is no memory-corruption or
code-execution primitive. Confidentiality and integrity are unaffected. Plausibly, a
service that does not wrap the parse in a handler will surface the error to the caller and
drop the in-flight request.
Attack Chain
- The application calls
nltk.ccg.lexicon.fromstring(lex_str)with attacker-supplied
text such as":- S\nw => " + "(" * 2000 + "S" + ")" * 2000 + "\n". fromstringsplits the input into lines;LEX_RE/RHS_RE
(nltk/ccg/lexicon.py:275-276) match and route the parenthesised category into
augParseCategory(nltk/ccg/lexicon.py:277) with no depth or length guard.
3.…
Source: CVE.org (CVE Program・cvelistV5) NVD GitHub Advisory
References
- advisory github.com
- package github.com
- REDHAT Red Hat
- web github.com
- web github.com
- web github.com
- web github.com
- web nvd.nist.gov
- web github.com