Executive brief
NLTK is a popular natural language processing library used to analyze and manipulate text data. The Text.findall() method, which searches for patterns in tokenized text, accepts user-supplied regular expressions but runs them without timeout protection or validation. An attacker can submit a specially crafted regex pattern that triggers catastrophic backtracking, consuming 100% CPU indefinitely and preventing legitimate users from accessing the application.
Technical details
The vulnerability is a Regular Expression Denial of Service (ReDoS) in nltk/text.py, specifically in the TokenSearcher.findall() (line 255) and Text.findall() (line 620) methods. The code preprocesses user-supplied regexes by transforming angle brackets and whitespace, but does not validate or reject patterns prone to exponential backtracking. When re.findall() executes the preprocessed regex against the internal token string, a malicious pattern like ((a+)+)b can cause catastrophic backtracking if the input contains no match, forcing the Python regex engine to explore exponentially many paths. This requires no authentication or user interaction; an unauthenticated attacker can trigger the denial of service with a single network request. The patch was released in version 3.10.0 (commit d8e4753), and affected versions are <= 3.9.4.
Affected products
- NLTK Project NLTK <= 3.9.4
Timeline
- 2026-08-12: disclosed: Published to GitHub Advisory Database
- 2026-09-08: advisory: GHSA-rrv8-h7p8-rx55 and CVE-2026-80205 published
- 2026-09-08: patched: Fix available in version 3.10.0