Network Isolation

BuildWarden enforces strict network isolation on the build environment so that every byte entering or leaving passes through the relay and is recorded in the ledger. The mechanism differs per driver, but the guarantee is identical.

The Trust Boundary

All drivers enforce the same invariant: every byte entering or leaving the build environment passes through the relay and is recorded in the ledger.

The relay is the single point of network egress. It terminates TLS (via an injected CA), logs DNS queries, and writes network events to the signed ledger. Whether the build environment is a container or a virtual machine, isolation ensures no traffic can bypass this path.

Container Driver — iptables Isolation

The build's network namespace is isolated before the build container exists, in the Kubernetes pod pattern:

  1. A namespace holder (warden-holder, a single static binary that does nothing) starts on the per-build bridge network and owns the namespace. It runs with no capabilities, a read-only root and no shell.
  2. A privileged sidecar (warden-netns) joins the holder's namespace, applies the iptables rules below, and exits.
  3. The build container is created from your FROM image inside that namespace (--network container:<holder>), with warden-io initialize as its entrypoint, and only then started.

Nothing from your image runs before the rules are in place, including the image's own ENTRYPOINT, which is replaced. The build container has no CAP_NET_ADMIN and cannot modify the rules. Release builds run the holder and sidecar images by digest, so a different image carrying the same name is never run privileged.

The relay IP is on the same bridge network as the holder.

NAT rules (DNAT)

All outgoing HTTP, HTTPS, and DNS traffic is redirected to the relay:

iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination <relay>:53
iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination <relay>:53
iptables -t nat -A OUTPUT -p tcp --dport 80 -j DNAT --to-destination <relay>:80
iptables -t nat -A OUTPUT -p tcp --dport 443 -j DNAT --to-destination <relay>:443

Filter rules (DROP)

After DNAT, only relay and loopback traffic is permitted:

iptables -A OUTPUT -d <relay> -j ACCEPT
iptables -A OUTPUT -d 127.0.0.0/8 -j ACCEPT
iptables -A OUTPUT -j DROP

Why the build container cannot escape

  • Isolation precedes execution — no code from the image runs on an open network
  • No CAP_NET_ADMIN — cannot flush or modify iptables rules
  • No route to any host other than relay and loopback
  • The sidecar exits after applying rules — no persistent privileged process
  • The holder runs no code that could use the namespace before it is isolated

QEMU Driver — Topological Isolation

Two VMs are connected by a Unix domain socket pair (QEMU -netdev stream). There is physically no network path from the build VM to the internet that does not pass through the relay VM.

Network topology

  • Relay VM has two interfaces:
    • eth0: socket to the build VM
    • eth1: user-net (QEMU SLIRP) to the internet
  • Build VM has ONE interface: the socket to the relay VM

No iptables are needed on the build VM — there is no other path. The hypervisor enforces the topology; the build VM cannot create new interfaces.

Relay VM iptables

The relay VM uses iptables to ensure build traffic is processed by the relay process before reaching the internet:

  • PREROUTING: redirects inbound build traffic to the local relay process
  • FORWARD DROP: prevents any unproxied egress from the build VM
  • POSTROUTING MASQUERADE: NAT for the relay's own upstream connections
  • INPUT: the build VM may reach the relay control plane (:8300) but is dropped from the claim port (:8301), so it cannot claim or re-claim the relay

VZ Driver — Topological Isolation

The macOS build VM has a single VZFileHandleNetworkDeviceAttachment backed by a socketpair. There is no vmnet.framework, no bridging — the socketpair IS the entire network.

How it works

  • The relay runs on the host and reads raw Ethernet frames from its end of the socketpair via gvisor netstack
  • The VM sees one network interface connected to the relay — nothing else
  • SSRF filtering is active in host-mode relay (blocks connections to loopback/link-local/metadata IPs)
  • The VM cannot create additional network interfaces (Virtualization.framework constraint)

Why this is stronger than iptables

There is no software firewall to misconfigure or bypass. The isolation is structural: the only network device the VM possesses connects exclusively to the relay process. No amount of privilege inside the VM can change this.

Hyper-V Driver — Topological Isolation

Like QEMU, the Hyper-V driver uses two VMs and the hypervisor enforces the topology. The relay VM and build VM share a Private build switch (one per build: a slot switch warden setup --driver hyperv made for the durable strategy, or a per-build switch); the relay reaches upstream through an Internal NAT switch. Each relay takes its own address in the NAT prefix, read back from the host and allocated per build under a host lock, and gets it, with the gateway and a fresh claim token, from a per-build WARDENRELAY seed ISO. The build VM has one interface, on the relay's Private switch, so its only path is the relay; before it starts, the driver refuses a slot that holds any adapter but the relay's build NIC and its own.

The same relay-VM iptables rules apply (the init script is shared with QEMU): PREROUTING redirect, FORWARD DROP, POSTROUTING MASQUERADE, and an INPUT rule that lets the build VM reach the control plane but drops it from the claim port. The claim endpoint lives only on the host-only NAT switch, so the build VM cannot reach it even before iptables, and it accepts only the build's token.

Firecracker Driver — Topological Isolation

The Firecracker driver uses the same two VMs and the same relay init as QEMU, but the link between them is on the host: a network slot that sudo warden setup --driver firecracker makes once per boot, so builds need no privilege.

Network slots

