{
  "id": 21329395,
  "title": "node:vm, vm2 and Python's exec are not sandboxes: in-process isolation and why it fails",
  "url": "https://urgent.news/2026/11/23/node-vm-vm2-and-pythons-exec-are-not-sandboxes-in-process-isolation",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-11-23T01:35:21.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/sandscale/nodevm-vm2-and-pythons-exec-are-not-sandboxes-in-process-isolation-and-why-it-fails-496l"
  },
  "original_language": "en",
  "account": "The popular method of running code from model-generated prompts in the same process as your application, using language features like Node's vm module or Python's exec with a stripped-down __builtins__, does not provide any real security isolation. Both runtimes explicitly warn against using them for untrusted code, as the documentation clearly states. While these methods make it easy to demonstrate running untrusted code, they fail to isolate the code from your process, heap, and permissions. The Node escape vm.runInNewContext runs code with a different global object, but it does not execute it in a separate heap, process, or permission set. Objects passed into the context, including the context object itself, come from the outer world, and JavaScript objects can always reach their constructor. This means that even with these language-level tricks, the untrusted code can still access the host's global objects and execute arbitrary code in the host's realm. Similarly, Python's exec or eval can still access built-in functions and objects, even when they are stripped down to an empty dictionary. One notable example is the CVE-2023-37466 vulnerability in the vm2 library, which allowed attackers to bypass sandboxing by exploiting the @@species accessor property. The project's README now advises against using vm2 for production due to critical security issues. The issue is that intercepting every path between two worlds that share a heap is an impossible task. The solution is to put a boundary enforced by the operating system or hardware between the untrusted code and your application. This can be achieved by running the code in a separate process with reduced privileges, in a container with a hardened profile, or in a microVM or user-space kernel for highly untrusted code. SandScales provides a solution by running each code run in a separate Firecracker microVM with its own kernel, giving each run its own operating system boundary.",
  "summary": "The first version of many agent tools runs model-written code the quick way: inside the same process, with a language feature that sounds like isolation. In Node that is the vm module. In Python it is exec with a stripped-down __builtins__ . It works in the demo, it is easy, and it does not isolate anything. This post shows why, using the languages' own documentation and two escapes short enough…",
  "key_points": [
    "Node's vm module and Python's exec do not provide real security isolation for untrusted code.",
    "Both runtimes explicitly warn against using them for untrusted code due to lack of isolation."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}