CVE-2021-43854 Inefficient Regular Expression Complexity in nltk

High 7.5 Published Updated

Attackers can cause denial of service in NLTK applications by submitting crafted long inputs to tokenization functions, leading to excessive CPU consumption.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
Not needed
Fix
Available

What is CVE-2021-43854?

CVE-2021-43854 is a high-severity denial of service vulnerability in nltk, published on 23 Dec 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.

Official 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.

Weakness: CWE-400

Which versions are affected by CVE-2021-43854?

3 open source packages ship an affected version, including nltk. It affects 1 product.

PackageAffectedFixed in
nltk PyPIAll versions3.6.5
nltk PyPIAll versions3.6.6
nltk PyPIAll versions3.6.6

Products include Nltk Nltk.

How do I fix CVE-2021-43854?

Upgrade nltk to a fixed version for your release line: 3.6.5 or 3.6.6.

Upgrade, then put limits on request size, rate and nesting depth so one client cannot exhaust the service. More about Denial of service.

Is CVE-2021-43854 being exploited?

There is no known exploitation of CVE-2021-43854 in the wild and no public exploit code.

Sources

Also known as DEBIAN-CVE-2021-43854, GHSA-f8m6-h2c7-8h9x, PYSEC-2021-859, UBUNTU-CVE-2021-43854.

Is CVE-2021-43854 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free