---
id: "CVE-2026-24118"
kind: "vulnerability"
aliases: ["CVE-2026-24118", "GHSA-grj5-jjm8-h35p"]
title: "VM2 Sandbox Breakout Through __lookupGetter__"
severity: "critical"
cvss: 9.8
epss: 0.00905
exploited: false
status: "open"
category: "package"
products: [{"name": "vm2", "fixed": ["3.11.0"], "affected": "< 3.11.0", "ecosystem": "npm"}, {"name": "vm2 project vm2", "fixed": ["3.11.0"], "affected": "< 3.11.0", "ecosystem": "vendor"}]
ecosystems: ["npm", "vendor"]
tags: ["cwe-693", "cwe-749", "cwe-94", "javascript", "node.js", "package", "sandboxing", "vm2"]
not_affected_if: ["fixed-3.11.0-or-later", "no-untrusted-code", "vm2-not-installed"]
published_at: "2026-05-04T16:29:15+00:00"
first_seen_at: "2026-11-04T03:31:21+00:00"
updated_at: "2026-11-04T03:46:40+00:00"
sources: [{"source": "ghsa", "url": "https://github.com/advisories/GHSA-grj5-jjm8-h35p", "first_seen_at": "2026-11-04T03:31:21+00:00"}, {"source": "nvd", "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-24118", "first_seen_at": "2026-11-04T03:46:40+00:00"}]
---

# VM2 Sandbox Breakout Through __lookupGetter__

vm2 is a Node.js library that runs untrusted JavaScript in a sandbox. A flaw in how __lookupGetter__ crosses between sandbox and host lets sandboxed code reach the host Function constructor and run arbitrary shell commands on the server.

_Summary, check and fix written by a model from the sources; labelled as such._

## Affected

- npm:vm2 affected < 3.11.0 fixed 3.11.0
- vendor:vm2 project vm2 affected < 3.11.0 fixed 3.11.0

## How to check

- Run `npm ls vm2` in each project to see whether vm2 is installed and at what version.
- Search lockfiles (`package-lock.json`, `yarn.lock`, `pnpm-lock.yaml`) for `vm2`.
- Check whether any code path passes user-supplied or third-party code to `new VM()` or `NodeVM` from vm2.

## Fix

- vm2 `3.11.0` (fixed version; earlier versions are affected)

## Timeline

- 2026-11-04T03:31:21+00:00 ghsa https://github.com/advisories/GHSA-grj5-jjm8-h35p
- 2026-11-04T03:46:40+00:00 nvd https://nvd.nist.gov/vuln/detail/CVE-2026-24118

## Documents

- [advisory] Maintainer's advisory: api.github.com https://api.github.com/repos/patriksimek/vm2/security-advisories/GHSA-grj5-jjm8-h35p
- [advisory] Maintainer's advisory: github.com https://github.com/patriksimek/vm2/security/advisories/GHSA-grj5-jjm8-h35p
- [fix] Patch: github.com https://github.com/patriksimek/vm2/commit/2b5f3e3a060d9088f5e1cdd585d683d491f990a3
- [fix] Patch: github.com https://github.com/patriksimek/vm2/commit/f9b700b1c7d9ef2df416666cb24e0b659140cc74
- [fix] Release: github.com https://github.com/patriksimek/vm2/releases/tag/v3.11.0

## From the sources

### Summary

VM2 suffers from a sandbox breakout vulnerability. This allows attackers to write code which can escape from the VM2 sandbox and execute arbitrary commands on the host system.

### Details

The `__lookupGetter__` method allows to read the getter of an object. It is special in VM2 since it will switch between the host and sandbox version of the method when passed to the other context.
This allows to access getters on an object in the host context if the method is called from the host context which can be achieved by using the host `apply` method which can be accessed through `Buffer.apply`.
Afterwards, this function can be used to call the host version of `__lookupGetter__` with `Buffer` and `__proto__` resulting in the prototype lookup method from the host context.
With this method the hosts `Function.prototype` object can be retrieved and the host `Function` acquired through the `constructor` property which allows to create and run code in the host context.
This issue was attempted to be fixed with https://github.com/patriksimek/vm2/blob/4b009c2d4b1131c01810c1205e641d614c322a29/lib/bridge.js#L427. However, this can be circumvented by using `Object.getOwnPropertyDescriptor` to get the `constructor` property.

### PoC

The following code demonstrates this issue by acquiring the host process object and executing `touch pwned`.

```js
const {VM} = require("vm2");
const vm = new VM();
vm.run(`
const g = ({}).__lookupGetter__;
const a = Buffer.apply;
const p = a.apply(g, [Buffer, ['__proto__']]);
Object.getOwnPropertyDescriptor(p.call(a),'constructor').value('return process')().mainModule.require('child_process').execSync('touch pwned');
`);
```

### Impact

Attackers can perform Remote Code Execution under the assumption that arbitrary code can be executed inside the context of a vm2 sandbox.

---

_Free to read at a human pace. An API with keys and an MCP server are in preparation; early access: hello@infrastack.ai_
