vm2
CVE-2026-47698 · GHSA-cfcw-xp6x-25gj
Sandbox breakout through dangerous host prototype mutators
Critical, 9.8 · Public source snapshot: November 12, 2026
Original portfolio report · Public advisory
Shared credits and the scope of my investigation are documented below.
CVE-2026-47698 · GHSA-cfcw-xp6x-25gj · vm2 · Critical
Public security research by Charles Vosburgh (
the-vibe-dev). The public advisory credits multiple reporters; this write-up does not claim sole discovery.
| Field | Value |
|---|---|
| Package | vm2 |
| Ecosystem | npm / Node.js |
| Severity | Critical |
| CVSS | 9.8 — CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| Public affected range | <= 3.11.5 in the GHSA; CVE record describes < 3.11.6 |
| Fixed | 3.11.6 |
| Weakness | CWE-913 — Improper Control of Dynamically-Managed Code Resources |
| Public PoC | Yes — published with the GHSA |
| Credit | Charles Vosburgh (the-vibe-dev) is one of the publicly credited reporters |
vm2's VM is intended to run untrusted JavaScript without allowing that code to obtain raw host-realm capabilities. In affected releases, a dangerous host prototype mutator could still be invoked by wrapping it in stacked Function.prototype.call indirection. That allowed sandbox code to alter the prototype chain of a host error object, recover the host Function constructor, and execute JavaScript with host-process authority.
This is a sandbox-boundary failure. It does not rely on vm2's documented nesting behavior, exposed require, host-module mocks, authentication bypass, or a network protocol weakness. The relevant prerequisite is the one vm2 is specifically designed to handle: an application intentionally executes less-trusted JavaScript inside VM.
Security invariant: A blocked host capability must remain blocked through every semantically equivalent invocation shape, not only direct and first-order wrapper forms.
vm2 mediates values crossing between sandbox and host through proxy handlers in lib/bridge.js. A key security responsibility of that bridge is preventing sandbox code from receiving or invoking host functions that can mutate host object relationships in unsafe ways.
Prior hardening recognized dangerous host prototype mutators and blocked direct invocation. Release 3.11.5 also attempted to account for a single layer of Function.prototype.call, apply, or bind indirection:
if (isApplyIndirectionPrimitive(object)) {
let underlying;
try { underlying = otherFromThis(context); } catch (e) {}
if (isDangerousHostProtoMutator(underlying)) throw new VMError(OPNA);
}
That logic inspects the context value for the one-layer form. In the stacked public bypass, both the outer applied object and context are themselves Function.prototype.call; the dangerous setter has moved deeper into the argument list. The guard therefore recognizes the wrapper but not the underlying semantic capability.
The public PoC uses the host Object.prototype.__proto__ getter/setter and a host error produced through a WebAssembly streaming failure path. By applying the host prototype setter through nested call indirection, the sandbox severs the prototype chain of a host error. A later exception crosses the bridge with a prototype shape the mapping logic does not expect. From the exposed value, constructor.constructor resolves to the host Function constructor.
Once the host constructor is recovered, code can be evaluated in the host realm rather than in vm2's sandbox realm.
The one-layer protection first appeared in public commit:
27c525f4615e2b983f122e2bed327d810126f5c8
and was released in 3.11.4 as hardening for an earlier issue. The stacked variant demonstrates why fixed-depth wrapper inspection is not a complete mediation strategy.
Fix
The public fix is commit:
a85acb61f81402c6eabf32760aa11272af6d0f9e
released in vm2 3.11.6.
The fix adds controls at more fundamental boundaries. Host-to-sandbox conversion helpers refuse to deliver dangerous host prototype mutators, while exception handling rejects foreign host values whose prototype chain reaches null without traversing the sandbox's expected Object.prototype boundary.
That is stronger than adding one more call-depth check: it blocks the capability at the crossing point and hardens the corrupted-object path used by the public exploit chain.
The defense was too syntactic. It recognized a dangerous function when called directly and when wrapped in a small number of anticipated ways, but JavaScript's invocation machinery allows the same function capability to survive arbitrary wrapper composition.
A security membrane should reason about the underlying host capability reaching the sandbox, not about a fixed set of surface call shapes.
flowchart TD
A[Application executes untrusted JavaScript in vm2 VM]
B[Sandbox obtains a host-realm prototype mutator through an exposed path]
C[Mutator is wrapped in nested Function.prototype.call indirection]
D[One-layer guard fails to identify the deeper dangerous target]
E[Host error prototype chain is corrupted]
F[Bridge exposes a host constructor path]
G[Sandbox recovers host Function and executes outside isolation]
A --> B --> C --> D --> E --> F --> G
The demonstrated path depends on a compatible host-error carrier. Retained validation reproduced the relevant error path on multiple modern Node.js releases; that runtime detail should not be generalized to every Node version without testing.
The PoC is already public in GHSA-cfcw-xp6x-25gj and is not duplicated as a separate repository artifact here.
The public demonstration uses marker-style host execution rather than destructive behavior. Its key controls are:
- sandbox execution begins inside
new VM().run(...); require,nesting, host modules, and custom compiler features are not needed for the demonstratedVMpath;- the exploit uses a host prototype mutator that vm2 intended to mediate;
- a single-layer wrapper is not the security bypass—the important step is stacked invocation indirection;
- the resulting constructor is a host-realm
Function, not merely a sandbox constructor.
The public PoC should only be run against disposable local installations or other explicitly authorized systems.
Recovering the host Function constructor breaks the core isolation guarantee of vm2. Code that an application intended to constrain to a JavaScript sandbox can instead execute with the authority of the Node.js host process.
That can expose any files, environment variables, process credentials, network access, or operating-system capabilities available to the embedding Node process. The exact downstream impact depends on how the application runs vm2 and what privileges the host process has.
The published advisory rates the issue Critical, CVSS 9.8.
The GitHub Security Advisory identifies versions through 3.11.5 as affected and 3.11.6 as fixed. The CVE record expresses the fixed boundary as <3.11.6.
Direct review covered 3.11.5, 3.11.6, the fixing change, and the earlier one-layer guard. The wider historical range is retained as the publisher's claim rather than presented as release-by-release independent execution.
The earlier hardening in 3.11.4 did not introduce the underlying host-prototype mutation family; it merely added an incomplete guard. The exact first affected vm2 release was not independently established in this review.
Upgrade to vm2 3.11.6 or later for this vulnerability family, and verify whether later vm2 advisories affect the intended deployment before relying on the sandbox.
For sandbox implementers, regression testing should cover semantic capability equivalence rather than a handful of syntax patterns. Dangerous host functions should remain blocked through nested call, apply, bind, proxy wrappers, and other function-forwarding constructions.
Exception-translation code should also reject malformed or unexpectedly rooted host prototype chains rather than attempting to continue mapping potentially corrupted host objects.
| Date | Event |
|---|---|
| 2026-08-14 | Public GHSA and PoC published. |
| 2026-08 | vm2 3.11.6 published with the fixing changes. |
| 2026-08-26 | Public source, release boundaries, and retained controls re-reviewed. |
CVE-2026-47698 / GHSA-cfcw-xp6x-25gj shows why sandbox mediation cannot safely depend on recognizing a bounded set of JavaScript call shapes. In affected vm2 releases, a dangerous host prototype mutator remained reachable through deeper invocation indirection, enabling a host-object corruption chain and recovery of the host Function constructor.
Version 3.11.6 moves the defense closer to the real trust boundary by refusing dangerous host mutators during value conversion and hardening exception handling against corrupted foreign prototype chains.
Broader lesson: Sandbox policy must follow capabilities through equivalent representations. If the capability crosses the membrane, changing the syntax used to invoke it must not change the security decision.
- https://github.com/patriksimek/vm2/security/advisories/GHSA-cfcw-xp6x-25gj
I (the-vibe-dev) am one of the reporters credited by the public advisory. This write-up intentionally preserves shared attribution.
Research was AI-assisted for source mapping, hypothesis generation, release comparison, and evidence organization. I performed the final validation, disclosure coordination, severity calibration, and publication review.
This write-up documents a publicly disclosed sandbox vulnerability for defensive research, remediation, regression testing, and authorized assessment. Do not use the public PoC against systems without explicit permission.