Skip to content
SSRF Disclosed report Intermediate CVE-2022-35949

[CVE-2022-35949]: undici.request vulnerable to SSRF using absolute / protocol-relative URL on pathname

The undici HTTP client library for Node.js combined a user-supplied path or pathname with the configured origin in a way that let an absolute or protocol-relative URL override the host. An attacker who controlled that input could make the application send requests to an internal address such as the loopback interface instead of the intended host.

haxatron1 Follow

Originally disclosed on HackerOne

  • Triaged in 6 hours
  • Fixed in 15 days
  • Paid in 15 days
  • Disclosed after 45 days

Summary by the program

undici.request vulnerable to SSRF using absolute URL on pathname

Package: undici (npm) Affected versions: =< 5.8.1 Patched versions: 5.8.2

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

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.

Full GHSA Link: https://github.com/nodejs/undici/security/advisories/GHSA-8qr4-xgw6-wmr3

The report

GHSA: https://github.com/nodejs/undici/security/advisories/GHSA-8qr4-xgw6-wmr3

Report: https://hackerone.com/reports/1642017

Impact

SSRF

The original report as published on HackerOne, by haxatron1. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the library resolved the combined origin and path as a full URL, so an absolute or protocol-relative path replaced the origin's host rather than being appended to it.

Impact

An application that passes user input into the path or pathname option could be tricked into sending requests to internal hosts, though the text gives no further detail on what an attacker could reach.

What the attacker needed

App passes user input into path/pathname; undici version 5.8.1 or earlier

The fix

The issue was fixed in undici 5.8.2, and validating user input before passing it to undici.request is also advised.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Server-side request forgery (SSRF) is when an attacker can make a server send a request to a destination of their choosing, often to internal systems the attacker cannot reach directly. Here a library that builds web requests joined a developer-supplied base address with a user-supplied path, and a path that looked like a full address replaced the base address entirely. So input the developer thought was just a path could redirect the request to another machine.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

More by haxatron1

View all

30 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.