Skip to main content
HighAI codeCWE-1321

How to fix: Prototype Pollution Vulnerability Risk

Deep merge or property assignment with user-controlled keys was detected. When user input can set `__proto__`, constructor, or prototype properties, attackers can pollute the JavaScript prototype chain.

Why it matters

Prototype pollution can enable remote code execution, privilege escalation, and denial of service. Attackers can inject properties into Object.prototype that affect all objects in the application, bypassing security checks that rely on undefined properties being falsy.

AI tools generate deep merge utilities and Object.assign patterns to merge configuration. When the keys come from user input, an attacker can send { '__proto__': { 'isAdmin': true } } to pollute all objects with isAdmin: true.

How to fix it

  1. 1Use Object.create(null) for objects that will receive user-controlled keys.
  2. 2Block __proto__, constructor, and prototype keys from user input explicitly.
  3. 3Use Map instead of plain objects for user-keyed data.
  4. 4Use safe deep merge libraries that protect against prototype pollution (lodash merge with version 4.17.11+).

Code examples

Safe merge with key filtering

TypeScript
function safeMerge(target: Record<string, unknown>, source: Record<string, unknown>) {
  for (const key of Object.keys(source)) {
    // Block prototype pollution keys
    if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue;
    target[key] = source[key];
  }
  return target;
}

References

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

See every ai code check

Questions

How severe is Prototype Pollution Vulnerability Risk?
VulnRadar rates this high severity in the ai code 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 vibe-prototype-pollution, which stays the same between runs so you can filter, diff, or gate CI on it.
Which standards does Prototype Pollution Vulnerability 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 prototype pollution vulnerability 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

Prototype Pollution Vulnerability Risk fix | VulnRadar