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
- 1Use Object.create(null) for objects with user-controlled keys.
- 2Filter __proto__, constructor, and prototype from all user-supplied keys.
- 3Upgrade lodash to 4.17.21+ (patched against prototype pollution in merge/set).
- 4Use Map instead of plain objects for user-keyed data.
Code examples
Key filtering
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.
More client-side checks
- HighCSP Allows 'unsafe-inline' Scripts
- MediumCSP Allows 'unsafe-eval'
- HighpostMessage Without Origin Validation
- HighSensitive Data Stored in localStorage
- HighDOM XSS via location.hash Assignment
- Highdocument.write() in Page Scripts
- Higheval() in Client-Side JavaScript
- MediumExternal Script Without Subresource Integrity
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.