Skip to main content

CVE-2026-12876 — NLTK: Uncontrolled resource consumption in nltk

MEDIUM

NLTK: Uncontrolled resource consumption in RecursiveDescentParser via ambiguous or left-recursive grammars

Published September 2, 2026Updated September 10, 2026Source: OSV

Does your project use an affected nltk version?

Paste your requirements.txt to check it for CVE-2026-12876 and every other known vulnerability, with CISA KEV and EPSS on each finding. Free with no signup for up to 10 packages, or up to 500 per scan with a free account, which also keeps up to 200 packages in saved projects.

Check my requirements.txt

Summary

nltk.parse.RecursiveDescentParser (and SteppingRecursiveDescentParser) enumerate parses top-down with no bound on the number of recursive steps. A small, crafted context-free grammar makes a short input consume unbounded CPU (and/or exhaust the Python recursion stack), pinning a process indefinitely — a denial of service.

Proof of concept

Both of the following hang on a 24-token input (killed after 8s; growth is super-linear in input length), on NLTK develop:

from nltk import CFG
from nltk.parse import RecursiveDescentParser

# (a) left recursion -> unbounded recursion
g = CFG.fromstring("S -> S S | 'a'")
list(RecursiveDescentParser(g).parse(["a"] * 24))   # hangs

# (b) ambiguous grammar -> exponential number of parses
g = CFG.fromstring("S -> 'a' S | 'a' S S | 'a'")
list(RecursiveDescentParser(g).parse(["a"] * 24))   # hangs

Impact

An application that runs RecursiveDescentParser on a grammar (or an input) drawn from an untrusted source can be driven into an unbounded CPU / stack-exhaustion loop by a tiny payload. No confidentiality or integrity impact; single-process availability only.

Sibling

The RegexpTokenizer ReDoS reported alongside this (CVE-2026-12875) is a different class (caller-supplied regex) and is addressed under GHSA-w3v8-gmh9-3wv7.

Advisory Timeline

  • First published September 2, 2026 (85 days ago).
  • Last revised September 10, 2026 — 8 days after initial publication.

Remediation

Upgrade to the fixed version using your package manager.

pip
Update nltk to 3.10.3 or later
pip install "nltk>=3.10.3"

After upgrading, scan your dependencies again to confirm the vulnerability is resolved.

Affected Packages (1)

Affects 1 ecosystem: PyPI (1).

PackageFixed In
nltk PyPI · Affected: 0.8, 0.9, 0.9.3, 0.9.4 (+64 more)3.10.3

Vulnerability Classification

Common Weakness Enumeration (CWE) identifiers for this vulnerability type.

CVSS Score Breakdown

What the CVSS (Common Vulnerability Scoring System) 5.3 score means for each attack dimension.

Attack Vector
Network
Attack Complexity
Low
Privileges Required
None
User Interaction
None
Scope
—
Confidentiality
—
Integrity
—
Availability
—

CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N

Frequently Asked Questions

What is CVE-2026-12876?
NLTK: Uncontrolled resource consumption in RecursiveDescentParser via ambiguous or left-recursive grammars. This vulnerability has been assigned a severity rating of MEDIUM (CVSS score: 5.3/10).
How do I check if my project is affected by CVE-2026-12876?
CVE-2026-12876 affects nltk. Use GeekWala's free vulnerability scanner to check your dependencies against CVE-2026-12876 and 200,000+ other known vulnerabilities.

Severity & Exploitability

CVSS Score
5.3

Exploitation requires specific conditions, or the impact is limited.

Also Known As

GHSA-ff5c-cp5c-9wjf
PYSEC-2026-3869

Related CVEs

Check your own dependencies

Free, with no signup for up to 10 packages.

Check my requirements.txt