Explore our new Cybersecurity Terms Glossary, explained by our experts.
Cybersecurity Terms Glossary
Prototype pollution is a JavaScript vulnerability in which an attacker adds or changes properties on Object.prototype, altering the behaviour of every object in the application.

What Is Prototype Pollution?
JavaScript objects inherit from a prototype, and nearly every object in a program inherits ultimately from Object.prototype. Prototype pollution is an attack that reaches that shared object and writes a property onto it. From that moment, every object in the process that does not define the property itself appears to have the attacker’s value, including objects created by code that has nothing to do with the vulnerable function.
The entry point is almost always a function that copies properties from one object into another by name: a deep merge, a clone, a configuration loader, a query string parser, or a helper that sets a nested value from a dotted path. If the function walks the keys of attacker-supplied data and assigns them without checking, then a key of __proto__ redirects the write to the prototype.
merge({}, JSON.parse('{"__proto__": {"isAdmin": true}}'))
// afterwards, an unrelated object reports isAdmin === true
The equivalent routes are constructor.prototype and, in templating or path-based setters, a dotted string such as constructor.prototype.polluted. A JSON parser does not treat __proto__ specially, which is why parsing untrusted JSON and then merging it is the classic sequence.
Writing a property on its own does nothing visible. The impact comes from a gadget: existing code that reads a property it expects to be absent and does something consequential with the value.
if (user.isAdmin) succeeds for every user once the property exists on the prototype.toString breaks code across the whole process in ways that are difficult to diagnose.CVE-2019-10744 affected lodash before version 4.17.12, where defaultsDeep could be made to modify the prototype; lodash is a dependency of a very large share of the npm ecosystem, so the advisory reached an enormous number of projects. CVE-2020-7598 covered minimist, a command line argument parser used by countless build tools, where an argument of --__proto__.x achieved the same. CVE-2019-11358 addressed jQuery before 3.4.0, where an extend operation could pollute the prototype from attacker-controlled JSON. The pattern in each case is the same: a small utility, used everywhere, whose convenience function walks untrusted keys.
__proto__, constructor, and prototype. Checking with Object.hasOwn rather than the in operator avoids reading inherited values as well.Object.create(null) produces an object with no prototype, and Map is a better structure for key-value data from users in any case.Object.freeze(Object.prototype) blocks the write outright. Test carefully, because some older libraries extend built-in prototypes legitimately.--disable-proto=throw to remove the __proto__ accessor entirely.Server-side, submit a JSON body containing a __proto__ object with a property that would change behaviour visibly, such as a status code or a content type, then make an unrelated request and look for the effect. Client-side, append ?__proto__[test]=polluted to a URL and check in the console whether an empty object has acquired the property. Burp Suite includes a DOM Invader mode that automates the client-side search for both the injection point and a usable gadget. These checks form part of our web application security testing for Node.js and single-page applications.
The specific mechanism is JavaScript’s, because of how prototype-based inheritance works there. Conceptually similar issues exist elsewhere, such as mass assignment in Ruby and Python frameworks where attacker-controlled keys set object attributes, and class pollution in Python through the dunder class attribute. The defence is the same idea: never set properties by names supplied by a user.
Only as denial of service. Pollution by itself adds a property to a shared prototype; something else has to read that property and act on it for there to be impact. The gadget may be in your own code, in a framework, or in a dependency, and a new library version can introduce one into an application that was previously only polluted and not exploitable.
It can, so test it rather than deploying it blind. Code that legitimately extends built-in prototypes, which includes some older polyfills and a few analytics and charting libraries, will throw in strict mode or silently fail otherwise. Run the full test suite with the freeze in place; most modern codebases pass without changes.
Dependency scanning catches the known cases, because published prototype pollution issues in packages such as lodash, minimist, and jQuery all have advisories and fixed versions. What scanning will not tell you is whether your own merge, clone, or configuration helpers have the same defect, which needs a code search for functions that assign properties from untrusted keys.
You May Be Interested In These
We use a few cookies that are needed to make this website work, and they are always on. We would also like to set analytics cookies, to see which pages are useful; functional cookies, so that our live chat works; and advertising cookies, to measure our campaigns. We will not set any of those until you say yes, and you can change your mind at any time from the Cookie Settings link in the footer.
Choose the cookies you are happy for us to use. Strictly necessary cookies are always on; everything else is off until you turn it on.
These cookies keep the website working: they hold your security checks, your form submissions and the choice you make here. The site cannot run without them, so they are always on.
These let our live chat open and remember your conversation, and let the newsletter sign-up work. Switch them off and the chat window will not appear.
These tell us which pages are read and how people find us, so that we can improve the site. The reports are about groups of visitors, never about you personally.
These let us measure our advertising and show you our adverts on other websites, such as LinkedIn, Google and Meta. Switch them off and you will still see adverts, but they will be less relevant.