Urgent.News

What's breaking now, across hundreds of outlets.

Tech

node:vm, vm2 and Python's exec are not sandboxes: in-process isolation and why it fails

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…

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.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

I Built 9 Free Browser-Based File & Image Tools That Run 100% Client-Side (No Uploads)

Most free online file converters come with the same frustrating catch: you have to upload your personal photos or sensitive PDFs to an unknown third-party server, wait in a processing queue, and hope…

  • UmarFilekit offers nine free, client-side tools for images, PDFs, and QR codes.
  • All tools process data directly in the browser, no uploads or accounts needed.
  • The toolkit simplifies tasks like HEIC to JPG conversion, PDF merging, and QR code generation.

Streaming 1 GiB CSV Diffs in a Web Worker Without Corrupting Leading Zeros

Reconciling two large CSV exports in the browser usually fails in one of three ways: Calling await file.text() on two 400 MB files blows past the tab heap limit before parsing even starts.

  • Web Worker architecture streams 1 GiB CSV diffs locally without exceeding tab heap limits
  • Preserve leading zeros and raw strings to accurately compare invoice IDs and other composite keys

More from Monday 23 November →