CVE-2012-6708: Cross-Site Scripting in jquery
Summary
CVE-2012-6708: Cross-Site Scripting in jquery. Affects jquery versions < 1.9.0. Fixed in 1.9.0. How to fix ↓
Also tracked for
- ruby · Alpine:v3.10
The same CVE-2012-6708 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
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 jquery package is a popular JavaScript library that simplifies HTML document traversal, event handling, and animation for web development. It is widely used in various ecosystems such as npm, Maven, NuGet, and RubyGems. This vulnerability affects versions of jquery up to 1.8.3. The package is susceptible to a cross-site scripting (XSS) attack due to a flaw in the main jquery function. The function uses a regular expression to differentiate between HTML and selectors but fails to properly anchor the regular expression. As a result, certain inputs can be interpreted as selectors, leading to client-side code execution.
Vulnerability Detail
The vulnerability in jquery allows an attacker to inject malicious client-side code into a web application. By exploiting this vulnerability, an attacker can execute arbitrary JavaScript code within the context of a victim's browser. This can lead to various security risks, including session hijacking, defacement of web pages, theft of sensitive information, and unauthorized actions on behalf of the victim. The vulnerability has a CVSS score of 6.1, indicating a moderate severity level.
How To Fix
Latest published version: 4.0.0 as of 23 Oct 2026
npm install jquery@4.0.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
1.9.0
This is the first release that contains the fix.
npm install jquery@1.9.0
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If updating the jquery package is not immediately feasible, a temporary workaround can be implemented. One possible workaround is to sanitize user input and properly encode any dynamic content that is inserted into the HTML using jquery. This can help mitigate the risk of cross-site scripting attacks. Here is an example of how to sanitize user input in a jquery context:
var userInput = '<img src="x" onerror="alert(1)" />';
var sanitizedInput = $('<div>').text(userInput).html();
$('#log').html(sanitizedInput);
In this example, the user input is sanitized using the text() function to prevent any HTML tags or special characters from being interpreted as code.
Conclusion
The jquery package is vulnerable to a cross-site scripting (XSS) attack due to a flaw in its main function. This vulnerability can be mitigated by updating the package to version 1.9.0 or later. Developers should also sanitize user input and properly encode dynamic content to prevent cross-site scripting attacks. For further support on vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for jquery →
FAQ
This vulnerability allows an attacker to execute arbitrary JavaScript code in the context of a victim's browser. This can lead to various security risks, including session hijacking, defacement of web pages, theft of sensitive information, and unauthorized actions on behalf of the victim.
Versions of jquery up to 1.8.3 are affected by this vulnerability.
The recommended mitigation is to update the jquery package to version 1.9.0 or later. Additionally, sanitizing user input and properly encoding dynamic content can help mitigate the risk of cross-site scripting attacks.
If updating the jquery package is not immediately feasible, a temporary workaround is to sanitize user input and properly encode any dynamic content that is inserted into the HTML using jquery.
You can find more information about this vulnerability, including the technical details and recommended fixes, in the official GitHub advisory: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2020/09/GHSA-2pqj-h3vj-pqgw/GHSA-2pqj-h3vj-pqgw.json
Related vulnerabilities
Recent vulnerabilities recorded for jquery.