CVE-2021-3828: Inefficient Regular Expression in nltk

nltk Updated 02 Oct 2025

Summary

29/09/2021
Yes i
High
7.5

CVE-2021-3828: NLTK Vulnerable to REDoS. Affects nltk versions < 3.6.4. Fixed in 3.6.4. How to fix ↓

Also tracked for

The same CVE-2021-3828 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 MarkAI Find prospects already talking about the problem you solve AI watches the communities your customers use to find qualified prospects, then alerts you when a conversation is worth joining. See MarkAI

Background

The nltk package is a Python library used for natural language processing tasks. It provides various functionalities for tokenization, stemming, tagging, parsing, and more. The package is widely used in applications that require text analysis and processing. However, nltk is vulnerable to regular expression denial of service attacks due to an inefficient regular expression implementation.

Vulnerability Detail

The vulnerability in nltk arises from an inefficient regular expression used in the nltk.corpus.reader.comparative_sents.KEYWORD function. This vulnerability can be exploited by an attacker to launch regular expression denial of service (ReDoS) attacks. By providing specially crafted input, an attacker can cause the function to consume excessive CPU resources, leading to a denial of service condition. This can impact the availability and performance of applications that utilize the nltk package.

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

3.6.4

This is the first release that contains the fix.

pip install --upgrade "nltk==3.6.4"

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

Workaround

There is no specific workaround provided for this vulnerability. However, users can mitigate the risk by ensuring they have the latest version of the nltk package installed. Additionally, it is recommended to implement input validation and sanitization techniques to prevent malicious inputs from triggering the vulnerable regular expression.

Conclusion

The vulnerability in nltk due to an inefficient regular expression implementation can lead to regular expression denial of service attacks. It is crucial to update the nltk package to the latest version and implement proper input validation to mitigate the risk. For further support on vulnerability remediation, you can reach out to DevNack.com.

See every vulnerability recorded for nltk →

Share this vulnerability

FAQ

nltk is a Python library used for natural language processing tasks such as tokenization, stemming, tagging, and parsing.

Regular expression denial of service (ReDoS) is a type of attack where an attacker provides input that causes a regular expression to take an excessive amount of time to process, leading to a denial of service condition.

The vulnerability in nltk can impact the availability and performance of applications that utilize the package. An attacker can exploit the vulnerability to launch ReDoS attacks, causing the application to consume excessive CPU resources and potentially leading to a denial of service.

To fix the vulnerability, update the nltk package to version 3.6.4 or later using the package manager of your Python environment.

While there are no specific workarounds provided, you can mitigate the risk by ensuring you have the latest version of the nltk package installed and implementing input validation and sanitization techniques.

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

3.6.4

This is the first release that contains the fix.

pip install --upgrade "nltk==3.6.4"

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