CVE-2021-3842: Inefficient Regular Expression Complexity in nltk

nltk Updated 02 Oct 2025

Summary

04/01/2022
Yes i
High
7.5

CVE-2021-3842: nltk is vulnerable to Inefficient Regular Expression Complexity. Affects nltk across 2 version ranges.

< 2a50a3edc9d35f57ae42a921c621edc160877f4d < 3.6.6

Fixed in 2a50a3edc9d35f57ae42a921c621edc160877f4d. How to fix ↓

Also tracked for

The same CVE-2021-3842 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Sponsored Devnack Penetration testing for web, API and mobile Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

nltk is a Python package available on PyPI that provides natural language processing (NLP) functionalities. It is widely used for tasks such as tokenization, stemming, tagging, parsing, and semantic reasoning. The package is designed to assist in the development of NLP applications and research. However, nltk is vulnerable to an issue related to inefficient regular expression complexity.

Vulnerability Detail

The vulnerability in nltk arises from the inefficient complexity of regular expressions used in certain operations. This can lead to excessive backtracking and cause the application to consume significant CPU resources and time when processing certain inputs. An attacker could potentially exploit this vulnerability to launch denial-of-service attacks against applications that utilize nltk for NLP tasks. It is important to note that this vulnerability does not directly lead to remote code execution or data leakage.

How To Fix

Latest published version: 3.10.4 as of 22 Oct 2026

pip install --upgrade "nltk==3.10.4"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2a50a3edc9d35f57ae42a921c621edc160877f4d

This is the first release that contains the fix.

pip install --upgrade "nltk==2a50a3edc9d35f57ae42a921c621edc160877f4d"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Workaround

As a workaround, if immediate upgrade to the fixed version is not feasible, developers can consider implementing input validation and limiting the complexity of regular expressions used in their application's nltk operations. By carefully crafting regular expressions and validating user input, the impact of this vulnerability can be mitigated.

Conclusion

The vulnerability in nltk related to inefficient regular expression complexity can be mitigated by updating to version 3.6.6 or later. Alternatively, implementing input validation and limiting regular expression complexity can serve as a temporary workaround. For further assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for nltk →

Share this vulnerability

FAQ

nltk is a Python package that provides natural language processing (NLP) functionalities.

The vulnerability can lead to excessive CPU resource consumption and time delays, potentially enabling denial-of-service attacks.

No, this vulnerability does not directly lead to remote code execution.

To fix this vulnerability, update nltk to version 3.6.6 or later.

As a workaround, implement input validation and limit the complexity of regular expressions used in nltk operations.

Related vulnerabilities

Recent vulnerabilities recorded for nltk.

How To Fix

Latest published version: 3.10.4 as of 22 Oct 2026

pip install --upgrade "nltk==3.10.4"

Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.

If you need the minimum change

2a50a3edc9d35f57ae42a921c621edc160877f4d

This is the first release that contains the fix.

pip install --upgrade "nltk==2a50a3edc9d35f57ae42a921c621edc160877f4d"

Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback