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
- 1Use Object.create(null) for objects that will receive user-controlled keys.
- 2Block __proto__, constructor, and prototype keys from user input explicitly.
- 3Use Map instead of plain objects for user-keyed data.
- 4Use safe deep merge libraries that protect against prototype pollution (lodash merge with version 4.17.11+).
Code examples
Safe merge with key filtering
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.
More ai code checks
- LowGeneric Error Messages Leak No Context
- MediumTODO/FIXME Security Note in Response
- Higheval() Usage in Page Scripts
- HighSSL Certificate Verification Disabled
- HighMath.random() Used for Security Tokens
- CriticalHardcoded Credential in Authentication Logic
- CriticalJWT 'none' Algorithm Accepted
- CriticalSQL String Concatenation Pattern Detected
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.