How to Fix an Outdated jQuery Vulnerability (and Other CDN Libraries) in 2026

Pass the string <style><style /><img src=x onerror="..."> to .html() on jQuery 3.4.1 and you get a working <img> tag with its onerror handler attached. Pass the same string to jQuery 3.5.0 and the image stays trapped as inert text inside a <style> block. We ran both on November 12, 2026, and the output is below. That one-version gap is what the "Outdated jQuery" finding is about.

It's also why npm audit keeps saying you're clean. The old jQuery often isn't in a lockfile at all: it's a script tag pointing at a CDN, or a copy a chat widget brought along.

TL;DR

Upgrade jQuery to 3.5.0 or newer: 3.7.1 is the newest 3.x and the low-effort target, 4.0.0 is the current major. Find the copy your site actually loads with jQuery.fn.jquery in the browser console, not with npm ls, because CDN script tags never show up in npm. Then test for one behaviour change: jQuery stopped rewriting self-closing tags like <div/>.

What Our Scanner Flags, and At What Version

The finding reads Outdated {library} ({version}). Here's the full list of libraries the check looks for and the version below which it fires. These are the thresholds from the analyzer itself, not a summary.

LibraryFlagged belowSeverityWhy
jQuery3.5.0MediumXSS in HTML pre-processing (CVE-2020-11022, CVE-2020-11023)
AngularJS (1.x)1.8.0HighSandbox escapes; 1.x is end-of-life
DOMPurify3.0.0HighSanitizer bypasses
Handlebars4.7.7HighPrototype pollution leading to code execution
Lodash4.17.21MediumPrototype pollution (CVE-2021-23337)
Bootstrap4.3.1MediumXSS in data- attributes (CVE-2019-8331)
Underscore.js1.13.6MediumCode injection via template()
Axios1.6.0MediumOlder releases have SSRF issues
Socket.io4.5.0MediumAssorted fixed vulnerabilities
Moment.js2.29.4LowReDoS; the library is deprecated
Vue.js2.7.0LowVue 2 is end-of-life
React16.13.0LowOld release line
highlight.js11.0.0LowReDoS

jQuery is the one people search for, so most of this page is about it. The fix pattern at the bottom works for every row.

What the jQuery Bug Actually Does

jQuery's .html(), .append(), .before() and friends run your HTML string through a helper called htmlPrefilter before handing it to the browser. Up to 3.4.1, that helper used a regex to expand self-closing tags, so <div/> became <div></div>.

The regex didn't know about context. It would also expand a <style /> sitting inside a <style> element, which closes the style block early and releases whatever came after it as real HTML.

Here's what that looks like. We installed jQuery 3.4.1, 3.5.0 and 3.7.1 from npm, loaded each into jsdom, and passed the same strings to $('#t').html(...):

Output of .html() on each version, run 2026-11-12
Payload: <style><style /><img src=x onerror="window.pwned=1">

3.4.1  <style><style ></style><img src="x" onerror="window.pwned=1">
3.5.0  <style><style /><img src=x onerror="window.pwned=1"></style>
3.7.1  <style><style /><img src=x onerror="window.pwned=1"></style>

Payload: <img alt="<x" title="/><img src=x onerror=window.pwned=1>">

3.4.1  <img alt="<x" title="></x"><img src="x" onerror="window.pwned=1">"&gt;
3.5.0  <img alt="<x" title="/><img src=x onerror=window.pwned=1>">
3.7.1  <img alt="<x" title="/><img src=x onerror=window.pwned=1>">

On 3.4.1 both payloads come out as a second, live <img> with an event handler. On 3.5.0 and later, the first stays as text inside <style> and the second stays inside an attribute value, which is where it started.

Sanitizing first doesn't save you on 3.4.1. Both payloads look harmless to a sanitizer: one hides the <img> inside a style block, the other inside an attribute. If your app cleans user HTML and then inserts it with jQuery, the old version reassembles the attack after the cleaning step. The CVE description says it outright: passing HTML from untrusted sources to these methods "even after sanitizing it" may run untrusted code. jQuery's 3.5.0 release notes removed the regex for that reason.

Is your site exploitable? Only if it passes a string an attacker can influence into one of those methods. Plenty of sites never do. But "we probably don't" is a hard thing to verify across a codebase you didn't write line by line, and the upgrade is usually smaller than the audit.

Step 1: Find the Copy You Actually Load

Don't start with package.json. Start with the browser, because that's what the scanner saw.

1

Ask the page. Open your live site, open DevTools, and run this in the console:

jQuery.fn.jquery

It prints the version that actually loaded, for example "3.4.1". If it prints an error, jQuery isn't on that page under that name. Repeat on any page that loads a chat widget, a booking embed or a form builder, since those often ship their own copy.

2

Find where it comes from. In the Network tab, filter by jquery. The request URL tells you which of three cases you're in:

  • code.jquery.com, cdnjs.cloudflare.com or cdn.jsdelivr.net: a script tag in your HTML or layout.
  • Your own domain, inside a file like /_next/static/chunks/... or /assets/index-abc123.js: bundled from npm.
  • A third party's domain: a widget brought it, and you don't control the file.

