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

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

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.

Technologies: nltk (PyPI). Vendors: PyPI.

Quick answers

Is CVE-2026-12876 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-12876 being exploited in the wild.
How severe is CVE-2026-12876?
Medium severity, with a CVSS score of 4, published 2 September 2026.
Which products and versions are affected?
nltk (PyPI) <= 3.10.2, ECOSYSTEM:introduced=0,fixed=3.10.3.
Is there a fix for CVE-2026-12876?
Yes. nltk (PyPI): upgrade to 3.10.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-12876 attacked?
It is attacked over the network.
Am I affected by CVE-2026-12876?
Check whether you run nltk (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

How to fix

  • nltk (PyPI): upgrade to 3.10.3 or later
    pip install "nltk>=3.10.3"

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

Identifiers

  • CVE-2026-12876
  • GHSA-ff5c-cp5c-9wjf
  • PYSEC-2026-3869

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

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.