CVE-2022-0691: Url parse Url-parse Incorrectly Parses Hostname / Vulnerability
MODERATECVE-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
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).
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.
npm install url-parse@1.5.9
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
CVE-2022-0691 Affected Url parse Versions
1 component(s)| 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?
Which Url parse versions are affected?
What version fixes CVE-2022-0691?
Is url-parse affected?
What is the CVSS score of CVE-2022-0691?
What CWE is associated with CVE-2022-0691?
How can I check npm dependencies for CVE-2022-0691?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}