Skip to main content
HighClient-sideCWE-1321

How to fix: Client-Side Prototype Pollution Risk

A client-side prototype pollution pattern was detected. Deep merge operations, recursive object assignment, or direct __proto__ manipulation with user-controlled keys can corrupt the JavaScript prototype chain.

Why it matters

Client-side prototype pollution can bypass security checks (if (user.isAdmin) checks become if (true) after pollution), corrupt application state, and in some cases enable XSS through gadget chains in popular libraries.

When user-controlled data is merged into objects without key filtering, attackers can set the __proto__ property to inject values into all objects. Libraries like lodash, jQuery, and many others have had prototype pollution CVEs.

How to fix it

  1. 1Use Object.create(null) for objects with user-controlled keys.
  2. 2Filter __proto__, constructor, and prototype from all user-supplied keys.
  3. 3Upgrade lodash to 4.17.21+ (patched against prototype pollution in merge/set).
  4. 4Use Map instead of plain objects for user-keyed data.

Code examples

Key filtering

JavaScript
const BLOCKED_KEYS = new Set(['__proto__', 'constructor', 'prototype']);

function safeMerge(target, source) {
  for (const [key, value] of Object.entries(source)) {
    if (BLOCKED_KEYS.has(key)) continue;
    target[key] = value;
  }
  return target;
}

References

Detected automatically by VulnRadar. The check id is prototype-pollution-client, stable across every scan so you can filter or diff on it.

See every client-side check

Questions

How severe is Client-Side Prototype Pollution Risk?
VulnRadar rates this high severity in the client-side category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
Does VulnRadar check for this automatically?
Yes. It runs as part of every scan under the check id prototype-pollution-client, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Client-Side Prototype Pollution Risk map to?
It maps to CWE-1321.

Missing a check?

The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.

Propose a checkHow a check is built

Scan your own site for client-side prototype pollution risk

VulnRadar runs this check and hundreds more against a URL in seconds. No agent to install, just paste a URL.

Or scan this site as a demoRead the docs

How to fix: Client-Side Prototype Pollution Risk | VulnRadar