Simon Willison 推出外部沙箱模式,让编码智能体安全执行代码
Simon Willison 和 Prime Radiant 发了三个开源沙箱服务器,让 Claude Code、Codex 这类编码智能体跑代码时隔离在沙箱里,还带域名白名单代理和密钥替换。想试本地模型又怕被提示注入搞坏机器的开发者可以直接上手。
Simon Willison 与 AI 研究实验室 Prime Radiant 合作发布外部沙箱模式,代码在专属沙箱内运行,智能体本身留在沙箱外,降低本地模型被提示注入攻击后破坏机器的风险。
项目提供三个实现:external-sandbox-v86 用 v86 在 WebAssembly 中运行 Alpine Linux 的 Node.js 服务器;external-sandbox-container 基于 Apple Containers 的 Python 服务器;external-sandbox-quicksand 使用微软 Quicksand 库,把 QEMU 和 Alpine Linux 打包进 Python 包。三者暴露同一套 localhost API。
沙箱附带可选的 HTTP/HTTPS 白名单代理,可精确控制智能体代码能访问哪些主机,并支持凭据替换机制,让代码调用需要认证的 API 时无需把密钥交给智能体。Pi、Claude Code 和 Codex 都可配置为将执行代码的请求发往沙箱。
External sandboxes for coding agents I've been exploring new ways to sandbox code that is executed by agents, with a focus on making it safer to try out local models without worrying that a mistake or prompt injection attack might cause them to take damaging actions on a machine. I worked on this project with Prime Radiant , the AI research lab behind Superpowers and other projects . My post on the Prime Radiant blog introduces the external sandbox pattern, where code executed by the agent runs inside a dedicated sandbox while the agent itself lives outside of that sandbox. To demonstrate this pattern we've released three sandbox server implementations: external-sandbox-v86 runs a Node.js server which then uses v86 to run Alpine Linux inside WebAssembly. external-sandbox-container is a Python web server which runs the sandbox in Alpine Linux inside an Apple Containers instance. external-sandbox-quicksand is another Python web server, this time using Microsoft's Quicksand sandboxing library, which bundles QEMU and Alpine Linux in a Python package! Each of these implementations offers the same localhost API. You can then configure Pi, Claude Code, or Codex to send API calls to that sandbox any time they want to execute code. The sandboxes also include an optional HTTP/HTTPS allow-list proxy, so you can control exactly which hosts your agent's code is allowed to communicate with - plus a credential replacement mechanism to make authenticated API calls without sharing a secret with the agent. Here's the UI you can use to reconfigure that proxy while the sandbox is still running: I continue to be fascinated by the challenge of safely running untrusted code. This external sandbox pattern provides a neat way to experiment with different approaches. Tags: sandboxing , security , ai , webassembly , generative-ai , llms , coding-agents , claude-code , codex , pi
This report is categorized under AITOP's "Products" desk, focusing on US frontier AI labs and Silicon Valley technology leaders. Within our cross-regional analytical framework, it directly maps to AI developer toolchains, coding agents, and engineering workflows. Key entities and technical topics under continuous tracking include Claude Code, Codex, sandbox, coding assistants.
Source attribution: curated from Simon Willison’s Weblog.