Running Python code in a sandbox with MicroPython and WASM
Simon Willison explores sandboxed Python execution using MicroPython compiled to WebAssembly via wasmtime.
Simon Willison describes his latest attempt to safely run Python plugin-style code inside his own applications. The alpha package micropython-wasm uses MicroPython compiled to WebAssembly, executed through the maintained wasmtime Python library. His goals include clean PyPI installation, CPU and memory limits, controlled file and network access, host functions, and reliable documentation.
In this article, Simon Willison summarizes his latest progress in his years-long search for a Python code-sandboxing solution. His core need stems from his own open-source ecosystem: Datasette, LLM, and sqlite-utils all support plugins, and the plugin system brings great extensibility, allowing users or third parties to quickly try out new features without having to merge every idea into the core application. But existing plugins are mostly run via Python and Pluggy, meaning the plugin code operates with full privileges within the main application; once a plugin has a bug or contains malicious code, it could corrupt data, read unauthorized files, or even leak private information.
Free shows the 3-line summary; Pro unlocks the full deep summary (~300 words) so you never have to click through.
See Pro plans →Want the original English / full article?
Read on Simon Willison's Weblog →Related
Summaries are AI-generated; the original article is authoritative.