CVE-2022-0691: Url parse Url-parse Incorrectly Parses Hostname / Vulnerability

MODERATE
Advisory Identifier: GHSA-jf5r-8hm2-f872
CVSS 6.5
CWE-639
Published
Advisory Summary

CVE-2022-0691 is a MODERATE (CVSS 6.5) url-parse incorrectly parses hostname / vulnerability (CWE-639: Authorization Bypass Through User-Controlled Key) affecting Url parse libraries in the npm ecosystem. The issue involves url-parse incorrectly parses hostname / protocol due to unstripped leading control characters.. Remediation is available by upgrading affected packages to version 1.5.9.

CVE-2022-0691 at a Glance

CVE Identifier CVE-2022-0691
GHSA Identifier GHSA-jf5r-8hm2-f872
Severity MODERATE
CVSS v3.1 Base Score 6.5
CWE Classification CWE-639: Authorization Bypass Through User-Controlled Key
Affected Product Url parse
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.5

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2022-0691

To remediate this vulnerability, upgrade all affected Url parse dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

url-parse fixed: 1.5.9
npm install url-parse@1.5.9
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls url-parse

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2022-0691, inspect your project dependencies using npm:

npm ls url-parse

Analyze the terminal output to locate any version of Url parse in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.5.9), your application is affected.

Note: The npm ls url-parse command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-639: Authorization Bypass Through User-Controlled Key, where the system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data. In Url parse, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

Leading control characters in a URL are not stripped when passed into url-parse. This can cause input URLs to be mistakenly be interpreted as a relative URL without a hostname and protocol, while the WHATWG URL parser will trim control characters and treat it as an absolute URL. If url-parse is used in security decisions involving the hostname / protocol, and the input URL is used in a client which uses the WHATWG URL parser, the decision may be incorrect. This can also lead to a cross-site scripting (XSS) vulnerability if url-parse is used to check for the javascript: protocol in URLs. See following example: ```js const parse = require('url-parse') const express = require('express') const app = express() const port = 3000 url = parse(\"\\bjavascript:alert(1)\") console.log(url) app.get('/', (req, res) => { if (url.protocol !== \"javascript:\") {res.send(\"<a href=\\'\" + url.href + \"\\'>CLICK ME!</a>\")} }) app.listen(port, () => { console.log(`Example app listening on port ${port}`) }) ```

CVE-2022-0691 Affected Url parse Versions

1 component(s)
Fixed Versions:
1.5.9
Product / Package Ecosystem Affected Versions Fixed Version
url-parse
npm
≥ 0.1.0
< 1.5.9
1.5.9

References

Frequently Asked Questions

What is CVE-2022-0691?
CVE-2022-0691 is a security vulnerability in Url parse involving url-parse incorrectly parses hostname / protocol due to unstripped leading control characters. under CWE-639: Authorization Bypass Through User-Controlled Key.
Which Url parse versions are affected?
Affected versions include releases prior to 1.5.9 across affected packages: url-parse.
What version fixes CVE-2022-0691?
Upgrading to 1.5.9 (or the latest patched release for your respective branch) resolves the vulnerability.
Is url-parse affected?
Yes, url-parse is affected in releases prior to 1.5.9. Upgrade your dependency to 1.5.9 or later.
What is the CVSS score of CVE-2022-0691?
CVE-2022-0691 has a CVSS v3.1 base score of 6.5 (MODERATE) with vector string CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N.
What CWE is associated with CVE-2022-0691?
CVE-2022-0691 is classified under CWE-639: Authorization Bypass Through User-Controlled Key (The system's authorization functionality does not prevent one user from gaining access to another user's data or record by modifying the key value identifying the data.).
How can I check npm dependencies for CVE-2022-0691?
Run the dependency tree command: 'npm ls url-parse'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-jf5r-8hm2-f872",
  "modified" : "2026-02-03T22:10:35Z",
  "published" : "2022-02-22T00:00:30Z",
  "aliases" : [ "CVE-2022-0691" ],
  "summary" : "url-parse incorrectly parses hostname / protocol due to unstripped leading control characters.",
  "details" : "Leading control characters in a URL are not stripped when passed into url-parse. This can cause input URLs to be mistakenly be interpreted as a relative URL without a hostname and protocol, while the WHATWG URL parser will trim control characters and treat it as an absolute URL.\n\nIf url-parse is used in security decisions involving the hostname / protocol, and the input URL is used in a client which uses the WHATWG URL parser, the decision may be incorrect.\n\nThis can also lead to a cross-site scripting (XSS) vulnerability if url-parse is used to check for the javascript: protocol in URLs. See following example:\n```js\nconst parse = require('url-parse')\nconst express = require('express')\nconst app = express()\nconst port = 3000\n\nurl = parse(\\\"\\\\bjavascript:alert(1)\\\")\n\nconsole.log(url)\n\napp.get('/', (req, res) => {\n if (url.protocol !== \\\"javascript:\\\") {res.send(\\\"<a href=\\\\'\\\" + url.href + \\\"\\\\'>CLICK ME!</a>\\\")}\n })\n\napp.listen(port, () => {\n console.log(`Example app listening on port ${port}`)\n })\n```",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "url-parse"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.1.0"
      }, {
        "fixed" : "1.5.9"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2022-0691"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/github/advisory-database/pull/6765"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/unshiftio/url-parse/commit/0e3fb542d60ddbf6933f22eb9b1e06e25eaa5b63"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/unshiftio/url-parse"
  }, {
    "type" : "WEB",
    "url" : "https://huntr.dev/bounties/57124ed5-4b68-4934-8325-2c546257f2e4"
  }, {
    "type" : "WEB",
    "url" : "https://lists.debian.org/debian-lts-announce/2023/02/msg00030.html"
  }, {
    "type" : "WEB",
    "url" : "https://security.netapp.com/advisory/ntap-20220325-0006"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-639" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2022-03-01T19:05:20Z",
    "nvd_published_at" : "2022-02-21T09:15:00Z"
  }
}