CVE-2022-31151: Undici Undici Before V5.8.0 Vulnerable To Vulnerability
LOWCVE-2022-31151 is a LOW (CVSS 3.7) undici before v5.8.0 vulnerable to vulnerability (CWE-601: URL Redirection to Untrusted Site ('Open Redirect')) affecting Undici libraries in the npm ecosystem. The issue involves undici before v5.8.0 vulnerable to uncleared cookies on cross-host / cross-origin redirect. Remediation is available by upgrading affected packages to version 5.8.0.
CVE-2022-31151 at a Glance
Security Impact
CVSS: 3.7
The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N).
How to Fix CVE-2022-31151
To remediate this vulnerability, upgrade all affected Undici 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 undici@5.8.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
npm ls undici
How to Check if You Are Affected
To determine whether your Node.js application is affected by CVE-2022-31151, inspect your project dependencies using npm:
npm ls undici
Analyze the terminal output to locate any version of Undici in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 5.8.0), your application is affected.
Note: The npm ls undici 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-601: URL Redirection to Untrusted Site ('Open Redirect'), where the web application accepts a user-controlled input that specifies a link to an external site, and uses that link in a redirect. In Undici, 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-2022-31151 Affected Undici Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
undici
|
npm |
< 5.8.0
|
5.8.0
|
References
Frequently Asked Questions
What is CVE-2022-31151?
Which Undici versions are affected?
What version fixes CVE-2022-31151?
Is undici affected?
What is the CVSS score of CVE-2022-31151?
What CWE is associated with CVE-2022-31151?
How can I check npm dependencies for CVE-2022-31151?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-q768-x9m6-m9qp",
"modified" : "2022-07-21T20:31:05Z",
"published" : "2022-07-21T20:31:05Z",
"aliases" : [ "CVE-2022-31151" ],
"summary" : "undici before v5.8.0 vulnerable to uncleared cookies on cross-host / cross-origin redirect",
"details" : "### Impact\n\nAuthorization headers are already cleared on cross-origin redirect in\nhttps://github.com/nodejs/undici/blob/main/lib/handler/redirect.js#L189, based on https://github.com/nodejs/undici/issues/872.\n\nHowever, cookie headers which are sensitive headers and are official headers found in the spec, remain uncleared. There also has been active discussion of implementing a cookie store https://github.com/nodejs/undici/pull/1441, which suggests that there are active users using cookie headers in undici.\nAs such this may lead to accidental leakage of cookie to a 3rd-party site or a malicious attacker who can control the redirection target (ie. an open redirector) to leak the cookie to the 3rd party site.\n\n### Patches\n\nThis was patched in v5.8.0.\n\n### Workarounds\n\nBy default, this vulnerability is not exploitable.\nDo not enable redirections, i.e. `maxRedirections: 0` (the default). \n\n### References\n\nhttps://hackerone.com/reports/1635514\nhttps://curl.se/docs/CVE-2018-1000007.html\nhttps://curl.se/docs/CVE-2022-27776.html\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [undici repository](https://github.com/nodejs/undici/issues)\n* To make a report, follow the [SECURITY](https://github.com/nodejs/node/blob/HEAD/SECURITY.md) document\n",
"severity" : [ {
"type" : "CVSS_V3",
"score" : "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "undici"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "5.8.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nodejs/undici/security/advisories/GHSA-q768-x9m6-m9qp"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-31151"
}, {
"type" : "WEB",
"url" : "https://github.com/nodejs/undici/issues/872"
}, {
"type" : "WEB",
"url" : "https://github.com/nodejs/undici/pull/1441"
}, {
"type" : "WEB",
"url" : "https://github.com/nodejs/undici/commit/0a5bee9465e627be36bac88edf7d9bbc9626126d"
}, {
"type" : "WEB",
"url" : "https://hackerone.com/reports/1635514"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nodejs/undici"
}, {
"type" : "WEB",
"url" : "https://github.com/nodejs/undici/blob/main/lib/handler/redirect.js#L189"
}, {
"type" : "WEB",
"url" : "https://github.com/nodejs/undici/releases/tag/v5.8.0"
}, {
"type" : "WEB",
"url" : "https://security.netapp.com/advisory/ntap-20220909-0006"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-346", "CWE-601", "CWE-93" ],
"severity" : "LOW",
"github_reviewed" : true,
"github_reviewed_at" : "2022-07-21T20:31:05Z",
"nvd_published_at" : "2022-07-21T04:15:00Z"
}
}