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
I recently opened a PR (scssyworks/deparam.js#24) on deparam.js, another fork of jQuery BBQ’s deparam. The PR fixes a prototype pollution vulnerability that happens because browsers support the non-standard-but-de-facto -universal __proto__ magic property to access an object’s prototype.
I found that objects created using Object.create(null) don’t have this vulnerability:
deparam('__proto__[test]=1');// Will put test on Object.prototypedeparam('test[__proto__][test]=1');// Will put test on Object.prototype
It’s still present in arrays, however:
deparam('test[]=1&test[__proto__][test]=2');// Will put test on Array.prototypedeparam('test[]=1&test[__proto__][__proto__][test]=2');// Will put test on Object.prototype
https://github.com/scssyworks/deparam.js coerces arrays to objects as soon as a non-numeric index is accessed, so the fix from there is not directly translatable to this project.
Let me take this moment to say that introducing __proto__ was one of the great mistakes in the history of JavaScript… Granted, Symbol hadn’t been invented yet so obj[Symbol.proto] or similar might have seemed non-trivial at the time but the now-standard way Object.getPrototypeOf(obj)/Object.setPrototypeOf(obj, {}) was definitely an option back then…
The text was updated successfully, but these errors were encountered:
I recently opened a PR (scssyworks/deparam.js#24) on deparam.js, another fork of jQuery BBQ’s deparam. The PR fixes a prototype pollution vulnerability that happens because browsers support the non-standard-but-de-facto -universal
__proto__
magic property to access an object’s prototype.I found that objects created using
Object.create(null)
don’t have this vulnerability:This fixes the problem for the following cases:
It’s still present in arrays, however:
https://github.com/scssyworks/deparam.js coerces arrays to objects as soon as a non-numeric index is accessed, so the fix from there is not directly translatable to this project.
Let me take this moment to say that introducing
__proto__
was one of the great mistakes in the history of JavaScript… Granted, Symbol hadn’t been invented yet soobj[Symbol.proto]
or similar might have seemed non-trivial at the time but the now-standard wayObject.getPrototypeOf(obj)
/Object.setPrototypeOf(obj, {})
was definitely an option back then…The text was updated successfully, but these errors were encountered: