# CVE-2021-43854: Inefficient Regular Expression Complexity in nltk

- Severity: High 7.5 (CVSS:3.1, scored by GitHub_M) `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Likelihood of exploitation in the next 30 days (EPSS): 2.79%, higher than 86% of CVEs (2026-12-01)
- Public exploit code or proof of concept: 3 links below, marked "exploit"
- Published: 2021-12-23T17:55:11.000Z
- Modified: 2026-07-08T06:28:12.494Z
- Also known as: GHSA-f8m6-h2c7-8h9x, PYSEC-2021-859
- Weaknesses: CWE-400
- Assigned by: GitHub_M

## Description

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.

(As written by CVE List.)

## Affected

- nltk nltk: < 3.6.5; before 3.6.5
- nltk (PyPI): before 3.6.6; before 1405aad979c6b8080dbbc8e0858f89b2e3690341; before 3.6.5

## Every score

- GitHub_M: CVSS:3.1 7.5 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- GitHub: CVSS:3.1 7.5 High `CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H`
- GitHub: CVSS:4.0 High `CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N`
- NVD: CVSS:2.0 5.0 Medium `AV:N/AC:L/Au:N/C:N/I:N/A:P`

## References

- <https://github.com/nltk/nltk/security/advisories/GHSA-f8m6-h2c7-8h9x> (exploit, advisory, patch, third-party-advisory, web)
- <https://github.com/nltk/nltk/issues/2866> (exploit, issue-tracking, patch, report, third-party-advisory, web)
- <https://github.com/nltk/nltk/pull/2869> (exploit, patch, third-party-advisory, web)
- <https://github.com/nltk/nltk/commit/1405aad979c6b8080dbbc8e0858f89b2e3690341> (fix, patch, third-party-advisory, web)
- <https://nvd.nist.gov/vuln/detail/CVE-2021-43854> (advisory)
- <https://github.com/nltk/nltk> (package)
- <https://github.com/pypa/advisory-database/tree/main/vulns/nltk/PYSEC-2021-859.yaml> (web)

## Sources

- CVE List: [CVE-2021-43854](https://www.cve.org/CVERecord?id=CVE-2021-43854), CVE Terms of Use, modified 2024-08-04
- GitHub Advisory Database: [GHSA-f8m6-h2c7-8h9x](https://github.com/advisories/GHSA-f8m6-h2c7-8h9x), CC-BY-4.0, modified 2026-07-08
- NVD: [CVE-2021-43854](https://nvd.nist.gov/vuln/detail/CVE-2021-43854), Public domain, modified 2026-06-17
- PyPA Advisory Database: [PYSEC-2021-859](https://osv.dev/vulnerability/PYSEC-2021-859), CC-BY-4.0, modified 2023-11-08

---

Page: https://cve.day/CVE-2021-43854 · Whole record: https://cve.day/CVE-2021-43854.json · Rebuilt by cve.day 2026-11-25T22:24:36.367Z
