rivet-dev/secure-exec

Secure Node.js Execution Without a Sandbox A lightweight library for secure Node.js execution. No containers, no VMs — just npm-compatible sandboxing out of the box.

What it solves

Secure Exec provides a way to run untrusted Node.js and TypeScript code safely without the overhead of containers, virtual machines, or external sandbox providers. It specifically targets the need for AI agents to write and execute code in a secure environment where resource usage is capped and host access is strictly controlled.

How it works

The library uses V8 isolates—the same isolation technology used by Chrome browser tabs and Cloudflare Workers—to create lightweight execution boundaries. Instead of booting a full OS, it runs code within the host process using a virtual kernel and a system bridge. This allows for native V8 performance (including JIT compilation) while maintaining a "deny-by-default" permission model for networking, filesystem access, and child processes.

Who it’s for

  • Developers building AI agents that need to execute generated code (compatible with Vercel AI SDK, LangChain, etc.).
  • Developers creating interactive coding playgrounds or plugin systems.
  • Users who want to run user-submitted scripts or dev servers (like Express or Hono) without managing complex infrastructure like Docker.

Highlights

  • Zero Infrastructure: No Docker daemon, hypervisor, or vendor accounts required; installable via npm.
  • Granular Permissions: Deny-by-default access to the filesystem, network, and environment variables.
  • Resource Limits: Deterministic termination of runaway code via CPU time budgets and memory caps.
  • Node.js Compatibility: Supports core modules like fs, http, and child_process, and allows dynamic npm module installation.
  • High Efficiency: Significantly lower cold-start times and memory footprint compared to traditional container-based sandboxes.