CVE-2022-35949: Undici `undici.request` Vulnerable To SSRF Using Vulnerability
MODERATECVE-2022-35949 is a MODERATE (CVSS 5.3) `undici.request` vulnerable to ssrf using vulnerability (CWE-918: Server-Side Request Forgery (SSRF)) affecting Undici libraries in the npm ecosystem. The issue involves `undici.request` vulnerable to ssrf using absolute url on `pathname`. Remediation is available by upgrading affected packages to version 5.8.2.
CVE-2022-35949 at a Glance
Security Impact
CVSS: 5.3
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:L/I:N/A:N).
How to Fix CVE-2022-35949
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.2
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-35949, 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.2), 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-918: Server-Side Request Forgery (SSRF), where the web server receives a url or similar request from an upstream component and retrieves the contents of this url, but it does not sufficiently ensure that the request is being sent to the expected destination. 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-35949 Affected Undici Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
undici
|
npm |
< 5.8.2
|
5.8.2
|
References
Frequently Asked Questions
What is CVE-2022-35949?
Which Undici versions are affected?
What version fixes CVE-2022-35949?
Is undici affected?
What is the CVSS score of CVE-2022-35949?
What CWE is associated with CVE-2022-35949?
How can I check npm dependencies for CVE-2022-35949?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-8qr4-xgw6-wmr3",
"modified" : "2023-01-18T21:52:48Z",
"published" : "2022-08-18T18:59:46Z",
"aliases" : [ "CVE-2022-35949" ],
"summary" : "`undici.request` vulnerable to SSRF using absolute URL on `pathname`",
"details" : "### Impact\n\n`undici` is vulnerable to SSRF (Server-side Request Forgery) when an application takes in **user input** into the `path/pathname` option of `undici.request`.\n\nIf a user specifies a URL such as `http://127.0.0.1` or `//127.0.0.1`\n\n```js\nconst undici = require(\"undici\")\nundici.request({origin: \"http://example.com\", pathname: \"//127.0.0.1\"})\n```\n\nInstead of processing the request as `http://example.org//127.0.0.1` (or `http://example.org/http://127.0.0.1` when `http://127.0.0.1 is used`), it actually processes the request as `http://127.0.0.1/` and sends it to `http://127.0.0.1`.\n\nIf a developer passes in user input into `path` parameter of `undici.request`, it can result in an _SSRF_ as they will assume that the hostname cannot change, when in actual fact it can change because the specified path parameter is combined with the base URL.\n\n### Patches\n\nThis issue was fixed in `undici@5.8.1`.\n\n### Workarounds\n\nThe best workaround is to validate user input before passing it to the `undici.request` call.\n\n## For more information\nIf you have any questions or comments about this advisory:\n\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:L/PR:N/UI:N/S:U/C:L/I:N/A:N"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "npm",
"name" : "undici"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "5.8.2"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 5.8.1"
}
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nodejs/undici/security/advisories/GHSA-8qr4-xgw6-wmr3"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-35949"
}, {
"type" : "WEB",
"url" : "https://github.com/nodejs/undici/commit/124f7ebf705366b2e1844dff721928d270f87895"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/nodejs/undici"
}, {
"type" : "WEB",
"url" : "https://github.com/nodejs/undici/releases/tag/v5.8.2"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-918" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2022-08-18T18:59:46Z",
"nvd_published_at" : "2022-08-12T23:15:00Z"
}
}