Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is Prototype Pollution?

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.

Illustration for the cybersecurity term Prototype Pollution
Home / Blog / Cybersecurity Terms / What Is Prototype Pollution?
17 November 2026

What Is Prototype Pollution?

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.

How the Write Happens

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.

From Pollution to Impact

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.

Vulnerabilities That Defined the Class

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.

Defending Against It

  1. Reject the dangerous keys. Any function that copies properties by name should skip __proto__, constructor, and prototype. Checking with Object.hasOwn rather than the in operator avoids reading inherited values as well.
  2. Use prototype-free objects for maps. Object.create(null) produces an object with no prototype, and Map is a better structure for key-value data from users in any case.
  3. Validate against a schema with AJV, Zod, or a similar library, so unexpected keys never reach a merge. Most schema validators strip unknown properties when configured to.
  4. Freeze the prototype at start-up. Object.freeze(Object.prototype) blocks the write outright. Test carefully, because some older libraries extend built-in prototypes legitimately.
  5. Run Node.js with --disable-proto=throw to remove the __proto__ accessor entirely.
  6. Keep dependencies patched through software composition analysis, since almost every published case has been in a library rather than in application code.

Testing for It

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.

FAQ – Frequently Asked Questions

Does Prototype Pollution Affect Languages Other Than JavaScript?

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.

Is It Exploitable Without a Gadget?

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.

Will Freezing Object.prototype Break Our Application?

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.

How Do We Find It in Our Dependencies?

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.

Related Terms

You May Be Interested In These

What Is the MOVEit Transfer Vulnerability?

Cybersecurity Terms

17 November 2026

What Is the MOVEit Transfer Vulnerability?

Read More
What Is ISO/IEC 27017?

Cybersecurity Terms

17 November 2026

What Is ISO/IEC 27017?

Read More
What Is Social Engineering?

Cybersecurity Terms

23 December 2020

What Is Social Engineering?

Read More