{"id":"GHSA-jf5r-8hm2-f872","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) =\u003e {\n if (url.protocol !== \\\"javascript:\\\") {res.send(\\\"\u003ca href=\\\\'\\\" + url.href + \\\"\\\\'\u003eCLICK ME!\u003c/a\u003e\\\")}\n })\n\napp.listen(port, () =\u003e {\n console.log(`Example app listening on port ${port}`)\n })\n```","aliases":["CVE-2022-0691"],"modified":"2026-02-03T22:19:28.188485Z","published":"2022-02-22T00:00:30Z","database_specific":{"cwe_ids":["CWE-639"],"github_reviewed":true,"severity":"MODERATE","nvd_published_at":"2022-02-21T09:15:00Z","github_reviewed_at":"2022-03-01T19:05:20Z"},"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"}],"affected":[{"package":{"name":"url-parse","ecosystem":"npm","purl":"pkg:npm/url-parse"},"ranges":[{"type":"SEMVER","events":[{"introduced":"0.1.0"},{"fixed":"1.5.9"}]}],"database_specific":{"source":"https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2022/02/GHSA-jf5r-8hm2-f872/GHSA-jf5r-8hm2-f872.json"}}],"schema_version":"1.7.3","severity":[{"type":"CVSS_V3","score":"CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N"}]}