url-parse package return wrong hostname
The url-parse package returned an incorrect hostname for certain URLs, which could lead to vulnerabilities such as SSRF, open redirect, and authentication bypass. An attacker could craft a URL that the library parses with a different hostname than the actual destination, potentially bypassing security controls.
- Triaged in 6 days
- Fixed in 11 days
- Disclosed after 11 days
Summary by the program
Jul 19th 2018 - lolwaleet submitted a report to Node.js third-party modules. I would like to report url-parse package return wrong hostname in url-parse.
Module
module name: url-parse version: 1.4.1 npm page: https://www.npmjs.com/package/url-parse
Module Description
The url-parse method exposes two different API interfaces. The url interface that you know from Node.js and the new URL interface that is available in the latest browsers.
In version 0.1 we moved from a DOM based parsing solution, using the <a> element, to a full Regular Expression solution. The main reason for this was to make the URL parser available in different JavaScript environments as you don't always have access to the DOM. An example of such environment is the Worker interface. The RegExp based solution didn't work well as it required a lot of lookups causing major problems in FireFox. In version 1.0.0 we ditched the RegExp based solution in favor of a pure string parsing solution which chops up the URL into smaller pieces. This module still has a really small footprint as it has been designed to be used on the client side.
Vulnerability
Vulnerability Description
url-parse returns wrong hostname which leads to multiple vulnerabilities such as SSRF, Open Redirect, Bypass Authentication Protocol.
Fix
Fixes applied to version 1.4.3
Resources:
- Patch landed in master, including tests to prevent regression: https://github.com/unshiftio/url-parse/commit/53b1794e54d0711ceb52505e0f74145270570d5a
- A SECURITY.md file has been added to the repo to make it easier to report bugs, and reach me in the future, including history of the previous security reports and their fix version. https://github.com/unshiftio/url-parse/commit/d7b582ec1243e8024e60ac0b62d2569c939ef5de
- http://0xahmed.ninja/
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 a flaw in the string parsing logic that incorrectly extracts the hostname from certain URL formats.
Impact
This could enable SSRF, open redirect, and authentication bypass, though the report does not provide specific exploitation details.
What the attacker needed
Use of vulnerable url-parse version
The fix
The issue was fixed in version 1.4.3 with a patch that includes regression tests.
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.
A library that splits web addresses into parts (like the domain name) sometimes got the domain wrong. If a program trusts that wrong domain, an attacker could trick it into sending requests to unintended places or redirecting users to malicious sites.
What is SSRF?
The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.