Skip to content
Prototype pollution Write-up Intermediate

jQuery 3.2.1 Security Flaws Explained

jQuery 3.2.1 is vulnerable to prototype pollution via $.extend(true, ...) and DOM-based XSS via HTML containing <option> elements. An attacker could pollute Object.prototype or execute arbitrary JavaScript if untrusted input reaches these jQuery methods.

medium.com

Published on medium.com

For years, jQuery has been the go-to JavaScript library for simplifying DOM manipulation, AJAX calls, and event handling. It provided developers with a way to write less code and support more browsers back when cross-browser inconsistencies were a daily headache.

Vishvadini Ravihari, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely, jQuery's deep merge function did not block the special __proto__ key, and its HTML parsing did not properly sanitise <option> elements before insertion.

Impact

An attacker could bypass logic checks, cause input validation to fail, or execute arbitrary JavaScript to steal session data or modify the UI, all without server-side involvement.

What the attacker needed

Application uses jQuery 3.2.1 or older; attacker can supply untrusted data to $.extend or HTML…

The fix

The vulnerabilities were fixed in jQuery 3.5.0 and later; users should update to version 3.5.0 or higher.

How it was found

  1. Create a JavaScript object with a __proto__ key containing a property.
  2. Call $.extend(true, {}, payload) to deep-merge the object.
  3. Observe that the property is added to Object.prototype.
  4. Insert an HTML string with an <option> tag containing an event handler into a select element using jQuery.
  5. Observe that the event handler executes.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

jQuery is a popular JavaScript library that helps developers manipulate web pages. Two bugs in old versions let attackers either change how all JavaScript objects behave (prototype pollution) or run their own code in the victim's browser (XSS). Both require that the attacker can get their data into the vulnerable jQuery functions.

What is Prototype pollution?

Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.

Similar reports

View all

Same bug class and techniques, clearest first.

Prototype pollution

The lesson behind this report.

Input changes JavaScript's shared object prototype, altering behaviour across the application, sometimes to XSS or code execution.