Executive brief
NLTK is a widely-used Python library for natural language processing, with the PorterStemmer being a common component for text analysis in search, indexing, and machine learning pipelines. A flaw in the stemmer causes it to consume excessive CPU when processing specially crafted text inputs containing many repeated 'y' characters, allowing attackers to disrupt service availability by submitting malicious tokens that lock up the server.
Technical details
The vulnerability is an inefficient algorithmic complexity issue (CWE-407) in the PorterStemmer.stem() method, specifically in the _is_consonant() helper function. The _is_consonant() function iteratively walks backward over the entire run of trailing 'y' characters on every invocation, and _measure() calls _is_consonant() for each stem position, resulting in O(n²) behavior. An attacker can craft a 20–50 KB untrusted token consisting of a long run of 'y' characters followed by a suffix like 'ness' to trigger _measure() on the long stem, pinning a CPU core for seconds to minutes. The fix involves memoizing character consonant/vowel status in a single left-to-right O(n) pass rather than re-walking the run on each call. This is a network-reachable vulnerability requiring no authentication or user interaction, as PorterStemmer.stem() is a public API routinely applied to untrusted text. Patched in version 3.10.3.
Affected products
- NLTK NLTK <= 3.10.2
Timeline
- 2026-08-27: disclosed: Advisory published by GitHub (GHSA-ww6m-cw3f-q94g)
- 2026-08-27: patched: Fixed in version 3.10.3
- 2026-09-02: other: Duplicate advisory GHSA-8x48-8g7j-rqxp withdrawn