Skip to content
SSRF Disclosed report Intermediate CVE-2021-3647

URIjs Vulnerable to Hostname spoofing via backslashes in URL

The URI.js library incorrectly parses URLs containing backslashes in the scheme delimiter, returning no hostname instead of the actual hostname. An attacker could exploit this to bypass allow/block lists, perform SSRF, or open redirects if the library is used for security decisions.

medialize/URI.js

Originally disclosed on huntr

Impact

If using affected versions to determine a URL's hostname, the hostname can be spoofed by using a combination of backslash (\) and slash (/) characters as part of the scheme delimiter, e.g. scheme:/\/\/\hostname. If the hostname is used in security decisions, the decision may be incorrect.

Depending on library usage and attacker intent, impacts may include allow/block list bypasses, SSRF attacks, open redirects, or other undesired behavior.

Example URL: https:/\/\/\expected-example.com/path Escaped string: https:/\\/\\/\\expected-example.com/path (JavaScript strings must escape backslash)

Affected versions incorrectly return no hostname. Patched versions correctly return expected-example.com. Patched versions match the behavior of other parsers which implement the WHATWG URL specification, including web browsers and Node's built-in URL class.

Patches

Version 1.19.7 is patched against all known payload variants.

References

https://github.com/medialize/URI.js/releases/tag/v1.19.7 (fix for this particular bypass) https://github.com/medialize/URI.js/releases/tag/v1.19.6 (fix for related bypass) https://github.com/medialize/URI.js/releases/tag/v1.19.4 (fix for related bypass) https://github.com/medialize/URI.js/releases/tag/v1.19.3 (fix for related bypass) PR #233 (initial fix for backslash handling)

For more information

If you have any questions or comments about this advisory, open an issue in https://github.com/medialize/URI.js

Reporter credit

ready-research via https://huntr.dev/

From the GitHub Advisory Database (GHSA-89gv-h8wf-cg8r, CC BY 4.0).

The original report as published on the GitHub Advisory Database. Images and videos are our own copies; raw HTML is shown as text. View it on GitHub Advisory Database.

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 URL parser did not correctly handle backslashes in the scheme delimiter, treating them as part of the path rather than as separators, leading to an empty hostname.

Impact

Depending on how the library is used, this could allow bypassing allow/block lists, SSRF attacks, open redirects, or other undesired behaviour.

What the attacker needed

Application uses URI.js to parse URLs; hostname used for security decisions

The fix

The issue was fixed in version 1.19.7, which correctly parses such URLs and matches the WHATWG URL specification.

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.

URI.js is a JavaScript library for parsing URLs. It had a bug where URLs with backslashes in the part that separates the scheme from the host were parsed incorrectly, so the hostname was not recognised. If a website used this library to check whether a URL points to a trusted site, an attacker could craft a URL that appears to be trusted but actually points elsewhere.

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 from medialize/URI.js

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.