Improper Input Validation Affecting url-js package, versions <2.1.0


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.07% (30th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-JS-URLJS-2414030
  • published 7 Mar 2022
  • disclosed 28 Feb 2022
  • credit Pocas

How to fix?

Upgrade url-js to version 2.1.0 or higher.

Overview

url-js is a Simple URL parser, similar to DOM URL

Affected versions of this package are vulnerable to Improper Input Validation due to improper parsing, which makes it is possible for the hostname to be spoofed. http://\\\\\\\\localhost and http://localhost are the same URL. However, the hostname is not parsed as localhost, and the backslash is reflected as it is.

PoC:

Running the following command:

node -e "const URLJS = require('url-js');console.log(URLJS('http://\\\\localhost'))"

Will result in the following output:

URLJS {
  protocol: 'http:',
  username: '',
  password: '',
  hostname: '\\localhost',
  port: '',
  pathname: '/',
  search: '',
  query: '',
  hash: ''
}

References

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
4.3 medium
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    Low
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    Low
  • Integrity (I)
    None
  • Availability (A)
    None
Expand this section

NVD

5.3 medium