Skip to content
Prototype pollution Disclosed report Intermediate CVE-2019-11358

Prototype pollution attack through jQuery $.extend

The deep version of jQuery's $.extend function can be tricked into adding or modifying properties on Object.prototype when given an object with a __proto__ property. An attacker could use this to change default values for any option in functions that take an options argument, potentially altering application behaviour.

asgerf Follow

Originally disclosed on HackerOne

Medium 5.6 View original
  • Triaged in 25 days
  • Fixed in 4 months
  • Disclosed after 4 months

I would like to report prototype pollution in jQuery. It allows an attacker to inject properties on Object.prototype.

Module

module name: jquery version: 3.3.1 npm page: https://www.npmjs.com/package/jquery

Module Description

jQuery is a fast, small, and feature-rich JavaScript library.

Module Stats

1.6M NPM downloads in the last week

But this is jQuery, so I'd expect there are quite a few more downloads outside of NPM.

Vulnerability

Vulnerability Description

$.extend can be tricked into adding or modifying properties of the Object prototype. These properties will be present on all objects. Note that only the "deep" version of $.extend is affected.

Users sometimes use $.extend for things like cloning an object or filling in defaults in an object with some options in it. It is not at all obvious that this is an unsafe operation.

It is a variant of this vulnerability: https://hackerone.com/reports/310443

Steps To Reproduce:

Craft an object with a named __proto__ property, usually through JSON.parse, and pass it to $.extend:

JavaScript
$.extend(true, {}, JSON.parse('{"__proto__": {"devMode": true}}'))
console.log({}.devMode); // true

Supporting Material/References:

Tested on jQuery 3.3.1 (and a few older versions), using Chrome 70 and Firefox 63.

Wrap up

  • I contacted the maintainer to let them know: [N]
  • I opened an issue in the related repository: [N]

Impact

How to escalate this depends on the application. After obtaining prototype pollution, an attacker can generally change the default value for any option provided to a function that takes an "options" argument, which is a fairly common pattern in JavaScript.

The original report as published on HackerOne, by asgerf. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

How it worked

Root cause

Likely the deep merge logic in $.extend does not block or sanitise the special __proto__ key, allowing it to modify Object.prototype.

Impact

An attacker could change default values for any option in functions that take an options argument, which may alter application behaviour depending on how the application uses those options.

What the attacker needed

Application uses deep $.extend with untrusted input

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 report has not been written yet. The Original tab links to the source.

Prototype pollution is a JavaScript bug where an attacker can add or change properties on the base object that all other objects inherit from. In this case, jQuery's deep extend function copies properties from an input object without checking for special names like __proto__, so an attacker can sneak in a property that affects every object in the page. This can change how the application behaves, for example by turning on a debug mode or altering default settings.

What is Prototype pollution?

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

More by asgerf

View all

7 more disclosed reports, best first.

More from Node.js third-party modules

View all

The newest disclosed reports for this program.

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.