Disclosed vulnerabilities
CVE-2022-0512 Published: Apr 25, 2022

Authorization Bypass vulnerability in url-parse

5.3 Medium Severity authorization bypass javascript node nodejs npm
@ranjit-git Reported by Checkmarx Zero

Summary

Authorization bypass through user-controlled key in url-parse. It improperly handles username and password, and unable to detect the hostname.

Product

NPM url-parse prior to 1.5.6.

Impact

This issue may lead to the bypass of the hostname check.

Steps to reproduce

url-parse was not able to verify basic authentication credentials and it also wrongly verifies the hostname. This allows to bypass the hostname validation.
Let username be set as admin, password as password123@ and hostname as 127.0.0.1.
The url will be http://admin:password123@@127.0.0.1.
There is a blacklist check for domain 127.0.0.1 and every request to 127.0.0.1 will be blocked.

var cc=parse("http://admin:password123@@127.0.0.1")

Expected result:

  protocol: 'http:',
  hash: '',
  query: '',
  pathname: '/',
  auth: 'admin:password123',
  host: '@127.0.0.1',
  port: '',
  hostname: '@127.0.0.1',
  password: 'password123',
  username: 'admin',
  origin: 'http://@127.0.0.1',
  href: 'http://admin:password123@@127.0.0.1/' }

Incorrret detection of auth, origin, password and hostname.
Here hostname check cc.hostname is @127.0.0.1 and also cc.origin is http://@127.0.0.1 which will clearly bypass above 127.0.0.1 blacklist check.
Now if you use cc.href to fetch url it will fetch 127.0.0.1.

Remediation

Update url-parse to version 1.5.6.

Credit

This issue was reported by @ranjit-git through huntr.dev.

Resources

  1. Disclosure
  2. 7b0b8a6

Stay connected and never miss a research update!