Junglewise Threat Intelligence

patriksimek vm2 prototype pollution in stack-trace formatter

Severity: low · CVSS 2.1 · Published 2026-05-29

Technologies: Patriksimek Vm2. Vendors: npm.

Executive brief

vm2 is a library used to run untrusted code in a secure, isolated environment. A flaw was found where the sandbox's internal error handling could be intercepted by the untrusted code it is supposed to isolate. While this specific instance only allows the untrusted code to observe internal data (a side channel), it violates core security design principles and could be used as a building block for more serious attacks in the future.

Technical details

A vulnerability exists in `lib/setup-sandbox.js` within the `defaultSandboxPrepareStackTrace` function. The component appends stack trace lines to an array using standard index assignment (`lines[lines.length] = value`), which triggers the JavaScript prototype chain. An attacker within the sandbox can define a setter on `Array.prototype` to intercept these writes. While the current impact is limited to a side channel (observing formatted stack frames), it violates 'Defense Invariant #11' which requires bridge-internal containers to use prototype-bypassing primitives like `Reflect.defineProperty`. This flaw could potentially be escalated if future updates pass host-realm references through this codepath. The issue is fixed in version 3.11.4.

Affected products

  • patriksimek vm2 <= 3.11.3

Timeline

  • 2026-05-18: disclosed
  • 2026-05-29: advisory
  • 2026-05-29: patched: Fixed in version 3.11.4

References

Related threats