The finding itself carries the URL it matched in, so check that too. The scanner reads the first version string next to the word "jquery" in each script, which means a file that merely mentions an old version (a plugin's compatibility comment, say) can trigger it. If the URL in the finding isn't a jQuery file and jQuery.fn.jquery reports 3.5 or later, you're looking at that case.

Step 2: Upgrade It

If it's a CDN script tag

Change the version in the URL. If the tag has an integrity attribute (it should), the hash changes too, and a mismatched hash makes the browser refuse to run the file.

Before and after
<!-- before -->
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

<!-- after: copy the full tag from code.jquery.com so the hash is right -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
        integrity="sha256-..."
        crossorigin="anonymous"></script>

Copy the whole tag from code.jquery.com rather than typing the hash. Our subresource integrity guide covers why the hash matters and how to generate one for any CDN file.

If it's bundled from npm

Find out who asked for it. Often it's not your code at all:

Find the dependency path
npm ls jquery
# your-app@1.0.0
# └─┬ some-old-carousel@2.1.0
#   └── jquery@3.4.1

If you depend on jQuery directly, npm install jquery@^3.7.1. Going to 4.0 is a separate project: it removes long-deprecated APIs, so treat it as its own upgrade rather than part of this fix. If another package pins it, upgrade that package first. If the package is abandoned and won't take a newer jQuery, an overrides entry in package.json forces the version, but test it, since you're overriding what the package author tested against.

If a third-party widget brings it

You can't edit their file. Check whether the vendor has a newer embed snippet, then tell them. If the widget is on a page where users never type anything, it's lower priority than your own copy, but it's still in your page and still in the finding.

Step 3: Test the One Thing That Changes

The security fix is the breaking change. jQuery 3.5.0 stopped expanding self-closing tags, so code that relied on that expansion now nests differently. We checked it on the same setup:

Self-closing div followed by more HTML, passed to .html()
Input: <div class="a"/><p>hello</p>

3.4.1  <div class="a"></div><p>hello</p>
3.7.1  <div class="a"><p>hello</p></div>

On the new version the paragraph ends up inside the div, because the browser treats <div/> as an opening tag. Layouts shift, selectors stop matching. A lone tag like $("<div/>") still works fine on both: the change only bites when a self-closing tag is followed by more HTML in the same string.

Let jQuery Migrate find them for you. Load jQuery Migrate after jQuery in a staging build and it logs a console warning for each HTML string that would have been rewritten. Fix those by writing <div></div> out in full. Migrate also has jQuery.UNSAFE_restoreLegacyHtmlPrefilter(), which puts the old behaviour back. The name is honest: it brings the vulnerability back with it.

Once the warnings are gone, remove Migrate and ship.

Then Re-Check From the Outside

Reload the live site, run jQuery.fn.jquery again, and re-scan. A cached CDN response or a stale build on one route is the usual reason a finding survives a fix that looked done.

How do I fix the outdated jQuery vulnerability?

Upgrade to jQuery 3.5.0 or newer. If jQuery comes from a script tag, change the version in the CDN URL and update the integrity hash. If it comes from npm, run npm ls jquery to find which package pulls it in, then upgrade that package. After upgrading, test any code that inserts HTML strings containing self-closing tags like <div/>, because 3.5.0 stopped rewriting them.

Is jQuery 3.4.1 vulnerable?

Yes. CVE-2020-11022 affects jQuery 1.2 through 3.4.1, and CVE-2020-11023 (the variant involving option elements) affects 1.0.3 through 3.4.1. Both are XSS bugs in how jQuery's DOM manipulation methods pre-process HTML strings. We passed the same payload to .html() on 3.4.1 and 3.5.0: 3.4.1 produced a live img tag with an onerror handler, 3.5.0 left it inert.

How do I check which version of jQuery my site uses?

Open your live site, open the browser console and type jQuery.fn.jquery. It prints the version that actually loaded. If it prints undefined, jQuery isn't on the page under that name. Check every page that loads a third-party widget, since widgets often bring their own copy.

Why doesn't npm audit show the jQuery vulnerability?

Because npm audit only reads package-lock.json. A jQuery loaded from a CDN script tag, pasted into a public folder, or injected by a third-party widget never appears in your lockfile, so audit has nothing to check. You have to look at what the browser actually loads.

Will upgrading jQuery break my site?

Usually not, within the 3.x line. The one change to test is that jQuery no longer converts self-closing tags like <div/> into <div></div> when you pass an HTML string to .html(), .append() and similar methods. jQuery Migrate can flag those calls while you fix them.

Still loading an old library?

We check the scripts your live site actually serves, CDN tags and widgets included, not just your lockfile.

How-To Guides

How to Fix an Outdated jQuery Vulnerability (and Other CDN Libraries) in 2026