Running untrusted code requires stronger isolation than containers offer because containers share the host kernel and remain vulnerable to escapes, a threat classified by NIST SP 800-190 as critical and by MITRE ATT&CK as T1611. Network egress control must be allowlist-based rather than denylist-based, as code without filesystem access can still exfiltrate data or download payloads to attacker servers. Sprites provide hardware-isolated sandboxes with network policies enforced through an external API that code cannot modify, even with root access. They support checkpoint-based rollback, pre-installed runtimes for Python, Node, Ruby, Rust, Go, Java, Elixir, Bun, and Deno, and automatically sleep when idle. The post demonstrates creating a code-runner Sprite, applying a deny-all network policy, executing code via subprocess, and optionally permitting specific domains like api.openai.com while blocking all others.
Context
AI agents and tools generate or accept untrusted code that requires safe execution outside local or production environments.
Approach / What changed
Use Sprites to create sandboxed environments with hardware isolation, externally-enforced network policies, checkpoint rollback, and pre-installed runtimes. Set up a code-runner Sprite, apply a deny-all network policy via API, and execute untrusted code through subprocess calls within the Sprite. For selective network access, allowlist specific domains while blocking all others.
Takeaways
1
Containers are insufficient for running untrusted code because they share the host kernel and are vulnerable to escape (NIST SP 800-190 and MITRE ATT&CK T1611); hardware isolation with a dedicated kernel is required.
2
Network egress control must use an allowlist-based policy enforced externally; code inside the sandbox cannot modify its own network policy, even with root access.
3
Sprites provide disposable sandboxes with checkpoint-based rollback; if code corrupts the environment, you can destroy and recreate the Sprite or restore a working checkpoint in about one second.
FAQ
Why are containers not sufficient for untrusted code?
Containers share the host kernel, making them vulnerable to escapes. NIST SP 800-190 classifies container escapes as a critical threat and MITRE ATT&CK as technique T1611. Hardware isolation, such as a dedicated kernel, is required for truly untrusted code.
How do you control network access for sandboxed code?
Apply a deny-all outbound policy via the external API so code inside cannot modify it. Only allow specific domains needed. For example, allow api.openai.com and api.anthropic.com while blocking everything else. This prevents data exfiltration and unauthorized downloads.
What happens if the sandbox gets corrupted by a code run?
Sprites are disposable: destroy the Sprite and create a new one, or restore from a working checkpoint using 'sprite checkpoint restore' in about one second. Checkpoints save the state before running new code.
Clang's constant interpreter evaluates constant expressions at compile time, so the bill lands on your build, not your binary. This five-checkpoint guide shows where that memory goes and how to keep it small.
BitNet trades floating-point precision for a tiny, CPU-friendly footprint. This diagram maps the payoff—small memory and local serving—against the constraints that decide when the trade is worth it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.