sx (sandbox-shell) is a Rust CLI that wraps shell sessions and commands in macOS Seatbelt sandboxes. It protects developers from malicious code in npm packages, untrusted repositories, and build scripts by restricting filesystem and network access.
Critical Seatbelt Rules:
- Root literal
(allow file-read* (literal "/"))is required for path traversal - processes need to read/to resolve paths - Seatbelt uses last-match-wins semantics when rules have matching filter types - deny rules after allow rules take precedence for nested paths (e.g., allow
/homethen deny/home/.ssh) (allow file-read-metadata)must be global (no path filter) - required forgetaddrinfo()DNS resolution to work. Without this,curl, Python, and other tools using the system resolver fail with "Could not resolve host" even when network is allowed. Commands likehostandnslookupwork without it because they use direct DNS UDP queries.
Configuration Options:
inherit_base = falsein.sandbox.tomlskips the base profile for full custom control over allowed paths
Produce code following LEAN, CLEAN, MINIMAL but thoughtful KISS & YAGNI principle.
Follow TDD paradigm red-green-refactor for unit test.
Follow Rust Book, Rust API Guidelines, and idiomatic Rust resources.