InterfaceRoleAddress
wfc<i>bBridge joining the two TAPs below; IPv6 off, rp_filter=1, arp_ignore=8none
wfc<i>rRelay VM's build NIC (eth0, the build link's relay address inside)none
wfc<i>gBuild VM's only NIC (eth0, the build link's guest address inside)none
wfc<i>uRelay VM's upstream NIC (eth1); IPv6 off, rp_filter=1host 100.64.88.0 + 4i + 1/30, relay + 2

Every slot reuses the build link's two addresses (default 100.127.255.253 and 100.127.255.254): each bridge is its own segment with no host route. The TAPs belong to the user builds run as.

Bridge table and WARDEN-FC rules

  • nft bridge table warden_fc: its input hook drops every frame arriving on a wfc* port, so nothing from a build segment reaches the host stack; its forward hook passes frames only between a slot's own wfc<i>r and wfc<i>g.
  • WARDEN-FC-IN (first in INPUT): drop wfc<i>b; from wfc<i>u accept only ESTABLISHED from the slot's relay address; drop the rest of wfc+.
  • WARDEN-FC-FWD (first in FORWARD): from wfc<i>u with the relay's address to the uplink accept, and its replies (ESTABLISHED, RELATED for ICMP errors) back; TCP MSS clamped both ways to the uplink's MTU; anything else from wfc<i>u dropped (anti-spoof: un-NATed build traffic never leaves even if the relay's own rules are missing); within one bridge accept; every other wfc+ forward dropped.
  • WARDEN-FC-OUT (first in OUTPUT): to the relays accept ESTABLISHED and ICMP RELATED, NEW tcp/8301 only from the slot owner's uid, and drop the rest, so no other local user reaches a relay's :80, :443, :53 or :8300, and the owner reaches only the claim port.
  • WARDEN-FC6: ip6tables drops all INPUT, FORWARD and OUTPUT on wfc+.
  • WARDEN-FC-RAW (raw PREROUTING): conntrack zone i+1 per bridge, so identical flows in two slots never share conntrack entries when br_netfilter is loaded.
  • WARDEN-FC-NAT: MASQUERADE from 100.64.88.0/22 out of the uplink.

Inside the relay VM the same iptables rules as QEMU's apply. Setup refuses to run on a host whose filter FORWARD policy is ACCEPT, or whose firewalld or nftables ruleset would drop the relays' traffic, because a DROP in WARDEN-FC is final but an ACCEPT there cannot override another table's drop.

Every VM driver joins the build VM to the relay over one private /30, the build link: [vm] build_link, default 100.127.255.252/30 (relay .253, build VM .254; see Configuration). Each build segment is its own L2 network (a socket netdev, a per-slot bridge, a private switch, a socketpair), so the same two addresses repeat across builds without clashing, and no host interface holds one. The link reaches every component per build:

  • the relay, in its claim (build_link): in vm mode the relay addresses its build interface over netlink before it answers the claim, refusing a link another of its interfaces already uses; in host mode (vz) it builds its netstack from it;
  • the build VM, from its seed (cloud-init network-config), or by DHCP from the relay (Windows guests, whose warden-run.ps1 passes initialize no --ip; the direct-boot inits, with the kernel command line's warden.link_ip and warden.link_gw as the cross-check and fallback; vz's warden-boot).

The relay's DHCP responder. In vm and host modes the relay answers DHCP on the build link only: in vm mode on a UDP socket bound to the build interface (SO_BINDTODEVICE), so a request on the relay VM's upstream network never reaches it; in host mode inside its netstack. It makes one fixed offer per build, from the claim: the guest address, the link's mask, the relay as router, DNS server and server identifier, and an infinite lease. It keeps no per-client state, so a flood of requests exhausts nothing, and it never answers a BOOTREPLY, so a forged server message from the guest is ignored.

The link block. Inside the relay the link is a connected route, so an upstream address inside it would be sent to the build VM. In vm and host modes the relay's upstream dialer refuses every address inside the link (whether or not host mode's SSRF filter is on), it refuses a claim whose upstream_dns names a resolver there, and its resolv.conf default skips a nameserver there. warden refuses a link that holds a host interface address, every VM driver leaves out host resolvers inside it (and refuses a [vm] dns entry there), and Hyper-V refuses a NAT prefix that overlaps it, at setup and at every build.

Common DNS Behavior

All drivers configure the build environment to use the relay as its DNS server:

  • artifacts and cwd resolve to the relay itself (reserved hostnames for context transfer and artifact upload)
  • All other queries are forwarded to the relay's upstream resolvers, asked in order, and logged in the ledger. The list is fixed at the claim: its upstream_dns, which every VM driver sends ([vm] dns when set, used exclusively, else the host's resolvers the driver can reach), or, when the claim has none (the container driver), the usable nameservers of the relay's own resolv.conf. No public resolver stands in, and the relay's own upstream lookups use the same list.
  • IPv6 is disabled in VM drivers to prevent bypass via link-local addresses

What Isolation Prevents

ThreatHow it is blocked
Direct internet access bypassing the relayAll traffic forced through relay by topology or iptables
DNS tunneling to external serversAll DNS queries go through the relay
Metadata service access (169.254.169.254)Blocked by SSRF filter in host mode; unreachable in VM modes
Build environment modifying its own networkNo CAP_NET_ADMIN (container); no additional interfaces (VM)

What Isolation Does NOT Prevent

These are availability concerns, not integrity violations — the ledger still records everything:

  • Build environment sending excessive traffic through the relay
  • Build environment attempting to DoS the relay with many connections
  • Build environment consuming all available bandwidth

The relay applies fairness scheduling to mitigate resource exhaustion, but these are not considered security violations because the invariant (all traffic is recorded) is preserved.