GHSA-8qr4-xgw6-wmr3

Suggest an improvement
Source
https://github.com/advisories/GHSA-8qr4-xgw6-wmr3
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/08/GHSA-8qr4-xgw6-wmr3/GHSA-8qr4-xgw6-wmr3.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-8qr4-xgw6-wmr3
Aliases
Published
2022-08-18T18:59:46Z
Modified
2023-11-08T04:09:53.898548Z
Severity
  • 5.3 (Medium) CVSS_V3 - CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N CVSS Calculator
Summary
`undici.request` vulnerable to SSRF using absolute URL on `pathname`
Details

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.

For more information

If you have any questions or comments about this advisory:

Database specific
{
    "nvd_published_at": "2022-08-12T23:15:00Z",
    "github_reviewed_at": "2022-08-18T18:59:46Z",
    "severity": "MODERATE",
    "github_reviewed": true,
    "cwe_ids": [
        "CWE-918"
    ]
}
References

Affected packages

npm / undici

Package

Affected ranges

Type
SEMVER
Events
Introduced
0Unknown introduced version / All previous versions are affected
Fixed
5.8.2

Database specific

{
    "last_known_affected_version_range": "<= 5.8.1"
}