# jQuery Cross Site Scripting in htmlPrefilter

Source: https://junglewise.ai/threats/jquery-cross-site-scripting-in-htmlprefilter-9649f1a0  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2023-06-26. Updated: 2026-05-13  
License: CC BY 4.0 with a link back

Severity: low · CVSS 3.1 · Published 2023-06-26

jQuery, a widely used JavaScript library for web development, contains a security flaw in how it processes HTML tags. An attacker could use this vulnerability to execute malicious scripts in a user's browser when they visit a compromised or specially crafted website. This could lead to unauthorized actions being performed on behalf of the user or the theft of sensitive session information.

Technologies: [org.webjars.npm:jquery (Maven)](https://junglewise.ai/threats/technologies/org-webjars-npm-jquery), [jquery-rails (RubyGems)](https://junglewise.ai/threats/technologies/jquery-rails). Vendors: [Maven](https://junglewise.ai/threats/vendors/maven), [RubyGems](https://junglewise.ai/threats/vendors/rubygems).

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Low severity, with a CVSS score of 3.1, published 26 June 2023.

**Which products and versions are affected?** org.webjars.npm:jquery (Maven) ECOSYSTEM:introduced=1.0.3,fixed=3.5.0; jquery-rails (RubyGems) ECOSYSTEM:introduced=0,fixed=4.4.0.

**Is there a fix for This vulnerability?** Yes. org.webjars.npm:jquery (Maven): upgrade to 3.5.0 or later; jquery-rails (RubyGems): upgrade to 4.4.0 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network, in a software library.

**Am I affected?** Check whether you run org.webjars.npm:jquery (Maven) or jquery-rails (RubyGems) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- org.webjars.npm:jquery (Maven): upgrade to 3.5.0 or later

  ```sh
  # set org.webjars.npm:jquery to 3.5.0 in your pom.xml or build.gradle
  ```

- jquery-rails (RubyGems): upgrade to 4.4.0 or later

  ```sh
  bundle update jquery-rails
  ```


## Technical details

A Cross-Site Scripting (XSS) vulnerability exists in jQuery versions prior to 3.5.0 due to the way the 'jQuery.htmlPrefilter' method uses a regular expression to ensure XHTML-compliant closing tags. This regex-based transformation can be bypassed or manipulated using specific HTML elements, such as <option>, leading to unintended rendering and script execution. A remote attacker can exploit this by passing specially crafted HTML strings to jQuery manipulation methods (like .html() or .append()). The vulnerability is resolved in jQuery 3.5.0 by changing 'htmlPrefilter' to an identity function that no longer performs regex transformations. This issue is also tracked as a duplicate of CVE-2020-11023.

## Affected products

- jquery jquery >= 1.0.3, < 3.5.0
- rails jquery-rails < 4.4.0
- NuGet jQuery >= 1.0.3, < 3.5.0

## Timeline

- 2020-03-16: patched: Fix committed to jQuery repository
- 2020-04-10: advisory: jQuery 3.5.0 released with security fix
- 2023-06-26: disclosed: Initial publication of this advisory record
- 2024-05-15: other: Advisory withdrawn as a duplicate of GHSA-jpcq-cgw6-v4j6

## References

- [https://github.com/jquery/jquery/commit/1d61fd9407e6fbe82fe55cb0b938307aa0791f77](https://github.com/jquery/jquery/commit/1d61fd9407e6fbe82fe55cb0b938307aa0791f77)
- [https://blog.jquery.com/2020/04/10/jquery-3-5-0-released](https://blog.jquery.com/2020/04/10/jquery-3-5-0-released)
- [https://github.com/jquery/jquery](https://github.com/jquery/jquery)
- [https://github.com/rails/jquery-rails/blob/master/CHANGELOG.md](https://github.com/rails/jquery-rails/blob/master/CHANGELOG.md)
- [https://github.com/rails/jquery-rails/blob/master/CHANGELOG.md](https://github.com/rails/jquery-rails/blob/master/CHANGELOG.md)

## Related threats

- [jQuery Cross-Site Scripting in location.hash element selection](https://junglewise.ai/threats/cve-2011-4969-jquery-cross-site-scripting-in-location-hash-element-selection)
- [jQuery Cross-Site Scripting in main jQuery function](https://junglewise.ai/threats/cve-2012-6708-jquery-cross-site-scripting-in-main-jquery-function)
- [jQuery cross-site scripting in load method](https://junglewise.ai/threats/cve-2020-7656-jquery-cross-site-scripting-in-load-method)
- [jQuery DOM manipulation XSS via option elements](https://junglewise.ai/threats/cve-2020-11023-jquery-cross-site-scripting-xss-vulnerability)
- [jQuery XSS in DOM manipulation methods](https://junglewise.ai/threats/cve-2020-11022-jquery-xss-in-dom-manipulation-methods)
