CVE-2022-2218: Cross-Site Scripting in parse-url
Summary
CVE-2022-2218: Cross site scripting in parse-url. Affects parse-url versions < 6.0.1. Fixed in 6.0.1. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The parse-url package is an npm package that provides functionality for parsing and manipulating URLs. It is commonly used in web development projects to handle URL-related operations. However, versions prior to 7.0.0 of the parse-url package are vulnerable to a Cross-Site Scripting (XSS) attack.
Vulnerability Detail
The vulnerability in parse-url allows for stored Cross-Site Scripting (XSS) attacks. This means that an attacker can inject malicious code into the application, which will be executed when a user interacts with the affected page. The XSS vulnerability in parse-url can have various ramifications, including the theft of sensitive user information, session hijacking, defacement of web pages, and the potential for further attacks.
How To Fix
Latest published version: 11.1.0 as of 22 Oct 2026
npm install parse-url@11.1.0
Upgrading to it may include breaking changes; the version below is the minimum fixed release for this vulnerability.
If you need the minimum change
6.0.1
This is the first release that contains the fix.
npm install parse-url@6.0.1
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the parse-url package is not immediately feasible, developers can implement input validation and output encoding to prevent the execution of malicious code. It is crucial to sanitize user input and encode any dynamic content displayed on web pages to mitigate the risk of XSS attacks. Here is an example of input validation and output encoding in JavaScript:
// Input validation
const userInput = document.getElementById('userInput').value;
const sanitizedInput = userInput.replace(/<[^>]*>/g, '');
// Output encoding
const dynamicContent = '<script>alert('XSS');</script>';
const encodedContent = document.createElement('div');
encodedContent.innerText = dynamicContent;
// Display encoded content
document.getElementById('output').appendChild(encodedContent);
Conclusion
The parse-url package prior to version 7.0.0 is vulnerable to a Cross-Site Scripting (XSS) attack. This can lead to the execution of malicious code on web pages, potentially resulting in the theft of sensitive information and other security risks. It is crucial to update the parse-url package to version 6.0.1 or later and implement input validation and output encoding to mitigate the vulnerability. For additional support and guidance, please contact DevNack.com.
See every vulnerability recorded for parse-url →
FAQ
The parse-url XSS vulnerability can lead to the execution of malicious code on the affected web page. This can result in the theft of sensitive user information, session hijacking, defacement of web pages, and potential further attacks.
You can use Vulert's playground at Vulert Scanner to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities, using just the package-lock.json file.
While updating the parse-url package is the recommended solution, you can implement input validation and output encoding to mitigate the risk of XSS attacks. Ensure that user input is properly sanitized and dynamic content is encoded before displaying it on web pages.
At the time of this advisory, there are no known public exploits specifically targeting this parse-url XSS vulnerability. However, it is essential to promptly update the package and implement necessary security measures to prevent potential attacks.
For further support on vulnerability remediation, you can reach out to info@devnack.com. They can provide guidance and assistance in addressing the parse-url XSS vulnerability.
Related vulnerabilities
Recent vulnerabilities recorded for parse-url.