
microVMs for agents, analyses and experiments powered by NixOS
- run multiple VMs on a single host
- fully filtered traffic egress using policies and profiles
- ssh access
- an inference gateway: LLM providers without API keys in the VM, with token quotas
- file transfer via rsync or git
- ephemeral, home-persisted or full-persisted VMs
- disk, memory and CPU cores are configurable
- user-space only, no need to change system configuration!
Requirements
- Linux only, WSL might work
- KVM enabled, available to your user (part of group
kvm) - Nix daemon installed
- User + Network Namespaces enabled
- for one running VM, 8GiB Disk and 2 GiB RAM
Why
Running agents directly on your host can be dangerous as they may have access to private data and can easily wreak havoc. Moreover through prompt injections attackers can target developer machines and exfiltrate secrets or install malware. That is why more and more people start sandboxing their agents.Threat model
sodabox is created for coding agents but can be used to execute arbitrary untrusted applications.
Its threat model assumes that the whole guest system is untrusted and thus all network access must be fully controlled by policies. A sodabox VM has its own data disks. Data is copied into these disks and from them intentionally as the VM itself is regarded untrusted. That way, a VM cannot, by accident, delete the content of a folder that has been mounted using e.g. virtiofs.
A guiding idea is that the guest application itself can be run as root without compromising the host.
Installation
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.sodabox.url = "github:mguentner/sodabox";
outputs =
{ nixpkgs, sodabox, ... }:
{
nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
modules = [
(
{ pkgs, ... }:
{
nixpkgs.overlays = [ sodabox.overlays.default ];
environment.systemPackages = [ pkgs.sodabox ];
}
)
];
};
};
}{ pkgs, ... }:
let
sodabox = fetchTarball "https://github.com/mguentner/sodabox/archive/main.tar.gz";
in
{
nixpkgs.overlays = [ (import "${sodabox}/nix/overlay.nix") ];
environment.systemPackages = [ pkgs.sodabox ];
}Architecture
The architecture of sodabox tries to keep the trusted computing base (TCB) as minimal as possible. Instead of trying to lock in applications using namespaces, seccomp, landlocks etc. it creates a dedicated virtual machine around the Kernel-based Virtual Machine (KVM) using Cloud Hypervisor. Cloud Hypervisor has been chosen as it is written in the Rust language. It only has a limited amount of device options, does not support emulation and in general does not have much legacy debt. For networking, each VM gets its own passt instance. The hypervisor together with the passt instance is executed in a dedicated user networking namespace from which traffic is routed out using TPROXY nftables commands to a final proxy (again, per VM) running in the host. This combination makes sodabox a 100% user-space solution without needing to modify the host (no tun/tap interfaces, CAP_NET_ADMIN, custom firewall chains)!

Influences
Transparency
Built mostly using agents. Human facing content (documentation, TUI) was edited by an human.
License
MIT