Skip to content
Medium 5.3

NLTK: Uncontrolled recursion in semantic-logic type parser causes denial of service via nested type strings

CVE-2026-129226 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 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

  1. 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 reach read_type for each type-string signature value
    (nltk/sem/logic.py:1080) — with a deeply nested type string such as
    "<" * n + "e,e" + ">" * n.
  2. Type.fromstring passes the string straight to read_type wit…

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