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

nltk Updated 02 Oct 2025

Summary

04/01/2022
N/A
No i
High
7.5

CVE-2021-3842: nltk is vulnerable to Inefficient Regular Expression Complexity. Affects nltk versions < 2a50a3edc9d35f57ae42a921c621edc160877f4d. No fix is published. How to fix ↓

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

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

NLTK (Natural Language Toolkit) is a powerful library in Python used for working with human language data (text). It provides easy-to-use interfaces to over 50 corpora and lexical resources, along with a suite of text processing libraries for classification, tokenization, stemming, tagging, parsing, and more. The vulnerability CVE-2021-3842 affects NLTK's handling of regular expressions, potentially leading to performance issues when processing certain inputs.

Vulnerability Detail

CVE-2021-3842 is a vulnerability in the NLTK library that arises from inefficient regular expression complexity. This can lead to Denial of Service (DoS) conditions, where an attacker can craft specific inputs that cause excessive resource consumption, slowing down or crashing the application. The vulnerability is present in all versions of NLTK prior to the fix, which was introduced in version 3.6.7-1 for Debian packages and commit 2a50a3edc9d35f57ae42a921c621edc160877f4d in the Git repository.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

If immediate upgrading is not possible, consider limiting the input size or sanitizing inputs to avoid triggering the inefficient regular expressions. Implementing input validation can help mitigate the risk until an upgrade can be performed.

Conclusion

CVE-2021-3842 is a significant vulnerability affecting the NLTK library, which can lead to performance degradation and potential Denial of Service. It is crucial for users to update their NLTK installations to the latest version to mitigate this risk. Utilizing tools like Vulert can help in monitoring and managing vulnerabilities effectively.

See every vulnerability recorded for nltk →

Share this vulnerability

FAQ

CVE-2021-3842 is a vulnerability in the NLTK library that involves inefficient regular expression complexity, potentially leading to performance issues.

You can use the Vulert playground at Vulert Scanner to check if your application is affected by this vulnerability without needing to sign up.

The vulnerability can lead to Denial of Service (DoS) conditions, where an attacker can exploit the inefficient regex to consume excessive resources.

You can update NLTK by running the command 'pip install --upgrade nltk' in your terminal.

Vulert is a tool that monitors and alerts for open-source vulnerabilities in software using just a manifest file like package-lock.json.

Related vulnerabilities

Recent vulnerabilities recorded for nltk.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. 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