jquense / yup

Dead simple Object schema validation
MIT License
22.72k stars 925 forks source link

Prototype Pollution Affecting property-expr@1.5.0 #2220

Open syukronarie opened 3 months ago

syukronarie commented 3 months ago

Describe the bug Prototype Pollution Affecting property-expr package, versions <2.0.3

property-expr is a tiny util for getting and setting deep object props safely

Affected versions of this package are vulnerable to Prototype Pollution via the setter function.

POC

var expr = require('property-expr');
expr.setter('__proto__.polluted')({}, true);
console.log(polluted); // true

Details: Prototype Pollution is a vulnerability affecting JavaScript. Prototype Pollution refers to the ability to inject properties into existing JavaScript language construct prototypes, such as objects. JavaScript allows all Object attributes to be altered, including their magical attributes such as __proto__, constructor and prototype. An attacker manipulates these attributes to overwrite, or pollute, a JavaScript application object prototype of the base object by injecting other values. Properties on the Object.prototype are then inherited by all the JavaScript objects through the prototype chain. When that happens, this leads to either denial of service by triggering JavaScript exceptions, or it tampers with the application source code to force the code path that the attacker injects, thereby leading to remote code execution.

There are two main ways in which the pollution of prototypes occurs:

How to fix? Upgrade property-expr to version 2.0.3 or higher.

Reference: https://security.snyk.io/vuln/SNYK-JS-PROPERTYEXPR-598800