Skip to content
XSS Write-up Advanced

Widespread prototype pollution gadgets

The article describes how client-side prototype pollution can be exploited through gadgets in browser APIs and common JavaScript libraries, allowing an attacker to achieve DOM XSS. It shows that functions like fetch, Object.defineProperty, localStorage, and third-party scripts such as Google Analytics and Tag Manager can be abused if a prototype pollution source exists.

Gareth Heyes Follow

Published on portswigger.net

We recently launched a new version of DOM Invader that can find Client-Side Prototype Pollution (CSPP).

Gareth Heyes (@garethheyes), on portswigger.net

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 the root cause is that JavaScript APIs and libraries accept objects as arguments and do not guard against inherited properties from Object.prototype, so a polluted prototype can control options like body, value, or callback functions.

What the attacker needed

A client-side prototype pollution source; victim visits a crafted URL; site uses a vulnerable library or API

The fix

The article recommends using objects with a null prototype when using browser APIs that accept objects, and scanning JavaScript libraries for gadgets before deploying them.

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.

Prototype pollution is a bug where an attacker can add or change properties on a base object that many other objects inherit from. If a website later uses one of those inherited properties without checking, it can lead to unexpected behaviour such as running attacker-controlled code. This article explains how common browser features and third-party scripts can act as such 'gadgets' when combined with a pollution source.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More by Gareth Heyes

View all

15 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.