Skip to content

Commit

Permalink
Merge pull request #468 from XmiliaH/fix-467
Browse files Browse the repository at this point in the history
Fix 467
  • Loading branch information
XmiliaH committed Aug 28, 2022
2 parents 58478a5 + d9a7f3c commit d6379e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/setup-sandbox.js
Expand Up @@ -67,7 +67,8 @@ Object.defineProperties(global, {
global: {value: global, writable: true, configurable: true, enumerable: true},
globalThis: {value: global, writable: true, configurable: true},
GLOBAL: {value: global, writable: true, configurable: true},
root: {value: global, writable: true, configurable: true}
root: {value: global, writable: true, configurable: true},
Error: {value: LocalError}
});

if (!localReflectDefineProperty(global, 'VMError', {
Expand Down
7 changes: 7 additions & 0 deletions test/vm.js
Expand Up @@ -1070,6 +1070,13 @@ describe('VM', () => {
Error.prepareStackTrace = undefined;
stack.process
`));
assert.throws(()=>vm2.run(`(()=>{
const OldError = Error;
global.Error = {prepareStackTrace: (_, c) => c.map(c => c.getThis()).find(a => a && a.process)};
const { stack } = new OldError();
global.Error = OldError;
return stack.process.mainModule;
})()`));
});

it('Node internal prepareStackTrace attack', () => {
Expand Down

0 comments on commit d6379e1

Please sign in to comment.