Preset policies
public_only is the default. It blocks private address ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8, 169.254.0.0/16) while allowing public internet access.
Custom policies
Build a policy with explicit egress and ingress rules. Rules are evaluated first-match-wins.Port mapping
Expose ports from the sandbox to the host so services running inside the VM are accessible from your machine. For Rust,SandboxBuilder::port() and port_udp() are top-level shorthands that compose with .network(...) when you also need policy, DNS, or TLS settings.
DNS interception
All DNS queries are intercepted and resolved on the host side. This enables domain blocking, suffix blocking, and rebinding protection.Secrets
Secrets use a placeholder substitution model. The guest VM never sees the real credential. When you bind a secret to an environment variable and one or more allowed hosts, microsandbox generates a random placeholder (e.g.,OPENAI_API_KEY=msb_ph_a8f3c2...) and injects that into the guest instead. The real value never enters the VM. The only way it reaches the outside world is when a request goes to an allowed host, at which point microsandbox swaps the placeholder for the real value. Everywhere else, the placeholder is just a meaningless string.
So even with full code execution inside the sandbox, there’s nothing to steal. The credential was never there.
TLS interception
Enable HTTPS traffic inspection with an auto-generated CA certificate. microsandbox generates a per-sandbox CA during creation, installs it in the guest’s trust store, and generates per-domain certificates on first connection. Domains that use certificate pinning (or that you don’t want to intercept) can be bypassed.Protocol support
For most sandboxed workloads, networking behaves the way you’d expect:- Normal outbound TCP and UDP traffic works, including common tools and libraries like
curl,wget, package managers, HTTP clients, database drivers, and DNS lookups. - DNS is intercepted on the host side, which is what enables domain blocking, rebinding protection, and secret-aware policy checks.
- ICMP echo is supported: Pinging external hosts works on systems that support unprivileged ICMP echo sockets.
Raw sockets and full ICMP forwarding are not supported because they require elevated privileges on the host. Tools that depend on richer ICMP behavior, such as
traceroute, are outside the current scope.