NLTK: Uncontrolled recursion in semantic-logic type parser causes denial of service via nested type strings
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-129226 nltk No fixed version in this record
- Ubuntu UBUNTU-CVE-2026-129226 nltk No fixed version in this record
Original description The description as published by the source.
Root Cause
The semantic-logic type parser read_type (nltk/sem/logic.py:866) recurses on both
halves of every `` complex type (nltk/sem/logic.py:882-884) with no depth or length
bound — only an isinstance assertion and a parenthesis-balance assertion. The
LogicParser.MAX_PARSE_DEPTH guard (nltk/sem/logic.py:107,294) protects the expression
parser but never runs on the read_type path, which is reached directly by the public
Type.fromstring classmethod and by signature-string type checking.
Impact
An application that parses an untrusted type string, or type-checks an expression against
an attacker-influenced signature, aborts with an unhandled RecursionError, terminating
the affected operation or request worker (denial of service, CWE-674). The recursion is
pure Python, yielding a catchable RecursionError rather than memory corruption or code
execution. Confidentiality and integrity are unaffected. Exposure is narrower than a
general-purpose parser because the input must reach a type-string or signature parameter.
Attack Chain
- The application calls
nltk.sem.logic.Type.fromstring(s)(nltk/sem/logic.py:736) — or
Expression.typecheck(signature)/Expression.fromstring(expr, type_check=True, signature=...), which reachread_typefor each type-string signature value
(nltk/sem/logic.py:1080) — with a deeply nested type string such as
"<" * n + "e,e" + ">" * n. Type.fromstringpasses the string straight toread_typewit…
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 github.com
- web nvd.nist.gov
- web github.com