{"id":"CVE-2021-43854","published":"2021-12-23T17:55:11Z","modified":"2024-08-04T04:10:16Z","title":"Inefficient Regular Expression Complexity in nltk","vendor":"nltk","product":"nltk","tier":"tail","description":{"text":"NLTK (Natural Language Toolkit) is a suite of open source Python modules, data sets, and tutorials supporting research and development in Natural Language Processing. Versions prior to 3.6.5 are vulnerable to regular expression denial of service (ReDoS) attacks. The vulnerability is present in PunktSentenceTokenizer, sent_tokenize and word_tokenize. Any users of this class, or these two functions, are vulnerable to the ReDoS attack. In short, a specifically crafted long input to any of these vulnerable functions will cause them to take a significant amount of execution time. If your program relies on any of the vulnerable functions for tokenizing unpredictable user input, then we would strongly recommend upgrading to a version of NLTK without the vulnerability. For users unable to upgrade the execution time can be bounded by limiting the maximum length of an input to any of the vulnerable functions. Our recommendation is to implement such a limit.","provenance":"source","from":"CVE.org"},"cvss":{"score":7.5,"severity":"HIGH","version":"3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","provenance":"source","from":"CVE.org CNA"},"epss":{"score":0.0279,"percentile":0.86757,"provenance":"source"},"cwes":[{"id":"CWE-400","name":"Uncontrolled Resource Consumption"}],"references":[{"url":"https://github.com/nltk/nltk/security/advisories/GHSA-f8m6-h2c7-8h9x","tags":["x_refsource_CONFIRM"]},{"url":"https://github.com/nltk/nltk/issues/2866","tags":["x_refsource_MISC"]},{"url":"https://github.com/nltk/nltk/pull/2869","tags":["x_refsource_MISC"]},{"url":"https://github.com/nltk/nltk/commit/1405aad979c6b8080dbbc8e0858f89b2e3690341","tags":["x_refsource_MISC"]}],"priority":{"score":22.6,"factors":[{"name":"EPSS percentile","points":17.35},{"name":"CVSS severity","points":5.25}]},"vendorSlug":"nltk","affectedVersions":[{"vendor":"nltk","product":"nltk","versions":["< 3.6.5"]}],"affected":[{"ecosystem":"PyPI","package":"nltk","vulnerableRanges":["<3.6.6","<3.6.5"],"patched":["3.6.6","3.6.5"],"from":["GHSA-f8m6-h2c7-8h9x","PYSEC-2021-859"],"provenance":"source"}],"summary":{"text":"The flaw is an inefficient regular expression complexity (ReDoS) in the nltk Python package, affecting versions prior to 3.6.5 within its PunktSentenceTokenizer class and its sent_tokenize and word_tokenize functions. An attacker who can supply a specially crafted long input to any of these functions can cause them to consume a significant amount of execution time, with no authentication, user interaction, or special configuration required beyond the vulnerable code receiving that input over the network.","provenance":"ai","model":"claude-haiku-5-5","generatedAt":"2026-11-20T06:42:05Z"},"euvd":{"id":"EUVD-2021-0148","exploited":false,"provenance":"source"},"lineage":{"packageHistory":[{"cve":"CVE-2019-14751","published":"2019-08-22","fixed":"3.4.5","kev":false},{"cve":"CVE-2021-3828","published":"2021-09-27","fixed":"3.6.4","kev":false,"link":{"from":"CVE-2021-3828","to":"CVE-2021-43854","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"PyPI:nltk","fromFixed":"3.6.4","toFixed":"3.6.6","daysApart":87}]}},{"cve":"CVE-2021-3842","published":"2022-01-04","fixed":"3.6.6","kev":false,"link":{"from":"CVE-2021-43854","to":"CVE-2021-3842","relation":"successor","confidence":"low","kind":"sequence","evidence":[{"kind":"version-step","provenance":"source","package":"PyPI:nltk","fromFixed":"3.6.5","toFixed":"3.6.6","daysApart":12}]}},{"cve":"CVE-2021-43854","published":"2021-12-23","fixed":"3.6.6","kev":false},{"cve":"CVE-2024-39705","published":"2024-06-27","fixed":"3.9","kev":false},{"cve":"CVE-2025-14009","published":"2026-02-18","fixed":"3.9.3","kev":false},{"cve":"CVE-2025-71408","published":"2026-07-24","fixed":"3.9.3","kev":false}],"package":"PyPI:nltk"}}