2o3t / 2o3t-Utility

很简单的Node.js基本工具库. A simple tools for Node.js
0 stars 0 forks source link

Prototype pollution Vulnerability affecting 2o3t-Utility, versions * #1

Open tariqhawis opened 9 months ago

tariqhawis commented 9 months ago

Prototype Pollution vulnerability in 2o3t-Utility npm package (latest).

  1. Vulnerable functionality is exported here: https:/github.com/2o3t/2o3t-Utility/blob/cbbdd0635b0f505955e5473faca53928834d643b/lib/file.js#L157.
  2. Vulnerable value can be introduced by an attacker here: https:/github.com/2o3t/2o3t-Utility/blob/cbbdd0635b0f505955e5473faca53928834d643b/lib/file.js#L157.
  3. The malicious argument flows into a vulnerable sink here: https:/github.com/2o3t/2o3t-Utility/blob/cbbdd0635b0f505955e5473faca53928834d643b/lib/file.js#L180 in "key" variable.

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.

poc:

var utilit = require('2o3t-utility');

var BAD_JSON = JSON.parse('{"proto":{"polluted":true}}'); var victim = {} console.log("Before Attack: ", JSON.stringify(victim.proto)); try { utilit.extend(true, {}, BAD_JSON) } catch (e) { } console.log("After Attack: ", JSON.stringify(victim.proto)); delete Object.prototype.polluted;

tariqhawis commented 8 months ago

Is there any updates on this?