Junglewise Threat Intelligence

CVE-2026-12876: NLTK RecursiveDescentParser uncontrolled recursion denial of service

CVE-2026-12876 · Severity: medium · CVSS 6.9 · Published 2026-09-02

Executive brief

NLTK is a widely-used Python library for natural language processing that includes parsers for analyzing text based on grammars. The RecursiveDescentParser component fails to limit recursive operations when processing certain ambiguous or left-recursive grammars, allowing an attacker to supply a tiny crafted grammar or input that causes the parser to consume unbounded CPU cycles and exhaust the Python call stack, permanently blocking the affected process. This is a single-process availability attack with no data breach or system integrity risk.

Technical details

The RecursiveDescentParser (and SteppingRecursiveDescentParser) in NLTK enumerate parse trees top-down with no upper bound on the number of recursive steps (CWE-407, CWE-674). Two attack patterns are demonstrated: (a) left-recursive grammars (e.g., "S -> S S | 'a'") trigger unbounded recursion depth; (b) ambiguous grammars (e.g., "S -> 'a' S | 'a' S S | 'a'") cause exponential enumeration of parse trees. Both hang on a 24-token input with super-linear growth in input length. Attack vector is network-capable if the grammar or input is drawn from an untrusted source. The fix (in NLTK 3.10.3+) adds a wall-clock max_time limit (default 5 seconds) checked on every recursive _parse entry, protecting by default while allowing opt-out via max_time=None.

Affected products

  • NLTK Project NLTK <= 3.10.2

Timeline

  • 2026-08-12: disclosed: Published to GitHub Advisory Database
  • 2026-08-12: patched: Fix committed; NLTK 3.10.3 released
  • 2026-09-02: advisory: Advisory GHSA-ff5c-cp5c-9wjf published

References

Related threats