CVE-2021-43307: Semver regex Denial of Service Vulnerability
LOWCVE-2021-43307 is a LOW denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Semver regex libraries in the npm ecosystem. The issue involves regular expression denial of service in semver-regex. Remediation is available by upgrading affected packages to version 3.1.4, 4.0.3.
CVE-2021-43307 at a Glance
How to Fix CVE-2021-43307
To remediate this vulnerability, upgrade all affected Semver regex 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 semver-regex@3.1.4
npm install semver-regex@4.0.3
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls semver-regex
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2021-43307, inspect your project dependencies using npm:
npm ls semver-regex
Analyze the terminal output to locate any version of Semver regex in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.1.4), your application is affected.
Note: The npm ls semver-regex 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 Semver regex, 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-43307 Affected Semver regex Versions
2 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
semver-regex
|
npm |
< 3.1.4
|
3.1.4
|
|
semver-regex
|
npm |
≥ 4.0.0
< 4.0.3
|
4.0.3
|
References
Frequently Asked Questions
What is CVE-2021-43307?
Which Semver regex versions are affected?
What version fixes CVE-2021-43307?
Is semver-regex affected?
What CWE is associated with CVE-2021-43307?
How can I check npm dependencies for CVE-2021-43307?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-4x5v-gmq8-25ch",
"modified" : "2023-07-19T19:58:13Z",
"published" : "2022-06-03T00:01:00Z",
"aliases" : [ "CVE-2021-43307" ],
"summary" : "Regular expression denial of service in semver-regex",
"details" : "An exponential ReDoS (Regular Expression Denial of Service) can be triggered in the semver-regex npm package, when an attacker is able to supply arbitrary input to the test() method",
"severity" : [ ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "semver-regex"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.1.4"
} ]
} ]
}, {
"package" : {
"ecosystem" : "npm",
"name" : "semver-regex"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "4.0.0"
}, {
"fixed" : "4.0.3"
} ]
} ]
} ],
"references" : [ {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-43307"
}, {
"type" : "WEB",
"url" : "https://github.com/sindresorhus/semver-regex/commit/d8ba39a528c1027c43ab23f12eec28ca4d40dd0c"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/sindresorhus/semver-regex"
}, {
"type" : "WEB",
"url" : "https://research.jfrog.com/vulnerabilities/semver-regex-redos-xray-211349"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1333" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2022-06-03T22:26:33Z",
"nvd_published_at" : "2022-06-02T14:15:00Z"
}
}