CVE-2022-35949: Undici `undici.request` Vulnerable To SSRF Using Vulnerability

MODERATE
Advisory Identifier: GHSA-8qr4-xgw6-wmr3
CVSS 5.3
CWE-918
Published
Advisory Summary

CVE-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

CVE Identifier CVE-2022-35949
GHSA Identifier GHSA-8qr4-xgw6-wmr3
Severity MODERATE
CVSS v3.1 Base Score 5.3
CWE Classification CWE-918: Server-Side Request Forgery (SSRF)
Affected Product Undici
Package Ecosystem npm
Published Date
Last Updated

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).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity None (I:N)
Availability None (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.

undici fixed: 5.8.2
npm install undici@5.8.2
Verify Direct and Transitive Dependencies

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

### Impact `undici` is vulnerable to SSRF (Server-side Request Forgery) when an application takes in **user input** into the `path/pathname` option of `undici.request`. If a user specifies a URL such as `http://127.0.0.1` or `//127.0.0.1` ```js const undici = require("undici") undici.request({origin: "http://example.com", pathname: "//127.0.0.1"}) ``` Instead 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`. If 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. ### Patches This issue was fixed in `undici@5.8.1`. ### Workarounds The best workaround is to validate user input before passing it to the `undici.request` call. ## For more information If you have any questions or comments about this advisory: - Open an issue in [undici repository](https://github.com/nodejs/undici/issues) - To make a report, follow the [SECURITY](https://github.com/nodejs/node/blob/HEAD/SECURITY.md) document

CVE-2022-35949 Affected Undici Versions

1 component(s)
Fixed Versions:
5.8.2
Product / Package Ecosystem Affected Versions Fixed Version
undici
npm
< 5.8.2
5.8.2

References

Frequently Asked Questions

What is CVE-2022-35949?
CVE-2022-35949 is a security vulnerability in Undici involving `undici.request` vulnerable to SSRF using absolute URL on `pathname` under CWE-918: Server-Side Request Forgery (SSRF).
Which Undici versions are affected?
Affected versions include releases prior to 5.8.2 across affected packages: undici.
What version fixes CVE-2022-35949?
Upgrading to 5.8.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is undici affected?
Yes, undici is affected in releases prior to 5.8.2. Upgrade your dependency to 5.8.2 or later.
What is the CVSS score of CVE-2022-35949?
CVE-2022-35949 has a CVSS v3.1 base score of 5.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N.
What CWE is associated with CVE-2022-35949?
CVE-2022-35949 is classified under CWE-918: Server-Side Request Forgery (SSRF) (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.).
How can I check npm dependencies for CVE-2022-35949?
Run the dependency tree command: 'npm ls undici'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}