Simon Willison describes building micropython-wasm, an alpha Python package that runs untrusted Python code inside a WebAssembly sandbox using MicroPython compiled to WASI and the wasmtime runtime. The approach satisfies his key requirements: clean PyPI installation, memory and CPU limits (via wasmtime's fuel mechanism), controlled file and network access, and support for host functions. A persistent interpreter session is achieved by running MicroPython in a thread with a request queue, allowing variables to persist across multiple eval() calls. The C host module (78 lines) is compiled into a 362KB WASM blob shipped with the package. The project was largely built with AI coding agents (Codex, GPT-5.5). Willison acknowledges the irony of releasing yet another alpha sandbox library but is using it in his datasette-agent-micropython plugin and has stress-tested it against escape attempts.

8m read timeFrom simonwillison.net
Post cover image
4.6K Impressions1 Comment