CVE-2021-23354 Regular Expression Denial of Service (ReDoS)
An attacker can cause a denial of service by exploiting a vulnerable regular expression in the printf library, 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-23354?
CVE-2021-23354 is a medium-severity denial of service vulnerability in printf, published on 12 Mar 2021. An attacker can exploit it over the internet without logging in, with no action from the victim.
Official description
The package printf before 0.6.1 are vulnerable to Regular Expression Denial of Service (ReDoS) via the regex string /\%(?:\(([\w_.]+)\)|([1-9]\d*)\$)?([0 +\-\]*)(\*|\d+)?(\.)?(\*|\d+)?[hlL]?([\%bscdeEfFgGioOuxX])/g in lib/printf.js. The vulnerable regular expression has cubic worst-case time complexity.
Weakness: CWE-1333
Which versions are affected by CVE-2021-23354?
2 open source packages ship an affected version, including printf. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
printf npm | All versions | 0.6.1 |
printf npm | All versions | 0.6.1 |
Products include Adaltas Printf.
How do I fix CVE-2021-23354?
Upgrade printf to 0.6.1 or later.
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-23354 being exploited?
There is no known exploitation of CVE-2021-23354 in the wild and no public exploit code.
Sources
Also known as CLSA-2026-1772669616, CLSA-2026-1774311624, GHSA-xfhp-gmh8-r8v2, SNYK-JS-PRINTF-1072096.