Running Python code in a sandbox with MicroPython and WASM

Simon Willison ยท email ยท 2026-06-06 Reader ๐Ÿ–ฅ๏ธ

Agent SecurityCoding AgentsLethal TrifectaSandboxingVibe Coding
WebAssembly-embedded MicroPython is the first Python sandbox that meets all the criteria Willison thinks a trustworthy in-process sandbox must satisfy โ€” clean PyPI install, memory/CPU limits, controlled file and network access, host-function interop, and active upstream maintenance โ€” making it the right substrate for safely running plugin and agent-generated Python code.

practical ยท mixed โ€” Lead piece is a practical/expository build log with embedded argument about sandbox requirements. The newsletter wrapper bolts on a roundup of links and quotes; through-line is sandboxing-for-agent-executed-code.

Structure

PartRole
Motivation: plugin systems and agent-generated code both need a way to run untrusted Python without full host privilegescontext โ€” establishes the problem the sandbox is meant to solve
Requirements list: six criteria a usable sandbox must meet (install, memory, CPU, files, network, host functions, maintenance)evaluative framework โ€” sets the bar against which all candidates are judged
Survey of alternatives: JavaScript engines too complex; Pyodide browser-only; MicroPython designed for constrained environmentsevidence by elimination โ€” narrows the space to MicroPython+WASM
Build log: using GPT-5.5 Pro and Codex to compile MicroPython to WASM, solve persistent interpreter state via a queue/eval loop, expose host functions in 78 lines of Cexistence proof โ€” shows the approach is viable
Trust caveat: 'should you trust my vibe-coded sandbox?' โ€” alpha, irony acknowledged, hopes professional security teams will adopt the approachhonest scoping โ€” bounds the claim being made
Roundup items: Anthropic's containment doc, OpenAI Lockdown Mode, Meta AI account-takeover failure, Uber AI spend caps, Charity Majors enthusiasts-vs-skepticsambient reinforcement โ€” most touch sandboxing, exfiltration, or agent-spend governance

Key terms

Propositions

Arguments

MicroPython+WASM is the right substrate for a Python sandbox embeddable in Python applications. strength: high
Explicit premises:
Implicit premises:
Inferences:
It's defensible to ship an alpha sandbox built largely with coding agents because the WASM boundary contains failures. strength: medium
Explicit premises:
Implicit premises:
Inferences:
Cutting exfiltration is the right industry-wide defense posture for LLM systems exposed to untrusted content. strength: high
Explicit premises:
Implicit premises:
Inferences:

Narratives

Questions addressed

Gaps

Closes gaps elsewhere

Related documents