Summary
Authorization bypass through user-controlled key in url-parse. An incorrect conversion of “@” in protocol in “href” leads to improper validation of the hostname.
Product
NPM url-parse prior to 1.5.7.
Impact
This bypass hostname check issue can lead to an authorization bypass.
Steps to reproduce
url-parse is not able to verify broken protocol. This will allow to bypass hostname validation.
console.log(parse("http:@/127.0.0.1"))
Expected result:
slashes: true,
protocol: 'http:',
hash: '',
query: '',
pathname: '/127.0.0.1',
auth: '',
host: '',
port: '',
hostname: '',
password: '',
username: '',
origin: 'null',
href: 'http:///127.0.0.1'
}
Here the hostname check equals null which will clearly bypass the 127.0.0.1 blacklist check (interpreted as relative path instead).
If href (http:///127.0.0.1) is used to fetch URL then it will fetch 127.0.0.1.
Remediation
Correct the href attribute or update url-parse to version 1.5.7.
Credit
This issue was reported by @haxatron through huntr.dev.