Skip to content
FlawDB
Sign in
Archived entry. Full-text search covers entries since 2026-11-10; exact IDs work for all years.

CVE-2026-12876

MEDIUM

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

Also known as GHSA-ff5c-cp5c-9wjf, PYSEC-2026-3869

Mitigation

  • Upgrade nltk to 3.10.3 or later.

Who should check

  • Projects that depend on PyPI package nltk (< 3.10.3)

Vulnerability facts

Affected
nltk < 3.10.3
Fixed in
3.10.3
Exploited in the wild
Not in CISA KEV
Public exploit / PoC
None known
Remote exploitation
Unknown
CVSS
Not scored yet
CWE
CWE-407, CWE-674
Published
Modified

Description

`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: ```python 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.

Affected and fixed versions

Package / productAffectedFixedSource
PyPI nltk< 3.10.33.10.3osv

Check your systems with an agent

Paste this into Claude Code, Cursor or another coding agent. It only reads; it changes nothing.

Check whether anything I run is affected by CVE-2026-12876. Work read-only: do not install, upgrade, delete or change anything.

Details: https://flawdb.com/CVE-2026-12876.md
Affected: nltk < 3.10.3
Fixed in: 3.10.3

Steps:
1. Search this machine and project for nltk (PyPI): dependency manifests and lockfiles, installed packages, container images and running services.
2. For each match, note the installed version and whether it is inside the affected range.
3. Report a table: location, installed version, affected (yes / no / unsure), evidence. If affected, say which fixed version or mitigation from the details link applies, but don't apply it.

References

FAQ

Is CVE-2026-12876 being exploited?

There is no confirmed exploitation: CVE-2026-12876 is not in the CISA Known Exploited Vulnerabilities catalog. No public exploit code is known.

How serious is CVE-2026-12876?

It has no CVSS score yet. Unknown.

Which versions are affected by CVE-2026-12876?

nltk < 3.10.3.

Is there a fix for CVE-2026-12876?

Yes. Fixed in 3.10.3. Upgrade nltk to 3.10.3 or later.

How do I check if I'm affected by CVE-2026-12876?

Find where you use the affected software (dependency lockfiles, installed packages, container images, servers) and compare the installed version with the affected range above. The agent prompt on this page does this read-only.

Sponsors