Prototype Pollution In fastest-json-copy

Description

Description

Version 1.0.1 of fastest-json-copy allows an external attacker to edit or add new properties to an object. This is possible because the application does not correctly validate the incoming JSON keys, thus allowing the __proto__ property to be edited.

Vulnerability

Prototype pollution is a vulnerability that affects JS. It occurs when a third party manages to modify the __proto__ of an object. JavaScript first checks if such a method/attribute exists in the object. If so, then it calls it. If not, it looks in the object's prototype. If the method/attribute is also not in the object's prototype, then the property is said to be undefined. Therefore, if an attacker succeeds in injecting the __proto__ property into an object, he will succeed in injecting or editing its properties.

Exploitation

exploit.js

const copy = require('fastest-json-copy');

let admin = {name: "admin", role:"admin"};
let user = {name: "user" , role:"user"};

let normal_user_request = JSON.parse('{"name":"user","role":"admin"}');
let malicious_user_request = JSON.parse('{"name":"user","__proto__":{"role":"admin"}}');
...

Evidence of exploitation

Our security policy

We have reserved the CVE-2022-41714 to refer to this issue from now on. Disclosure policy

System Information

    Version: fastest-json-copy 1.0.1

    Operating System: GNU/Linux

Mitigation

There is currently no patch available for this vulnerability.

References

Credits

The vulnerability was discovered by Carlos Bello from Fluid Attacks' Offensive Team.

Update Impact

Minimal update. May introduce new vulnerabilities or breaking changes.

Ecosystem
Package
Affected version