Resources / Code execution

Sandboxing for AI code: containers, gVisor, microVMs and WebAssembly compared

The main ways to sandbox AI-generated code — containers, user-space kernels, microVMs, WebAssembly and V8 isolates — and how to pick one.

A sandbox lets code run while limiting what it can touch: the file system, the network, other processes, other users' data, the host itself. For AI-generated code — which you haven't read and which an attacker may have influenced through prompt injection — the sandbox is the part that has to hold even when the code is wrong.

The options

### Containers (Docker, containerd)

Processes isolated with Linux namespaces and cgroups, sharing the host kernel.

### User-space kernels (gVisor)

A kernel implemented in user space intercepts the program's system calls, so the code never talks to the host kernel directly.

### MicroVMs (Firecracker, Cloud Hypervisor, Kata Containers)

Each workload gets its own lightweight virtual machine with its own kernel, booting in a fraction of a second.

### WebAssembly (Wasmtime, WasmEdge)

Code compiled to WebAssembly runs in a memory-safe runtime that can only use the capabilities you hand it (WASI).

### Language isolates (V8 isolates)

Many JavaScript contexts in one process, each with its own heap.

How to choose

If you need…Consider
Hostile multi-tenant code, any languageMicroVMs
Stronger containers without changing toolinggVisor
Millisecond starts, deny-by-defaultWebAssembly or isolates
Trusted internal codeHardened containers

The sandbox is only one layer

Whatever runs the code, also add:

On Wisp

Wisp gives every project its own isolated runtime and identity: a project's functions can reach only that project's storage, secrets and settings, run with fixed time and memory caps, and never see the model or Wisp's own credentials. You describe the code; the sandboxing, limits and scaling are already there. More on the security page.

Build it with Wisp — describe an API, get it live.

Related