Kagex/Guides
PID 1 · gRPCPlatforms & Hypervisors · 5 min read

How sandbox-agent Works: PID 1 Linux Guest Agent & gRPC over AF_VSOCK

No SSH daemon, no open TCP guest ports, no brittle expect scripts. Kagex embeds a tiny static Go agent as PID 1 inside every microVM over hardware-isolated AF_VSOCK.

Transport
gRPC over AF_VSOCK port 52
Proto contract
internal/proto/guest/v1/guest.proto
Components
initd, proc, execd, spool, files, server
Regenerate protobuf bindings & run guest tests
make proto         # buf generate in internal/proto
make test-linux    # runs internal/guest/proc tests in ubuntu:24.04 container

Key Engineering Points · MicroVM Kernel & Compute Isolation

All 10 key points →
  • 1Every Kagex sandbox boots a dedicated single-tenant Ubuntu 24.04 Linux kernel rather than sharing the host OS kernel.
  • 2macOS 14+ (Apple Silicon) runs natively via Apple Virtualization.framework (Code-Hex/vz/v3) with rootless ad-hoc entitlements in infra/vz.entitlements.
  • 3Linux amd64 and arm64 hosts run Firecracker v1.12.1 over /dev/kvm with per-VM Linux network namespaces and nftables packet filters.
  • 4Windows 10 (19041+) and Windows 11 (x64/arm64, Home/Pro/Enterprise) supervise Firecracker KVM inside WSL2 without requiring Hyper-V Pro or Admin privileges.
  • 5Guest base kernels are sha256-verified via infra/scripts/fetch-kernel.sh before registration into _out/images/vmlinux-<arch>.
  • 6Every microVM boots from an immutable Ubuntu 24.04 ext4 rootfs built reproducibly with Docker or native debootstrap.

Initramfs Boot & Zombie Process Reaping

guest/initd mounts virtual filesystems, configures netlink networking, performs switch_root into Ubuntu 24.04, and supervises a singleton SIGCHLD reaper (guest/proc) alongside a deadman timer.

OOM Detection & Frame Spooling

guest/execd isolates every invocation in its own process group, monitors /proc/vmstat OOM counters, and persists output frames in guest/spool so streaming reconnects never lose terminal logs.

Inspect this architecture live in 3D

Step through MCP ingress, Ghost Secrets, CoW blades, and run sandboxctl commands interactively in your browser.

Frequently Asked Questions

AF_VSOCK works independently of guest IP configuration or firewall rules, boots instantly in milliseconds, and needs zero SSH keys inside the VM.