Files

369 KiB
Raw Permalink Blame History

Design notes

For contributors: why devvm is built the way it is, what was tried and dropped, and what's still open. How each part works is on its own page in How it works, and the rest of Contributing has the repo's layout and rules. Why devvm is written in Go is under Why Go, with the processes it runs.

Emulated features

When devvm builds a backend feature from other parts of the backend, the feature is emulated, and it gets a note here before its review. The note says what the feature is built from, the guarantee it keeps, what could break it, and which end-to-end checks prove it. The threat check comes next, and only then is the feature marked reviewed. Every feature Lima has is native except its ports, which devvm's forwarder emulates (below).

ssh into VMs

ssh for editors is native on Lima, so it isn't an emulation, but its sessions keep a guarantee of devvm's own: ssh and editors reach a VM by name through the entries devvm writes (security model), and a session gives the VM no way out it doesn't already have, on a confined tier nothing past its proxy, whatever the VM runs as sshd.

What keeps a session from carrying the VM out. An ssh session can carry the VM's traffic only through channels the host's ssh asks for: remote forwards (-R, RemoteForward, a remote SOCKS forward), X11, a tunnel and the agent; OpenSSH's client refuses a channel the server opens unasked. Root in the VM runs whatever sshd it likes, so the guarantee is the host's ssh's: devvm's entry (first in ~/.ssh/config, so its options win over a Host *) sets ForwardX11 no, ForwardX11Trusted no, Tunnel no, PermitRemoteOpen none (so devvm needs OpenSSH 8.7 or newer; no IgnoreUnknown for older ones, as its first value wins and would replace a user's Host * one, such as macOS's for UseKeychain), ForwardAgent as the agent choice the VM's current start was made with says, AddKeysToAgent no (no key of the host's lands in an agent the session forwards), ProxyJump none and ProxyCommand none (no hop through something else), UpdateHostKeys no (the VM can't add host keys; devvm reads them itself) and HashKnownHosts no. A RemoteForward can't be turned off without refusing ssh -R on the command line too, so it isn't (Not covered). VS Code's Remote-SSH uses local and dynamic forwards (-L, -D) and is unaffected. Then sshd's own settings, a defence for an honest VM (assets/layers/base.sh, /etc/ssh/sshd_config.d/00-devvm.conf, first so it wins; Lima's own forwards are local; it applies only where the image's sshd_config includes sshd_config.d, as Ubuntu's and Debian's do, so for some --from images not at all, which only an honest VM's defence loses):

  • Local forwarding (-L, -D, -W) is allowed: the VM itself connects, from its own network, which its tier confines like any other connection of the VM's (checked). VS Code's Remote-SSH reaches its server this way.
  • Remote forwards bind only 127.77.0.0/16, the range devvm keeps for links between VMs, and remote socket forwards are refused. A remote forward makes the host connect on the VM's behalf, so one the host's ssh asked for by mistake could reach anything the host reaches, its loopback services and sockets (docker.sock, agents) included, around the VM's confinement. GatewayPorts clientspecified binds the address a request names, and PermitListen 127.77.*:* matches that address as text, so a request for localhost (ssh's default), 127.0.0.1, 0.0.0.0 or ::1 is refused. Only devvm on the host asks for a forward in that range, always by number. X11 and tunnels are refused too.
  • Agent forwarding is allowed: the entry decides it from the SSH agent choice the VM's current start was made with (ForwardAgent and IdentityAgent naming the VM's proxy's relay of that agent, yours or devvm's own, which passes on only listing keys, signing and [email protected], so the VM can't remove, lock or add the agent's keys, as the SSH agents says). Refusing it would break devvm ssh-agent on in editors.

These settings guard against the host's ssh asking for a forward that devvm's entry doesn't pin (a RemoteForward under Host *, ssh -R), and only while root in the VM leaves sshd as it is. They're a safeguard for an honest VM, and the boundary is the host's ssh, which accepts a channel only for a forward it asked for.

What it relies on: OpenSSH's client refusing unrequested channels, and devvm's Include line first in ~/.ssh/config, so its entries' options win.

What could break it: host ssh settings that come before devvm's entries.

Not covered:

  • A remote forward you ask for (ssh -R, a RemoteForward of yours): remote forwards you add lists what it leaves open.
  • Sessions see the proxy's password, as devvm's own shells do, and VS Code and Cursor relay what VS Code and Cursor describes.

Ports on Lima

The guarantee: when a VM forwards every port, each TCP port from 1024 up that a server in it listens on, on its loopback or on all its addresses, is forwarded to the same port on the host's loopback, and only to its loopback. When a VM lists its ports, only those are forwarded, however many it lists, by the same rules. The forwarder never takes a port that a program on the host has on any address when the forward is made, or a port devvm records for another VM. Forwarding gives the VM no way out that it doesn't already have, because every connection starts on the host. Lima's own forwards listen with SO_REUSEADDR, so on macOS, whenever a server in the VM starts, Lima takes 127.0.0.1:PORT while a program on the host has *:PORT, and that program's loopback connections go with it. That's why Lima forwards nothing and devvm's forwarder forwards the VM's ports instead. On macOS, a confined VM doesn't depend on Lima for that, because its hostagent's sandbox refuses it every port but its ssh port, so Lima can't forward a port of the VM's even if it ignored its rules. The emulation is reviewed, with the threat check's findings fixed or listed below, which is why the host key read is capped, reports are paced and the log is limited, and the end-to-end checks prove the rest.

What it's built from:

  • Lima's forwards off. Each VM's portForwards holds three ignore rules, each for every guest port and protocol (any, which is TCP and UDP). They're on 127.0.0.1, which Lima also matches for ::1, on 0.0.0.0 and on ::, which together match servers on all addresses. They come ahead of Lima's own last rule, which forwards everything. CreateVM sets them with limactl clone --set. Start sets them only where limactl list shows other rules, because an edit gives the VM new host keys at its next boot. Lima's ssh is its VM driver's forward (ssh.localPort), not a rule, so the ignore rules leave it alone, and they cover the guest's own ssh port like any other.
  • The sandbox's binds (macOS, confined tiers). The hostagent of a confined VM runs under a Seatbelt profile (confinement) that denies every network bind but two kinds. It may bind the VM's ssh port over TCP, which devvm chooses and records in the VM's state (the ports section's host.ssh), and unix sockets in the VM's Lima folder, which hold the hostagent's own socket (ha.sock), the VM's network (default_ep.sock, default_fd.sock) and ssh's control socket. Seatbelt matches a bind by its port alone, on any address, even when the rule names localhost, and it can't allow an ephemeral bind (port 0) without allowing every port. It matches a unix socket by its path with links resolved, so a link in the Lima folder doesn't let the hostagent bind a socket elsewhere. Lima's host resolver binds two ephemeral ports for its DNS server, so a confined VM starts with the resolver off and 127.0.0.1 as its DNS server, as on Linux, where nothing listens and lookups fail at once. The hostagent reaches the guest agent over vsock, which needs no bind. This list comes from starting a VM under a profile that reported every bind, then under one that denied the rest: Lima logs a forward it's refused (failed to listen) and carries on, while a refused resolver ends the start.
  • Which ports. Which ports each VM forwards, all, none or a list, is in its state (ports.forward), and the backend never hears of them: neither Start's Want nor any other call of the backend's has them. vmssh.Forwards.Start, the one owner of the forwarder, reads them from the VM's state each time it starts one, after a start of the VM and when devvm ports changes a running VM's ports, without editing Lima's config. A stopped VM's change is its state's alone, because its next start reads it. When the VM lists ports, the forwarder forwards those less the ports a program on the host has, which the owner leaves out with a ports_taken warning. When none is left, no forwarder runs.
  • A forwarder per VM, on the host. The forwarder is vmssh.Forwarder, which isn't a backend's. Its owner, vmssh.Forwards, runs it detached as devvm _ports, one per VM, for project VMs alone, because only a project VM's start goes through it, and builds' starts don't. The owner starts it once the backend's Start returns, and again on a running VM when its ports change, each after stopping any forwarder the VM had, which ends the connections open through it. devvm finds that one by its pid file, which it checks against the process's arguments, as it does for the proxy. It sends that forwarder SIGTERM and kills it if it hasn't ended within 2 s, so its ports are free before devvm asks which listed ports a host program has. devvm holds a lock of the VM's own (ports.lock, beside its pid file ports.pid in the VM's run folder) from stopping the old forwarder until the new one has started, so two devvm runs at once, such as a start and devvm ports, leave one forwarder, the one its pid file names. The owner waits up to 10 s for the forwarder to say it forwards while it runs. The forwarder says so in a status file of its own beside its pid file (ports.status), which holds its pid and which devvm removes before each start. If it doesn't, devvm warns with ports_forward_failed, naming its log, and leaves it to keep trying while the VM runs on.
  • Reaching the VM. The forwarder makes one ssh connection, a master (ssh -F none -M -S <socket>), to the VM's sshd on Lima's ssh port on the host's loopback. Lima's SSH gives the port with the user and the key, the first IdentityFile of Lima's ssh config, and devvm refuses that target unless the config names 127.0.0.1 (vmssh.FromTarget, the check links and the ssh config use too). It logs in as Lima's user with Lima's key alone (IdentitiesOnly, IdentityAgent=none), _config/user in devvm's Lima home, which every VM there authorizes, and never with the user's agent. The master reads none of the user's configuration and forwards nothing either way, with ClearAllForwardings, PermitRemoteOpen none, ProxyCommand none, and no agent, X11 or tunnel. The VM's sshd allows local forwarding, and remote forwards only to 127.77.0.0/16 for links (base.sh), and -W is local forwarding. Its control socket is in ~/.local/share/devvm/run (mode 700) and is named by a hash of the VM's name, because a socket's path has fewer than 104 characters. When the connection is lost, the forwarder closes its forwards and makes the connection again every 2 s while the lifeline holds.
  • What listens. The master's session runs ports.sh (assets/guest/ports.sh) as the VM's user (sh -s). It prints the local addresses of the VM's listening TCP sockets, which are the state 0A lines of /proc/net/tcp and tcp6, whenever they change and every 10 s regardless, so it ends soon after the connection does. The forwarder treats the report as untrusted. A line over 128 bytes or a report over 4096 lines ends the connection, and anything that isn't a hex address and port is skipped. Reports are applied at least 500 ms apart, and one that comes sooner waits, holding up the VM's ssh channel with it, so the VM can't make the forwarder bind, dial and read devvm's state at its own pace. The VM can make the forwarder write to its log, with ports coming and going and with the session's stderr, so the log takes 200 writes at once and then one every 10 s. Each write is at most 512 bytes, without control characters other than newlines and tabs, C1 included, and the log is rotated before it passes 1 MiB, its end kept in ports.log.1. A forwarded port's connections go to 127.0.0.1 for a server on all IPv4 addresses or on that address, and to ::1 for a server on all IPv6 addresses or on that address. A server on another 127.x address alone gets its connections there. Servers on other addresses alone aren't forwarded.
  • How many. With every port, the forwarder takes ports from 1024 up, because the ports below are the host's system services. With listed ports, it takes those alone (-only), a listed port below 1024 included, because the user asked for it, and a bind the host refuses is logged. Either way the forwarder takes at most 256 ports at once (vmssh.MaxForwards). It records why it couldn't take each port in ports.forwarded, by the bind's error: in use (EADDRINUSE), past its limit, or refused (EACCES or EPERM, such as below 1024 on Linux), and devvm ports warns each with its own message (ports_taken, ports_limit, ports_refused). Any other error, such as EMFILE, ENOBUFS or EADDRNOTAVAIL, says nothing about the port, so it's logged, not recorded, and the port is tried again at the next report, the log's limit capping the repeats. A port past the limit is tried again at the next report once the forwarder forwards fewer. A record from before the reasons, whose third line holds every port it couldn't take, is read as giving no reason, so it warns of none rather than call a refused port in use. It reads the reserved ports (below) again with each report, and while it can't read them, it takes no new port and keeps those it has. A port it has that has since become reserved, such as one another VM's start has chosen, is given up at that report, though the VM still listens on it, and also within 10 s on the host's own clock (Forwarder.Recheck), whether or not the VM reports, so a VM that holds its session open and stays silent can't keep it. A reserved port the VM listens on waits and is tried again at each report until it's no longer reserved. A port that a host program has, or that the host refused, is tried again only once the VM's server on it goes and comes back.
  • Listening. The forwarder listens on 127.0.0.1 and ::1, or on IPv4 alone on a host without IPv6, which a bind on ::1 reports as EADDRNOTAVAIL, EAFNOSUPPORT or EPROTONOSUPPORT. EACCES or EPERM on ::1 alone, with 127.0.0.1 bound, also gives IPv4 alone, with a line in the log, because that's a host denying IPv6 rather than a port it refuses. Any other error on ::1 closes the port's 127.0.0.1 listener and counts as that bind's error would on 127.0.0.1, recorded or tried again at the next report as the bullet above says, so a passing error such as EMFILE never leaves a forward on IPv4 alone until its port is opened again. It binds without SO_REUSEADDR (platform.ListenExclusive). With that option, which Go and Lima set, macOS lets a socket take 127.0.0.1:PORT while a program has *:PORT, and that program's loopback connections go with it. Without the option, the bind is refused when another program has the port on any address. This was checked on macOS for a program on 0.0.0.0, on :: (IPv4 and IPv6 at once, as Node's and Go's servers listen), on IPv6 alone and on 127.0.0.1, each with and without SO_REUSEADDR of its own. A port held only by ended connections (TIME_WAIT, with nothing answering on it) is taken as usual, so a server that restarts gets its forward back. When a bind is refused, the forwarder dials the port and takes it only if the dial is refused. A full backlog times out, which counts as taken. A port the forwarder took on 127.0.0.1 but finds in use on ::1 is given up, so localhost never reaches two programs. On Linux, SO_REUSEADDR stays on. Linux refuses that bind with the option too while another socket listens on the port, and without it, the forwarder's own ended connections (TIME_WAIT) would keep anyone from listening on the port for a minute, its next forwarder included.
  • Each connection. Each forwarded connection is a channel of the master's (ssh -S <socket> -W HOST:PORT), with one process per connection and at most 256 at once. The VM's sshd opens it to the VM's own loopback from inside the VM. The channel's ssh has the master's options. If the master is gone, ssh connects on its own, and it then reaches the VM's sshd the same way, never the host's. Each relay's ssh runs with a context of its own, which closing its forward cancels, so the ssh is killed with the forward even when the VM never ends its channel. pipeSSH, which carries every relay of the forwarder's, the link sessions' and a login's callback, also cancels that context once the client on the host has closed its side and the VM has sent nothing for 30 seconds (relayGrace), and once the client can take nothing more and the ssh hasn't exited within 30 seconds. Each write of the VM's bytes to the client starts the grace again once it's done, and the grace doesn't run while that write waits for the client, so a client that closes for writing alone and waits still gets an answer the VM keeps sending, however slowly it reads. The VM must send something at least every 30 seconds, its first byte included, so a client that half-closes and waits longer than that for a first byte, such as nc -N in front of a slow query, is cut. The timer (graceTimer) runs only once the client's side has closed, or once the copy to the client has ended, with a write that failed or the VM's EOF, and a relay that ends stops it for good, so the client's goroutine, which can outlive the relay, never starts it again. The relay's own context, its owner's, also closes the client's connection when it ends, so a write that waits on a client that stopped reading ends with its forward, its link or LoopbackForward.Close.
  • Reserved ports. The forwarder never takes the VM's own Lima ssh port, which Lima's SSH names, or its proxy port, which its state records, and the owner passes both as -reserve. It also never takes the ssh, proxy and desktop ports devvm chooses and records in any VM's state, the ports another VM's running forwarder forwards now, as its ports.forwarded record says, or the ports another VM lists while it has a claim on them, which is while its forwarder runs or while devvm holds its ports.lock to start one again, unless this VM lists them too (ports.Reserved). A stopped VM's listed ports aren't reserved from other VMs' forwarders, but the ports devvm chooses still avoid them (ports.Used). Every Lima VM's ssh port is one of those, whatever its tier: devvm chooses it when it makes the VM, sets it with limactl clone --set .ssh.localPort, and records it in the VM's ports section before the clone (ports.Allocator.SSH). One allocator, ports.Allocator, chooses every host port devvm chooses, the ssh, proxy and desktop ports, and records it while it holds the VM's lock and then the claims lock (run/claims.lock, state.VM.Claim) until the VM's state is written, so two devvm commands making or starting VMs at once never choose the same one. A build VM has no state, so devvm chooses its ssh port too, on every host, through the same allocator (ports.Allocator.Build), under the claims lock alone (state.Claims), and on macOS the build's Seatbelt profile names that port. It records the port by the build VM's name (run/build-ports/<name>), where ports.Used reads it, until limactl start returns, and by then Lima has bound the port or the start has failed. The devvm that starts the build holds a file lock on that record until then, and the kernel lets go of the lock when that devvm ends, even when it's killed. Each time devvm chooses a port, under the claims lock, it first deletes the records whose lock no process holds and that are over 15 minutes old. The age matters because a killed devvm leaves its limactl start running, which may still bind the port for up to Lima's 10 minutes of waiting for the VM's ssh. So a devvm killed while its build VM starts reserves that port for 15 minutes, and then only until the next port is chosen. A stopped VM gets a new one only when a program on the host has its port on any address, even one that accepts no connections, or when the VM lists it to forward, and its start then sets it with an edit. Lima binds the port only once the VM boots, a few seconds after its start, so a port Lima picked itself would be free for another VM's forwarder in that window, and Lima's own ssh, which checks no host key, would then reach the other VM (the threat check below).
  • The host key. devvm keeps one record of a VM's host keys for each of its starts, vms/<hash>/run/known_hosts (vmssh.PinHostKeys). It removes the record before each start and reads the keys once the VM runs, whatever ports the VM forwards, and a command that finds the VM running without a record of its current start reads them too (starter.pinHostKeys). It reads them through limactl shell, at most 64 KiB for at most 30 s, keeping only lines whose key decodes and names its own type (vmssh.ParseHostKeys). The record's first line names the start it was read for (backend.Run.ID), so a record of another start, such as one before a limactl start outside devvm, is read again, and keys read while the VM started again aren't recorded. The forwarder checks the VM against that record, with HostKeyAlias and StrictHostKeyChecking yes, as the ssh config, links' sessions and a --clone VM's git do. All of them reach the VM through one function, vmssh.Checked, which checks the backend's ssh and adds the record: the forwarder and the ssh config pin the keys when the record is another start's, and links' sessions and git take only a record of the current start. The pin keeps the forwarder from talking to a program on the host that takes the ssh port. It doesn't guard against the VM itself, which is already the other end of the connection.
  • Its lifeline. The forwarder follows the hostagent's pid file (ha.pid, the lifeline Lima's Running gives), as the proxy does, and exits once the file is gone, holds anything else, or its process is gone. devvm stop stops it with the VM, and devvm rm and devvm gc --orphans stop it before they delete its files with the VM's folder. A VM that stops some other way, such as when its self-check fails or a restart stops it, ends its forwarder through the lifeline, and the next start stops any forwarder that's left before it starts its own.

What keeps a forward from carrying the VM out: every connection starts on the host. A program connects to the forwarder's port, and the forwarder asks the VM's sshd to connect to the VM's loopback. The VM opens nothing to the host through the forwarder, because the master asks for no remote forward, agent, X11 or tunnel, and OpenSSH's client refuses a channel that the server opens unasked, whatever sshd root in the VM runs. The only remote forwards devvm asks a VM for are a client's links, on a link session that is a connection of its own, never the forwarder's master (links). What the VM sends back goes to the program that connected, as with any forward. On a confined tier, the VM's own connections stay confined by Seatbelt or QEMU's restrict=on, while the forwarder runs on the host as devvm, outside the hostagent's sandbox.

What it relies on: OpenSSH's client refusing unrequested channels and honoring -F none, the kernel refusing a bind without SO_REUSEADDR where another socket has the port (checked on macOS), devvm's state listing every VM's ports, each running forwarder's record of the ports it forwards, and the forwarders' pid files and locks saying which VMs have a claim on their listed ports. It also relies on Lima binding its ssh forward on the host's loopback alone, on the host key that devvm pins at the start, and on Lima honoring the ignore rules ahead of its own rule. On macOS, a confined VM relies on Seatbelt refusing the hostagent's binds instead of on the rules, and on the Virtualization framework's own process, which runs outside the profile, binding nothing: the VM's network goes through the hostagent's unix sockets.

What could break it: a Lima release that forwards despite the ignore rules, or that forwards from somewhere other than portForwards. On macOS, a confined VM keeps the guarantee even then, because its sandbox refuses the binds. An open VM, and every VM on Linux, where QEMU's restrict=on doesn't cover the hostagent's own binds, still relies on Lima honoring the rules. A Lima release that needs a new bind for a confined VM, such as a resolver that can't be turned off, fails its start closed, and Lima's log names the refused bind. The end-to-end checks look at the rules, and use lsof or ss to check that the hostagent has no TCP or UDP port of the VM's and that a host program keeps its port. A program on the host could take Lima's ssh port while the VM is stopped, and the pinned host key refuses it. Lima's key logs in to every VM in devvm's Lima home, as it does for Lima's own ssh, but public key authentication never sends the key to the VM.

Threat check (the security-audit skill, guidance mode, its local IPC companion; the sandbox's binds and the ssh port). Leads, each confirmed and fixed, ruled out, or listed:

  • Another VM answering for this one's ssh: confirmed, fixed. An ssh port that Lima picks at a VM's start, and binds once the VM boots, is one devvm doesn't record, so no forwarder reserves it. Another VM forwarding every port, with a server on that port in the window, has its forward take it. Lima then carries on with its other ssh forward and waits on the port (seen with a host program holding it), and Lima's own ssh checks no host key (StrictHostKeyChecking no), so limactl shell, the host keys devvm reads and pins after the start, and devvm's setup and shell would reach the other VM. The fix: each VM's ssh port is devvm's, whatever its tier, recorded before the clone and reserved by every forwarder. It's unit-tested and checked by the CLI tests, and end to end, the port a VM's state records is the one Lima listens on.
  • A guest port bound around the rules: ruled out on macOS on a confined tier. Lima forwards a port only by binding it on the host, and the sandbox refuses every port but the ssh port. End to end, with Lima's own rule put back for one start inside the sandbox, Lima tries the guest's TCP and UDP ports, is refused (operation not permitted), and has no port but its ssh port, while devvm's forwarder forwards the TCP port.
  • The ssh port on every address: listed. Seatbelt allows the ssh port on any address, so a Lima that bound it on 0.0.0.0 would put the VM's sshd on the network, where it still takes only keys. Lima binds it on 127.0.0.1, and the end-to-end checks look at the hostagent's listeners. The rule allows the port over TCP alone, so the guest's UDP server on that port number can't get a forward from it; checked end to end.
  • A program holding a stopped VM's ssh port: ruled out, but for a race. A start looks for the recorded port with a bind on 127.0.0.1 and ::1 as well as a connection, so a program that has the port on any address, even one that accepts no connections, gives the VM a new port. Only a program that takes the port between that check and Lima's bind, a few seconds later, gets Lima's ssh, which is listed under not covered below. End to end, a VM whose port a host program holds starts on a new one, recorded, and the program keeps its own.
  • Two VMs choosing the same ssh port: confirmed, fixed. Without a lock, two devvm commands making VMs at once could each choose the same port from the ports other VMs record, and the second VM's Lima would wait on a port that the first one's has. devvm chooses and records a port while it holds the claims lock, run/claims.lock in its data folder, after the VM's own lock (locks).
  • A build VM's ssh port: confirmed, fixed. A port that Lima picked at a build's start would be one that no VM's state records, so another VM forwarding every port could take it in the window before Lima binds it, and Lima's ssh would then run the build's scripts in that VM. The fix: devvm chooses every build VM's ssh port, on macOS and Linux, under the claims lock, and records it in run/build-ports/<name>, which every forwarder reserves, until the build VM's start returns. A record that a killed devvm leaves is deleted the first time devvm chooses a port once the record is 15 minutes old, because no process holds its lock, and until then it keeps the port from any VM while the start that the killed devvm left may still bind it. Builds carry no credentials, an image is the build VM's own disk, and a tool build writes its images through a folder that only its own VM mounts, so even a VM that reached a build's ssh another way could break that build but couldn't learn a secret from it or choose what an image or a tool image holds. It's unit-tested on both systems, and the CLI tests check that a build's start sets the port.
  • A browser reaching a VM's ssh port: confirmed, fixed. Lima listens on the ssh port on this machine's loopback, and root in the VM can make what answers on port 22 speak HTTP, so a page opened as http://localhost:PORT, by a link or by a VM that opens URLs, would reach a server the VM controls with the cookies of the apps you use on localhost, even in a VM that forwards no ports. The fix is that every VM's ssh port, and every build VM's, is one of the Fetch standard's bad ports from 1024 up that Chromium's kRestrictedPorts also blocks (ports.SSHPorts, 17 of them, because Chromium lacks 4190 and 6679, which headless Chrome 157 loads). Every browser engine refuses every request to these ports, navigations and WebSockets included. The one allocator chooses them (ports.Allocator.SSH and Build, through freeSSH), its other ports never take one, and a proxy or desktop port that an older devvm chose there moves at the VM's next start. No forwarder takes one unless its VM lists it (ports.Reserved), so a guest forwarding every port can't fill them, and a stopped VM's listed ports don't keep them from a start. That allows at most 17 running VMs, and a start past that fails with ports_ssh_limit or ports_ssh_limit_all, naming the VMs whose ports are in use, or ports_ssh_limit_others. An older devvm's VM moves onto the list at its next start, in the start's one limactl edit, and each launch warns of a running VM still on an old port (ports_ssh_old). A start holds its port, kept or new, for a minute (run/ports.ssh-hold in the VM's folder), because a stopped VM's port that it keeps would otherwise look free to another start in the window before Lima binds it. The hold is time-limited, so a backend that takes over a minute to bind can lose the port to another start and fail, and its next start gets another. It's unit-tested (TestSSHPorts, TestSSH, TestSSHHolds, TestSSHListed, TestOffList, TestBuild, TestReserved, TestStartBuildSSHPort, TestPrepareRestartsTheProxy, TestDesktopListener), checked by the CLI tests (ssh_ports, the frozen 0.1.0 fixture's launches), and end to end each VM's ssh port is on the list.
  • What a failed start or create leaves: ruled out. A VM whose create fails, other than by an interrupt, keeps its state, and with it its recorded port, until devvm rm deletes it, so the port stays reserved and nothing else takes it. devvm rm deletes the state, which frees the port.
  • Unix sockets: ruled out as a way out. The hostagent binds them only in the VM's Lima folder, which only Lima's own commands and devvm use.
  • DNS around the proxy: ruled out. With Lima's resolver off, the guest's DNS server is 127.0.0.1, which transparent mode's dnsmasq answers inside the VM with one stand-in address and no upstream, or nothing answers when it's off, and Lima's network's DNS address and the host's address on it answer nothing even when root asks them directly with transparent mode stopped, because the sandbox denies the hostagent the host's DNS service and every connection but the proxy's; checked end to end, with transparent mode stopped and running.
  • A compromised hostagent: listed. The bind rules stop a Lima that misbehaves, not code an attacker runs in it, which the profile still lets read and write your files.
  • Starts without the sandbox: listed. Only confined starts on macOS run under it. A build keeps Lima's host resolver, so its binds aren't denied, and an open VM starts unconfined. Such a VM could run under a profile that denies binds alone, as its ssh port is fixed, but it would need Lima's resolver off too, which changes how it resolves names (the user-mode network's own DNS instead of the host's resolver), so that's proposed rather than done.

Threat check for listed ports (the security-audit skill, its local IPC companion). Listed ports use the same forwarder with -only, so these leads are what listed ports add, each confirmed or ruled out:

  • A port the VM chooses: ruled out. -only comes from the VM's state, less the ports a host program has, both read on the host by the forwarder's owner, and the VM's reports can't add to it. A listed port is forwarded only while a server in the VM listens on it, as with every port.
  • Port 22 listed: ruled out as a collision. Port 22 in the VM is its sshd, and Lima's ssh forward comes from another host port, so a listed 22 forwards the VM's sshd to the host's port 22 as it would forward any server. The VM's sshd still takes only keys. A host whose own sshd has port 22 keeps it, with a ports_taken warning.
  • A listed proxy port: ruled out. The forwarder reserves the VM's own proxy port whether or not it's listed, and every other VM's as well.
  • A listed port below 1024: taken because the user asked for it. A host service that has the port keeps it, and a bind the host refuses is logged and recorded as refused, never as in use, so devvm ports warns ports_refused rather than ports_taken. One that isn't running yet is under Not covered.
  • A forwarder left behind: ruled out. devvm stop stops it, devvm rm stops it and removes its files, any other stop ends it through its lifeline, and a start or change whose listed ports are all taken runs none. Two devvm runs that start a VM's forwarder at once take turns on the VM's lock, so the second stops the first one's forwarder, and neither leaves one that its pid file doesn't name, which nothing would stop.
  • A tier's confinement: ruled out. Listed ports take fewer ports than every port, never more, and every connection still starts on the host.
  • Another VM takes a stopped or restarting VM's listed port: mitigated. Only a running VM holds a port, so while VM V is stopped, another VM E may forward V's listed port, and a hostile E could then try to keep it, such as by forwarding every port and holding its ssh session open without reporting again. Three things stop that. First, the host decides when a port is given up: every forwarder closes each forward whose port is now reserved within 10 s on its own clock, whatever its VM reports, so E gives V's port up once V runs and lists it. Closing a forward also closes every connection it accepted that's still open, so a browser's keep-alive connection to localhost:5173, opened while E had the port, ends then too, and the browser's later requests, with V's cookies, never reach E over it. Second, V's start, a change of its ports and devvm ports warn with ports_held and name E in held_by, whether E lists the port or forwards every port, so V never waits silently. Third, V's listed ports stay reserved while devvm holds V's ports.lock, from stopping V's old forwarder until its new one runs, so no other VM takes them in that window. A stale ports.forwarded can't hold a port either: devvm removes it under that lock before each start, each forwarder writes an empty one when it starts, and a record counts only while its pid is the VM's running forwarder.
  • A relay the VM holds open: confirmed, fixed. Closing a forward closed the connections it had accepted, but each connection's ssh (-W) waits for the VM's sshd to end its channel, so a hostile VM that ignored the EOF kept that ssh process, and one of the forwarder's 256 relays, until the forwarder ended. Up to 256 such ssh processes could pile up on the host for each VM, and the VM's forwards would then refuse every new connection. Each relay now runs with a context of its own, which closing its forward cancels, under the forwarder's lock as the close already runs, so the ssh is killed (exec.CommandContext), and a relay that ends by itself releases its context. Unit-tested with an ssh stand-in that never exits on its own: the relay ends, its process is gone and its slot is free once the forward closes (TestForwarderEndsStuckRelay), with no goroutine or file descriptor left under -race.
  • A relay the VM holds open after its client has gone: mitigated. While a forward lasts, a VM that ignores EOF would keep each relay whose client on the host had closed, its ssh process and one of the 256, so a hostile VM could fill the forwarder's relays with connections a browser had already closed. Each relay's ssh is killed once its client has closed and the VM has sent nothing for 30 seconds, or 30 seconds after the client can take nothing more, so a VM keeps such a relay only by sending to it, and only for as long as the client keeps its side open for reading. The grace doesn't run while a write waits for a slow client, so a client that stops reading holds the relay and its ssh itself, as it could by staying open, until it reads again, closes, or the relay's forward or link goes. Unit-tested with an ssh stand-in that never exits: a closed client's relay and a half-closed one's both end after the grace when the stand-in is silent, and one the stand-in keeps talking to goes on past it, while a fully closed client's relay, and one whose writes to its client fail, end within the grace however much the stand-in sends. A half-closed client that doesn't read for many graces still gets all of the stand-in's answer afterwards, and a relay whose write waits on a client that stopped reading ends when its context does (TestPipeSSHGrace, TestPipeSSHGraceWriteError, TestPipeSSHGraceSlowClient, TestRelayGrace, TestRelayGraceWriteError, TestRelayGraceSlowClient, TestRelayCancelEndsBlockedWrite, TestGraceTimer). The price is a client that half-closes and waits more than 30 seconds for an answer's first byte, which is cut.
  • A forward on IPv4 alone: ruled out except on a host without IPv6 or one that denies it. A bind on ::1 that fails with an error that says nothing of the port, such as EMFILE or ENOBUFS, closes the port's 127.0.0.1 listener, is logged, and has the port tried again at the next report, so localhost never reaches the VM on one address and another program, or nothing, on the other. Only EADDRNOTAVAIL, EAFNOSUPPORT and EPROTONOSUPPORT, a host without IPv6, give IPv4 alone, and so do EACCES and EPERM on ::1 alone, logged, as a security module that denies IPv6 sockets would otherwise stop every forward. On such a host, a program that the module lets use IPv6 could still take ::1 on a forwarded port, and localhost would then reach it there, which is listed rather than refused because the alternative is no forwarding at all. Unit-tested with each error on ::1 (TestForwarderIPv6Failures).
  • A forward's listener out of files: confirmed, fixed. The loop that accepts a forward's connections ended at any error, EMFILE included, while its listener stayed open, so a burst that ran the forwarder out of open files left that port taking connections that nothing answered until the forward went. The fix is that it tries again after a wait that starts at 5 ms and doubles with each failure in a row, up to a second, and logs only the first failure of a run (daemon.AcceptRetry), as the link session, a login's forward and the proxy's SSH agent relay do. A login's forward also carries at most 16 connections at once, an ssh process each (TestAcceptRetry, TestForwarderAcceptRetries, TestLinksAcceptRetries, TestForwardLoopbackLimit).
  • Channels the VM never closes in the master: listed. A hostile VM that never sends CLOSE for a killed relay's channel can leave small channel entries, with no file descriptor, in the forwarder's ssh master. At most 256 relays run at once, which bounds them, and no code change is needed.

Not covered:

  • While a VM is stopped, another VM that serves on its listed port, such as localhost:5173, gets that port's browser origin, with the site data, storage and service workers your browser keeps for it, as two projects on one port would on any host. A service worker that the other VM's page registers there can still answer for that origin after the first VM takes the port back.

  • A VM can take a free port from 1024 up, or a listed one, on the host's loopback that a program there expects to be its own, such as one that isn't running yet or is restarting. What the VM serves there reaches whatever connects, so a page it serves to the user's browser can reach the internet from the host, past the VM's tier.

  • A host program that starts on a port while the VM has it forwarded still binds it when it listens on all addresses with SO_REUSEADDR, as most servers do (checked on macOS). Its loopback connections then reach the VM, because the forward's address is the narrower one. A program that binds without SO_REUSEADDR is refused.

  • The VM can make the forwarder dial a host loopback port that's in use and then close the connection at once without sending anything, because that's how the forwarder checks for a port held only by ended connections. This happens at most once per port every second, as the VM's listener on the port goes and comes back.

  • Servers only on the VM's other addresses, such as its network address or a container's, aren't forwarded.

  • Other users on the host reach the forwards, because they're on the host's loopback.

  • UDP isn't forwarded. Ports shows how to tunnel it over TCP.

  • A server that keeps a port while its forward couldn't be made, because the host had the port, isn't forwarded until it stops and starts again.

  • Another user on the host can take a VM's ssh port while the VM is stopped or booting. Lima's own ssh would then reach that user's program, as it checks no host key, while devvm's forwarder and ssh config pin the VM's.

  • A VM started outside devvm, such as with devvm limactl start, or one whose forwarder ended, runs without forwarded ports until its next start through devvm, or until devvm ports changes its ports, which starts a forwarder with the host key devvm pinned at its last start.

End-to-end checks (tests/e2e, project, and network for the sandbox's binds):

  • Lima's rules ignore everything, the forwarder runs with the host key devvm pinned for the VM, and Lima's ssh listens on the port the VM's state records.
  • A stopped VM whose ssh port a host program holds, on 127.0.0.1 alone and accepting no connections, starts on a new port that its state records, and the program keeps its own.
  • A VM server on a port answers at the host's 127.0.0.1 through the forwarder, while Lima's hostagent has neither that port nor a UDP server's port. The forward listens on the host's loopback alone. A port that a host program has on every address keeps that program's localhost connections while a server in the VM listens on it, and the forwarder logs that port as not forwarded.
  • With listed ports, only those reach the host, whatever address the VM's server is on. A listed port that a host program has is left out with a warning, and forwarded again once it's free.
  • On a running VM, devvm ports changes the forwarder's ports at once. A port that devvm ports add lists has its server reach the host at once, and once devvm ports rm takes it out, it doesn't. The VM's boot ID is the same throughout, so it never restarted.
  • devvm stop stops the forwarder, limactl stop outside devvm ends it (on macOS), and rm stops it and deletes its files.
  • On macOS, a confined VM has a profile that denies every bind but its ssh port's over TCP and unix sockets in its Lima folder, and the same binds that work outside the profile, a TCP port and a UDP socket on the ssh port, fail under it. Its hostagent listens on its ssh port alone, with Lima's resolver off. Started again with Lima's own forwarding rule put back inside the sandbox, the hostagent tries a VM server's TCP and UDP ports and is refused, and has neither. The VM still works: ssh by name, devvm's forwarder (on the host's loopback alone), the proxy and the self-check. Its next start puts the ignore rules back.
  • On a confined tier, with transparent mode stopped, DNS fails at once, because the guest's programs ask 127.0.0.1 alone, and Lima's network's DNS address and the host's address on it give no answer for a name, with transparent mode running too.

devcontainer.json

A new VM gets what the project's devcontainer.json says, as far as devvm does it (its page).

The guarantee: nothing from the file runs on or reaches this machine: it reads none of its environment, files, credentials, Docker images or registry logins, adds no mount, writes nothing to the project folder, and weakens no confinement (the network tier, .git protection). It shapes only what's in a new VM and what runs in it, as the VM's user. devvm's own handling of it (reading, parsing, state, the environment file, commands, ports, the image lookup) can't be turned against this machine or devvm. Reviewed: the threat check's leads are fixed, ruled out or listed below.

The problem: the file is the project's, so the VM's: the VM writes the folder, and a cloned repo's file is whoever wrote it. Dev Containers runs much of it on the host (initializeCommand, ${localEnv:…}, builds, mounts, runArgs, docker-outside-of-docker's socket), pulls images with the user's logins, and forwards ports at will.

How it's kept:

  • Reading: only in the folder, through os.Root (a link out of it isn't followed, .. included), opened without blocking (a FIFO the VM made in its place opens at once and is refused) and checked as a regular file on the open descriptor, at most 1 MiB. It's read once, at plan; what the VM is made from is the parsed plan, recorded in its state, never the file read again. Later launches only hash it and warn.
  • Parsing: comments and trailing commas are blanked at the same offsets, strings untouched, then encoding/json; values of the wrong kind, a NUL, an environment variable's name that isn't one, and every variable devvm doesn't fill in are refused before anything's made, ${localEnv:…}/${env:…} above all. Nothing is filled in from this machine: ${containerWorkspaceFolder} is the folder's path (the same in the VM), ${containerEnv:X} the VM's own X, left to its shell.
  • Mapped, or refused, or ignored: build/Dockerfiles/Compose are refused; initializeCommand never runs; mounts, runArgs, privileged, capAdd, securityOpt, workspaceMount and the rest are ignored, named. Features map only to devvm's own layers (docker-in-docker to the docker layer, a toolchain's name to that toolchain); no feature's script is fetched, docker-outside-of-docker is refused, everything else too.
  • The image: --from's path, but only an image its registry gives anyone: asked anonymously (from.Lookup.Public, never Docker's store), pinned to that digest, which the build pulls by. A registry named localhost or by an address that isn't the internet's is refused by name, and the lookup's client (from.NewPublicRegistry) connects only to the internet's addresses, whatever a name resolves to, its token service's included; offline, only a registry digest recorded for that reference stands in.
  • The docker layer: the backend's own rules for it, as when it's named; the file never changes the VM's tier.
  • The environment: each variable's value is built as a shell word (single-quoted text, "${X}" for the VM's own), stored as JSON in the VM's state, and written as export NAME=word into the VM's environment file before devvm's own (which win); a name is checked again when it's written.
  • Commands: stored as argv in the VM's state; run by the backend's Exec (on Lima, one sh -c string, each word in single quotes), as the VM's user, in the folder, after the self-check, .git's locks and a --clone VM's clone: confined like anything in the VM. Their output goes to the run log, shown only through printable.
  • Ports: only numbers and localhost:N/127.0.0.1:N, added to the user's ports as devvm ports add adds them (filePorts, through AddPorts and RemovePorts; --ports wins when the VM is made): with every port forwarded, the default, they're among them already. The ones the file added are recorded (devcontainer.ports_gave), so devvm update takes out only those the file no longer lists and never brings back one devvm ports rm took out. Forwarded on this machine's loopback alone, as any listed port, by the one forwarder, never a host port of another program's (ports_taken). A repo's file can so widen a list the user narrowed, to more of this machine's loopback, which is the user's decision to accept by opening the folder; --no-devcontainer skips it.

What it relies on: os.Root and O_NONBLOCK; encoding/json; Lima's Exec passing arguments unchanged; the registry's digest naming what's pulled (a pull checks it); the backend's own confinement of the VM and its builds.

What could break it: a backend whose Exec runs its arguments through a host shell; a new property mapped without the same review; a host proxy that reaches this machine or its network for a public-looking name (Not covered).

Not covered:

  • The project's own VM and the lookup through a host proxy (HTTPS_PROXY), where only names are checked, not what the proxy resolves them to: Attack vectors lists both, under its devcontainer.json entries. Its image is any public image, whose code runs as root in the build VM, as with --from.
  • A name that resolves to the internet for devvm and to this machine's network for the backend's pull (DNS rebinding) gets only content with the digest the public registry gave, which only someone who has that content can give.

Threat check (the security-audit skill; its local IPC, data isolation and supply chain companions). Leads, each confirmed and fixed, or ruled out:

  • An image only this machine or its network has (localhost:5000/…, a private address, a name that resolves to one, its token service on one): confirmed: a backend that pulls it from this machine reaches this machine's loopback, and the lookup was made on this machine; fixed: refused by name and by address (publicHost, NewPublicRegistry), a recorded digest included; unit-, CLI- and end-to-end-tested.
  • forwardPorts over a user's port list (added to devvm ports -g's list, or to none, a limit the user set): accepted: the file's ports are added to the user's list, on this machine's loopback alone, as the Ports entry above says, so opening the folder accepts them, and --no-devcontainer skips them; CLI- and end-to-end-tested.
  • The JSONC stripper and parser (comments in strings, an unterminated comment or string, a BOM, trailing commas): ruled out: blanking keeps offsets and leaves strings alone; anything else is invalid JSON; fuzzed (FuzzParse): no panic, every variable a shell word, nothing of this machine's environment kept.
  • Reading (a link out, .., a FIFO, a device, a huge file, a swap between the check and the read): ruled out: os.Root, a non-blocking open, the descriptor's own Stat, 1 MiB; one read per new VM; unit-tested (links, a FIFO).
  • Variables (${localEnv:…}, ${env:…}, nested or unterminated): ruled out: refused, or left as text for the VM's shell; nothing is read from this machine.
  • The environment file and state (newlines, quotes, $(), a name like A;rm): ruled out: values are shell words, JSON-escaped in state (one line), names checked twice; the file is the VM's own.
  • Command quoting (', newlines, an argument starting with -): ruled out: devvm runs bash -lc 'exec "$@"' with the argv after it, and Lima quotes each word.
  • Messages (the file's values in this machine's terminal): ruled out: every message value goes through msg.OneLine as it renders, the image through from.Valid, errors' causes aren't printed, the log tail goes through msg.Printable.
  • Commands before confinement: ruled out: they run after the self-check (which stops a VM whose policy fails), .git's locks, and a clone's seeding.
  • A digest the registry made up (Docker-Content-Digest): ruled out: sha256: and 64 hex digits, and every pull checks content against it.

End-to-end checks (tests/e2e, project): a VM made from a file: its variables in the shell, postCreateCommand once and postStartCommand at each start, in the VM and folder, its port forwarded and no other, nothing written to the folder, a changed file only warned about; a file whose image is on this machine's registry refused, nothing made.

Network tiers

A VM's network is one of four tiers, open, internet, allowlist and none, from the lowest to the highest (what each reaches). The design keeps two things: every VM's requests go through its own proxy, whatever its tier, and only the open tier ever runs a VM unconfined.

What it's built from: netpolicy.Tier, in the VM's net section as tier. An unknown tier fails to read (Tier.UnmarshalJSON), and TierOf reads a section it can't read as none, never as open; a section without a tier reads as allowlist. Tier.Net maps the tier to the backend's confinement: NetProxy for every tier but open, and NetDirect with the proxy's port and password for open (Confinement.GuestProxy). netpolicy.Policies gives each tier its policies (PolicySet), and Prepare writes them into the proxy's config: builtin_policies for the built-in policies and policies for your files on the allowlist tier, deny_policies for the user's files on internet and none, whose allows the proxy drops as it reads them, and open for the open tier, which allows every host and address with no floor and takes no policy at all (Config.check). Every tier's proxy has the VM's CAs and its bindings file, an open VM's included, and every VM's setup sends the same placeholders and redacted copies (stageSecrets), so no VM holds a real secret and the tier decides only the confinement and the rules. A running VM keeps the confinement it started with: one made open while it runs confined stays on NetProxy until its next start, with an open proxy. Every Prepare reads the tier from the VM's state as it is then, so a command that read the state before a tier change never starts the proxy with the tier before.

Rules: ** covers addresses as well as names, and :* any port 1 to 65535. Neither lifts the floor, because only an address rule can (policy.addrAllowed), so the internet tier's **:* reaches every public host and address and no internal one.

Lima: an open VM runs as a VM without a proxy would, with no Seatbelt profile and no restrict=on from the QEMU wrapper, and its guest reaches its proxy at 192.168.5.2, the host's loopback on Lima's user-mode network, on macOS and on Linux. propagateProxyEnv is off for it, so the host's proxy settings never reach the guest, and its NO_PROXY adds Lima's names for the host.

Links: a client links only to a target on its tier or a stricter one (policyRule), and a group's VMs are all on one tier. A tier change that would break either is refused (tierLinked, group_tier_fixed).

Threat check (the security-audit skill, guidance mode). Leads, each ruled out, fixed or listed:

  • The open flag reaching a confined VM's proxy: ruled out. Open is set only for the open tier, a config with open and any policy is refused, and an unknown or unreadable tier reads as none.
  • A confined VM reaching the host or the LAN: ruled out. The confinement is the tier's (Tier.Net), the floor still judges every address the proxy dials on a confined tier, and ** and :* lift no floor (TestAnyPort, TestFloor).
  • A tier change racing the proxy's config: fixed. Prepare read the tier from the state its caller had read, so a command started before devvm network changed the tier could start the proxy again with the looser one; it now reads the tier from the VM's state as it is then. Listed: two devvm commands at once can still interleave between that read and the proxy's start, and the next launch puts the right config back.
  • A running confined VM made open: listed, by design. Until its next start it stays confined, but its proxy is open's, so through the proxy it reaches this machine's loopback and the LAN, as the open tier you asked for does. devvm network open asks first in a parent folder (widen), and the VM keeps its CAs, which its open proxy goes on signing with.
  • Other programs or VMs using an open VM's proxy: ruled out. Every request needs the VM's own random password, which is in no process's arguments: the proxy's config is mode 600, and the open self-check names $HTTPS_PROXY, not its value (TestSelfCheckOpen).
  • The company proxy's password: improved. An open VM no longer gets the host's proxy settings, so neither the shell's password nor config.toml's reaches its guest.
  • An open VM spending a secret past its proxy: ruled out. Its environment, its git credential helper and its agents' copies hold only its placeholders, which end in its own salt, so a request it sends directly carries a placeholder that the secret's host refuses, and only a request through its proxy, with its password, gets the real value.
  • An open VM's proxy putting secrets into another host's requests: ruled out. The open flag lifts the rules and the floor, not the bindings: the proxy intercepts and puts a secret in only for the binding's own hosts on :443, and a request inside the tunnel that names another host gets 421, as on every tier (TestInterceptOpen; TestPrepareOpen and sync.txtar for the VM's CAs, salt, bindings and placeholders).
  • An open VM's CA: listed, as on every tier. The VM trusts its own CA, whose key stays on this machine, so its proxy can impersonate the secrets' hosts to that VM alone.
  • ** matching addresses on the allowlist tier: listed. A policy with ** now allows public address literals too, which it refused before.
  • Old VMs: listed. A VM made before tiers reads as allowlist, so one that was open starts confined, and a running one shows as unenforced until devvm restarts it.

End-to-end checks (tests/e2e): network: open from its next start, a direct connection works, its proxy is set, answers the self-check and carries the VM to this machine's loopback and its LAN address, while the allowlist tier refuses this machine's loopback; the open VM holds no real secret, its proxy puts the token in over TLS the VM verifies with its own CA, and a request around the proxy carries only the placeholder and gets a 401; open behind a company proxy, the guest gets its own proxy and never the shell's settings, which go through the VM's proxy alone; internet reaches a host off the allowlist and another port but not this machine's LAN address, and a direct connection still fails; none refuses github.com, lets Claude Code's API through, and keeps a deny. link: an allowlist client's link to a none target goes on, and to an internet one is refused and warned of.

Rules by method and path

A rule can narrow a host name to some of its requests, by method, by path or both (how to use them, how the proxy judges them), and a secret of yours can go in for some methods alone. The design keeps two things: a request that a deny names doesn't reach its host by any spelling of its method or its path that the threat check below covers, and an allow lets through only what it names, as every server would read it. What it leaves open, such as a form's _method field and methods outside the list, is listed there.

What it's built from: the policy files' one line per rule, with the methods and then the path after the host (proxy.parseRule), --method and --path on devvm network allow, deny and rm (netpolicy.Rule), the proxy's interception with the VM's CA, which the secrets already use, and one matcher, proxy.match in internal/proxy/request.go, for rules and for secrets' bindings, whose path check (plainPath) is the one that custom secrets' --path had.

Decisions:

  • One line per rule, in the files there are. A rule stays a line of a policy file, api.github.com GET,HEAD /repos/, which the one parser reads for the proxy, devvm network and devvm doctor (ParsePolicy), so layers' and your own policies, -g's and each VM's take it as they are. A TOML or table form would be a second grammar beside the line one, for the same files. Every line that was a rule before means what it did, any method and any path. A line with spaces in it wasn't a rule, so a hand-written one that has the new form gains a meaning: example.com GET, which the proxy skipped, now allows GET, and !example.com GET, a broken deny that denied everything, now denies GET alone. Both are what the line says, and devvm writes such lines only from --method and --path.
  • Flags, not a quoted rule. RULE stays one word, as the cli skill has an argument, and --method and --path say how the rule narrows, so devvm network allow takes api.github.com --method GET,HEAD. The same flags on devvm secret set narrow a secret of yours, with none for every method, as --path and --scheme have it, so a saved secret's methods can go without deleting it. A path is one value, as --path has one wherever it appears, so two paths are two rules.
  • Allows add up, and a deny beats any allow, as before. An allow that narrows allows its host for the connection and only its requests one by one, and a deny that narrows refuses only its requests. So narrowing a host that a rule allows whole, devvm's built-in GitHub among them, takes a deny, and devvm network allow warns when an allow by method and path would narrow nothing because the VM's allowlist, or every VM's with -g, allows its host whole (proxy.Allowlist.CoversWhole, rule_narrows_nothing). An allow that replaced the whole allows of earlier policies was ruled out: adding an allow would then take access away, and a user's file would silently override devvm's.
  • Methods from a closed list. proxy.Methods are RFC 9110's, PATCH and QUERY, without CONNECT. A method outside them isn't a rule, so a typo in a deny, such as PSOT, is a broken deny, which denies everything until it's fixed, rather than a deny of nothing.
  • Paths as patterns, judged only in a plain form. * within a segment, ** for one segment or more, and a last / for everything below, which is what a binding's path below which its value goes in already meant. Rather than decode and clean a path, which servers do differently, the matcher takes only a path that every server reads alike (plainPath), as custom secrets' --path did. An allow, and a binding, match exactly, in case too, and never a path in another form, while a deny matches broadly, so each fails closed in its own direction. A deny matches in any case, every path that isn't plain, the path above one that ends with /, as /gists is to /gists/ for most servers, and a last segment cut at its first ., as Rails and Spring route /admin.json to /admin and some servers drop a trailing dot. Cutting at the first dot rather than the last covers /admin.tar.gz too, and it refuses a few more requests than a deny names, which is the side a deny errs on. The cost is that a request to a host with path rules whose path has an encoded character, such as a file name with a space, is refused unless a rule without a path allows it.
  • Rules that need requests force interception, or a refusal. A host whose requests the rules judge (hostRules.byRequest) is decrypted on :443 with the VM's CA, and refused on any other port and without a CA, never tunneled unjudged. A host that a whole allow covers, with no deny that narrows, stays a tunnel, so the cost falls only where the rules need it. No host is spliced by name: devvm already decrypts GitHub, Anthropic's API and the agents' token endpoints for secrets, and git, the GitHub CLI and Claude Code work through it. A client that pins its certificates or ignores the VM's CA fails its handshake, which devvm network log shows as TLS with the VM failed, so devvm notes that a host is now decrypted when a rule narrows it (rule_narrows) rather than refusing the rule. Addresses, CIDRs and ** can't narrow, because an address has no name to make a certificate for and ** would decrypt every host.
  • Methods a request names besides its own. Some frameworks take the method from a header, X-HTTP-Method-Override and its kin, which Rack and CGI read with _ for -, or from a _method parameter. The proxy reads every override-like header (overrideLike) and the query's _method, and while a rule narrows a host by method, it refuses a request whose value isn't exactly one method, such as a list, which servers read apart, rather than guess. Judging a _method in the query, rather than refusing every request with one, keeps a GET that names GET working, and an allow still needs every method named to be its own. A form's _method in a POST's body isn't read: the proxy forwards bodies unread, so it's judged as the POST it is.
  • Every request is judged. The intercepted tunnel's own HTTP server calls the handler for each request, HTTP/1.1 kept alive or HTTP/2, and so does each absolute-form request, so the rules and the bindings are asked for each one, with the files as they are then. A connection's verdict and whether its requests are judged come from one read of the files (hostRules). A WebSocket is judged by its upgrade request, and an upgrade to anything else, such as h2c, and a CONNECT inside the tunnel are refused, as the bytes after them would pass unread. A tunnel opened before a rule narrowed its host stays a tunnel until it closes, as tunnels do for every new deny, and rule_narrows says so. The shared Nix cache's own fetch from cache.nixos.org is judged as a GET of the path the VM asked for, so its rules apply there too.
  • A proxy from another binary. A running proxy is the devvm binary that started it, and one from before this change reads a rule by method and path as a line that isn't a rule: an allow it skips and a deny that denies everything. So devvm network allow, deny and rm warn, naming the VM, when they change such a rule while the VM's proxy runs from another binary than their own (proxy_other_binary, by the devvm_sha256 of the config it started with, and when that config or this binary can't be read, as devvm can't tell), and the VM's next launch starts the proxy again. A change to a host's rule doesn't warn, as every binary reads it alike. The bindings file stays version 1 while every binding has no methods and no path but a prefix longer than / that ends with / and has no *, so devvm secret set and rm, which write every VM's file, don't take an older proxy's bindings away, logins included. Such a file reads alike to a proxy from after bindings gained paths; a 0.1.0 proxy ignores the path, which for the built-in bindings only widens OpenRouter's key to all of openrouter.ai, as 0.1.0 bound it, until the VM starts again. Writing version 2 instead would cut those proxies' logins. It's version 2 only for a binding with methods or a pattern, which such a proxy refuses, so it puts no value in rather than put one in for every method, and devvm warns about each such VM whenever it writes one, from devvm secret set, rm and use or devvm agent login --api-key (Proxy.SecretsWritten, secrets_other_binary). A path of /, which that proxy's prefix check refused with the whole file, is no path, as it's every path. A custom secret's path that devvm writes is marked a pattern (path_pattern), so a path saved as a prefix whose * was itself is refused rather than read as a wildcard.
  • A blocked request gets 403 and a blocked event with its method and path, which devvm network log, /blocked and devvm-why show. A deny's refusal is marked refused, so no allow is suggested, and a request that no allow covers suggests the allow of the whole host, never a path, which the VM chose. Learning stays by host: devvm network lock adds whole hosts, which you then narrow, because a log of methods and paths would turn every request a VM made while it learned into a rule to review.
  • The floor and secrets. A rule that narrows names a host, so it lifts no floor: an internal address still needs an address rule. A secret of yours narrowed by --method goes in by the same matcher as an allow. A built-in secret's or an agent's login's binding isn't narrowed per VM: a deny by method and path in the VM's own file already keeps the token from those requests, and refuses them outright rather than sending them with a placeholder, which is stricter, while narrowing the binding would need a per-VM record of known secrets and logins and a second way to the same end.

What could break it: a spelling of a method or a path that a server reads as one a deny names and the matcher doesn't; an allow letting through a request it doesn't name; a host whose requests the rules judge reaching the far end without being judged; a request after the first on a connection going unjudged; the matcher being made slow by a VM's path; and the bindings' methods widening a secret.

Threat check (the security-audit skill, guidance mode). Leads, each ruled out, fixed or listed:

  • A path's spelling past a deny (case, a trailing slash, the prefix itself, a format's suffix or a trailing dot, percent-encoding, .., //, \, ;): fixed. A deny of /gists/ let /gists through, and a deny of /admin let /admin.json and /admin. through, which it now refuses (TestDenyBypasses, TestMatchPath; FuzzDenyBypass checks, with a deny of /gists/ alone, that no path that a server could read as /gists or below, decoded once or twice, with \ as /, without ;'s parameters, cleaned and with its last segment's suffix dropped, gets through). A deny of /config.json let /config.json. through, and every segment now matches with its trailing dots dropped too. Listed: a server that routes /admin-x or /admin~ to /admin isn't covered.
  • A method's spelling past a deny: fixed. The deny compared each of three override headers' whole value, so X-HTTP-Method-Override: DELETE, GET, X_HTTP_METHOD_OVERRIDE: DELETE and ?_method=DELETE got past a deny of DELETE. Now every override-like header in any spelling and the query's _method are read, each word of a list is judged, and a value that isn't exactly one method is refused while a rule narrows the host by method. Go's url.ParseQuery skips a pair with a ; in it, so ?a=1;_method=DELETE hid its _method; a query with a ;, or one ParseQuery can't read whole, is refused there too (TestDenyBypasses, TestAllowNarrowed, TestForRequestMethods, and FuzzDenyBypass, with a header of its choosing and an oracle that splits the raw query at & and ; itself). Listed: a method outside proxy.Methods, such as WebDAV's, can't be named, so a deny of writes doesn't refuse PROPFIND, which a server that doesn't speak WebDAV refuses itself; a _method field in a POST's body, which the proxy doesn't read, is judged as the POST it is; a header of another name that a framework is set to read the method from isn't.
  • An allow letting through more than it names: ruled out. It matches the method as written, every method the request names besides, and only a plain path in its own case (TestAllowNarrowed, TestPathWithin, which the bindings share).
  • An allow that narrows nothing: fixed. An allow by method and path for a host that a whole allow covers, such as api.github.com, changed nothing, while devvm said the host was now decrypted; devvm network allow now warns that it narrows nothing, naming the VMs, with -g by each VM's own allowlist, its file, layers and shared tools included, and names the deny instead. Where the whole allow names port 443 alone, the warning says the rule narrows only port 80's plain HTTP (TestCoversWhole, network_narrow.txtar).
  • Two reads of the rules for one connection: fixed. The CONNECT's verdict and whether its requests are judged each read the files, so a change between them could tunnel a host whose new rules needed its requests; both now come from one read (hostRules).
  • The shared Nix cache past the rules: fixed. Its fetch from cache.nixos.org asked only whether the host was allowed, and now meets rules by method and path as a GET of its path (TestNixCacheRulesByPath).
  • A proxy or a saved secret from before this change: fixed. A proxy from another binary, or one devvm can't tell, gets a warning when a rule by method and path changes (TestOtherBinaries). devvm wrote every bindings file as version 2, so a devvm secret set or rm after an upgrade took every running older proxy's bindings away, its agents' logins included, without a word; the file is version 1 now unless a binding needs 2, which an older proxy refuses rather than put a value in for every method, and writing one for such a proxy warns, devvm agent login --api-key's write included (TestReadBindings, TestRefreshSecretsOtherBinary, TestDefine's path of /). Checking whether an allow narrows anything after it's written warns about a VM whose rules can't be read rather than fail the change (TestNarrowNotesUnreadable). devvm 0.1.0's own state, frozen in the repo, is the check that none of this moves what 0.1.0 wrote: its bindings files read as version 1 and are written again byte for byte, its proxies' configs read and name the binary that started them, its grammar's lines and verdicts are a table of their own (TestFixtureBindings, TestFixtureProxyConfig, TestV010Rules), and its app VM takes an allow that narrows nothing, a deny by method, a launch that leaves its bindings file as 0.1.0 wrote it, and a secret by method that makes it version 2 (fixture_v010_network.txtar). A custom secret's path with a * saved as a prefix is refused (TestCustomsUnreadable).
  • A host whose requests the rules judge, tunneled unjudged: ruled out. Its CONNECT is intercepted on :443 and refused anywhere else and without a CA, logged as a refused block (TestNarrowedNotDecrypted).
  • Requests after the first, or smuggled in one: ruled out. Go's HTTP server parses every request on the decrypted connection and calls the handler for each, HTTP/1.1 kept alive and HTTP/2 alike, and the proxy sends each to the host as a request of its own through its reverse proxy, so no bytes of the VM's pass unparsed (TestInterceptRules over both). An upgrade other than WebSocket and a CONNECT inside the tunnel are refused. Listed: what a WebSocket carries after its upgrade request passes unread.
  • Another host's requests in the tunnel: ruled out, as before: a request that names another host gets 421.
  • A VM's path making matching slow: ruled out. Matching is a table over the pattern's segments, at most 32, and the path's, so a path of 20,000 segments against several ** takes well under a second (TestMatchPath).
  • A rule a typo turned into nothing: ruled out for methods and paths, which a line that isn't a rule can't hold, so a deny with one is a broken deny that denies everything (network_narrow.txtar).
  • A binding's methods widening a secret: ruled out. A binding goes in only where its match allows, and the lookup checks a binding's methods against the secret's as it's saved (fits), so a bindings file edited to drop them gets nothing (TestForRequestMethods, TestInterceptSecretMethods).
  • Interception breaking a client: listed. A tool that doesn't trust the VM's CA fails at a host once a rule narrows it, which devvm says when the rule is added and devvm network log shows.
  • What an allowed request carries: listed. A rule judges a request's method, the methods it names and its path, not its body or its other headers, so a POST that an allow lets through, such as GitHub's GraphQL, carries whatever the VM sends there, and a deny of POST refuses GraphQL's reads too. A deny of git-receive-pack blocks pushes over HTTPS alone, not over ssh on github.com:22 or through GitHub's Git Data API.

End-to-end checks (tests/e2e, network): a host that only devvm network allow --method GET --path allows, faked by the run's company proxy, is decrypted with no secret bound to it. Two GETs below the path reach it, while a POST to the same path, a GET elsewhere, and a GET that names POST in X_HTTP_METHOD_OVERRIDE or in ?_method= get the proxy's 403, never reach it, and are logged as blocked with their method and path, which devvm network log shows. A secret of yours with --method GET,HEAD goes into a GET and leaves the placeholder in a POST to the same host and path.

Transparent mode

A confined VM's tools that ignore the proxy settings, such as workerd under wrangler dev, a static Go binary or a container made through Docker's API, reach the VM's proxy by the names they look up (how). The design keeps three things: no DNS query and no connection leaves the VM but through its proxy, the host the proxy judges is the host it dials, and nothing new listens on the host or takes part in the backends.

What it's built from: internal/proxy/transparent.go: the reserved target TransparentHost (transparent.devvm.proxy), the stand-in address SentinelAddr (198.18.0.1, in benchmarking's 198.18.0.0/15, which clients such as workerd's kj count as public and the floor counts as internal), transparent's serve, tls, handler and refusePage, sniHost, and policy.transparentPorts behind /transparent/ports. routeFor is the order every connection is judged in, CONNECT's and the transparent path's alike, and carry is the one tunnel, its SNI check included. Event.Via is dns for the path's events (withVia for its requests). In the guest, assets/guest/transparent.sh is devvm-transparent, its ruleset (render), its slots and its service, set up by sync.sh when netpolicy.TransparentAddr gives the setup the stand-in address: the VM runs confined (backend.NetProxy) and its mode is on (netpolicy.TransparentOf: the VM's net.transparent, else config.toml's transparent-proxy, else on). layers/base.sh installs dnsmasq, socat and nftables, which changes base's key.

Choices against the first design:

  • Listeners on the stand-in address, not on 127.0.77.1: Docker's containers reach a local address on the VM over its bridges, but a loopback one only with route_localnet=1, the hole of CVE-2020-8558, which would open every loopback service of the VM to them. The port forwarder forwards only loopback and wildcard listeners, and vmssh.dialAddr refuses the stand-in address by name too.
  • dnsmasq on the stand-in address alone: a listener on 127.0.0.1:53 could be forwarded to this machine's loopback when you list port 53, giving the host's programs the stand-in address for every name and putting their names in the VM's log. A rule sends the VM's own 127.0.0.1:53 to dnsmasq instead, so nothing of transparent mode listens on loopback, and the forwarder never sees it.
  • DNS to public servers, not daemon.json: Docker gives containers 8.8.8.8 and 8.8.4.4 when the host's only name servers are on loopback, and an edit of daemon.json would restart Docker and need undoing on the open tier. A rule sends DNS to any public address to dnsmasq, from the VM and the bridges, which also catches resolvers that tools hard-code, and so does DNS to the VM's own name servers but loopback's: Lima's DHCP adds one beside 127.0.0.1, which systemd-resolved falls back on and Docker gives containers once it drops the loopback one, and the e2e run showed both failing without it. Other private, link-local, CGNAT and loopback addresses are left alone, so a DNS server on a container's or the LAN's address still answers.
  • Every other port refused, Docker's published ports included: the NAT chains run at -110, before Docker's at -100, and give every TCP and UDP port of the stand-in address a mapping, to its listener, to dnsmasq, or to a port where nothing listens. Without that, Docker's DOCKER chain, which takes every local address but loopback, would send db.example.com:5432 to a container that publishes 5432, and a test suite would write into a local database.
  • The ports from the proxy: the proxy owns the policy and reads its files again when they change, so devvm-transparent fetches /transparent/ports every 10 seconds rather than devvm finding every command and hand edit that changes a rule.
  • The first bytes decide on every port: HTTP and TLS each work on every redirected port, so a rule such as api.internal.example:8080 works for plain HTTP too.
  • devvm.proxy reserved whole: a name under it never reaches a link, a rule, a resolver or a company proxy, and neither does CONNECT devvm.proxy:P, which has no endpoint; only absolute-form requests for http://devvm.proxy/ reach the endpoints.
  • Never 22 or 53: SSH names no host in its first bytes, and the VM's ssh goes through ProxyCommand already. 53 is the VM's own names'.
  • A link's name refused on both ways: dnsmasq gives a link's name its /etc/hosts address, never the stand-in address, so only a crafted client reaches a link through the reserved target, and both the TLS and the HTTP way refuse it, so the two agree.

Threat check (the security-audit skill, guidance mode, on the reserved target, the guest's rules and the setup). Leads, each ruled out, fixed or listed:

  • Naming one host and reaching another: ruled out. The host is the SNI's, or each request's Host, and the proxy dials that host by name after routeFor judged it, then checks the replayed ClientHello's SNI again (carry). An interception's leaf names the SNI host alone, and every request whose Host or :authority differs gets 421 (TestTransparentIntercept). Domain fronting and ECH's outer name are what CONNECT with the password reaches already.
  • Secrets on the wrong host, or in plain HTTP: ruled out. Interception is chosen from the SNI host alone, on 443, and a plain request is always forwarded as http://, which never gets a secret (TestTransparentHTTP).
  • SNI and Host shapes: ruled out. No SNI, an address, a trailing dot, two names, a ClientHello split across records or cut short, a name HostOK refuses and a name under devvm.proxy are refused before the policy (TestTransparentSNI, FuzzTransparent). A name with anything but printable ASCII is refused before its case is folded, so the Kelvin sign never becomes k, and the same holds for CONNECT's target and its SNI check (TestHostsNotASCII).
  • Holding the proxy's memory or slots: fixed. A transparent connection counts toward the 1024 tunnels and gets 10 seconds for its first bytes. A ClientHello record longer than 16 KiB and 256 bytes is never read, and on every tunnel a ClientHello that has started must arrive whole within 10 seconds (TestTunnelHelloDeadline, TestPeekClientHelloCap). The 403 page's TLS connection and an intercepted tunnel took 1 MiB of a request's headers, where the proxy's own listener takes 64 KiB. With the fix, every connection that the proxy serves HTTP on takes 64 KiB, and HTTP/2 inside one asks for at most 100 requests at once, where Go's default is 250, each a request upstream (serveOne, TestServeOneHeaderLimit, TestServeOneStreamsLimit).
  • Requests left running, and idle connections: fixed. A plain HTTP request, the transparent path's included, went on after its client had gone, because the proxy can't tell that from a half-close, so a VM could leave requests waiting on a host that never answers, past the connections it holds. Once its client stops sending, a request ends after a minute with nothing to pass on, while an answer that keeps coming still reaches a client that half-closed. A connection to the proxy waits at most 10 minutes between requests, and one without the password is closed after its 407. Only tunnels counted toward a limit, so the fix holds the proxy to at most 2048 connections of every kind at once, a request that outlives its client included, as net/http closes its connection only once the handler returns (maxConns). A connection counts from its first request with the password, and the ones that haven't sent it wait in a pool of 128 where a new one closes the oldest (maxWaiting), so an open VM that reaches another VM's proxy port can't take that VM's room by holding connections through their 30 seconds for headers. Tunnels' HTTP/2 streams were bounded only for each tunnel, and every request upstream is a connection of its own, so 1024 tunnels could open about 100,000 connections to hosts. The proxy has at most 2048 requests upstream at once (maxRequests). Each limit's line in proxy.log comes once a minute at most (everyMinute). A plain ws:// upgrade got 502, because the request's writer hid the hijack it needs, and with the fix it gets its 101 (TestPlainHTTPEndsWithClient, TestProxyConnectionBounds, TestProxyConnectionLimit, TestProxyWaitingConnections, TestUpstreamRequestLimit, TestPlainWebSocket).
  • A flood of connections to another VM's proxy: listed. Connections without the password wait in their own pool, so holding them can't take a VM's room, but an open VM or a program on this machine that opens connections as fast as the host accepts them fills the kernel's accept queue, and the VM's own connections wait in it with them, or are evicted from the pool before their first request arrives. That slows the VM's proxy for as long as the flood lasts, and ends with it.
  • A ClientHello sent a byte, then late: fixed, found in review. The deadline first made a record header that didn't come whole read as "not TLS", so a tunnel that sent 0x16, waited past it, then sent a ClientHello naming another host was carried unchecked, which the SNI check had refused before. A stream whose first byte is 0x16 is TLS from then on: a header that doesn't come whole, or whose version byte isn't 3, is refused, and the far end gets nothing (TestTunnelHelloStall, FuzzClientHello).
  • A split ClientHello on an address's tunnel: fixed, found in review, older than transparent mode. A tunnel to an address may carry no server name, and a ClientHello that didn't parse read as one without a name, so one split across two records, naming another host in the second, went on unchecked. Only a ClientHello that parsed whole counts now: one that doesn't is refused, on every tunnel (TestTunnelAddressSplitHello).
  • Other bridges and protocols reaching Docker's DNAT through the stand-in address: fixed, found in review. The NAT chains map TCP and UDP alone, and only for lo, docker0 and br-*, so a published SCTP port, or a connection from Podman's or LXD's bridges, could reach a container through the stand-in address. Two filter chains at -150 drop both before any NAT chain (TestTransparentRuleset).
  • The proxy's endpoints without the password: fixed, found in review. socat adds the VM's password for any client, so a container without the proxy settings reached devvm.proxy's CA, ports and Nix cache through Host: devvm.proxy. On the transparent path that host reaches /blocked alone (TestTransparentHTTP).
  • Names under the search domain: listed. dnsmasq can't tell a single-label name the resolver extended from a name a tool names whole, so every name under this machine's network's search domain gets no answer through transparent mode, git.corp.example.com under corp.example.com included. Such a host needs the tool's proxy settings, as its address on the LAN or a company network would anyway.
  • A DNS server on the VM's 127.0.0.1:53: listed. The rule that sends the VM's resolver to dnsmasq takes every connection to that address and port, a forward of port 53 that the user listed included.
  • The via label: listed. Whether a connection came through transparent mode is the VM's own doing, as its User-Agent is, so devvm network lock's heading for such hosts is a hint, not proof.
  • DNS out of the VM: ruled out. dnsmasq has no upstream, the proxy asks the policy before it resolves a name, and the 403 page resolves nothing, so a blocked name never reaches the host's resolver. Root that gives dnsmasq an upstream, or stops the service, meets the host's confinement, which the e2e checks prove with the service stopped.
  • New exposure on the host: ruled out. No listener, socket or sandbox rule is added on the host. socat's connections are the VM's own, to its own proxy, with its own password, which /etc/environment gives every VM process already.
  • The listeners reached from the host or another network: ruled out. Nothing listens on loopback, the forwarder refuses the stand-in address, and an input rule keeps every interface but lo and Docker's bridges off it.
  • The VM's password in arguments: ruled out. The setup reads the proxy's URL on stdin, and socat and curl read the password from root's files, so ps and the journal never show it.
  • Containers without the proxy settings: listed, within the threat model. A container made through Docker's API, or with its proxy variables emptied, had no way out before, and now reaches what the VM's policy allows, as every program in the VM does. --network none gives a container no network, and an --internal network's containers reach nothing.
  • What /transparent/ports tells the VM: listed. It's the ports the VM's rules name, the shared ~/.config/devvm/policy's included, never their hosts. The VM can't read its policy otherwise, and it can't learn a rule's port by trying without a host that matches it, so the list is a small disclosure that reaches nothing.
  • Learning: listed. Tools that failed silently before, such as telemetry, now succeed on the learn tier and would be learned, so devvm network lock lists the hosts that only they reached apart, under a heading of their own. A tunnel event needs a dial that succeeded, so a VM can't make learn list a host it never reached.
  • An open start after a confined one: listed. The service is enabled at boot until that launch's setup takes it out, a few seconds later. In that window its connections reach the VM's proxy, which is open by then, so they reach what the open tier allows anyway, and its answers have a time to live of 0, so nothing keeps them after.
  • A running VM's tier changed: listed, by design. The setup decides by the confinement the VM runs with, so a confined VM made open keeps transparent mode on an open proxy until its next start, which reaches what the open tier allows.
  • Unprivileged in the VM: listed. dnsmasq and each socat connection's process run as devvm-transparent, while socat's listeners stay root's, because socat drops its user only in each connection's process. That's hardening inside the VM, which the threat model doesn't rely on.

End-to-end checks (tests/e2e): network, on macOS and on a Linux host: the service runs, the stand-in address is on lo, and dnsmasq and socat listen on that address alone; every name with a dot resolves to it, IPv6 has none at once, /etc/hosts' names keep theirs, and a name without a dot that isn't there resolves to nothing, though the VM's resolver appends this machine's network's search domain to it; curl without proxy settings and a static Go client with its own resolver reach github.com with its own certificate, logged without proxy settings; a blocked host gets the 403 over the VM's CA; port 5432 of a name is refused at once and devvm-why names it; a port a rule names is redirected while the rule is there and refused at once after; your own servers bind 0.0.0.0:443 and :80; the service comes back when it's killed or its table flushed; devvm network transparent off takes it out at the next launch and on puts it back; open, there's none and names resolve with Lima's DNS; with the service stopped, direct connections, DNS to Lima's addresses and TCP to a public server's port 53 still fail, and with it running a public DNS server and Lima's DNS addresses answer only with the stand-in address, TTL 0, or nothing. In a VM of the docker layer, containers without proxy settings reach github.com on the default bridge and on a network of their own, a blocked host is logged, a container reaches no other port of the stand-in address and none of its listeners directly, a container's published 5432 isn't reached through the stand-in address from the VM or from another container, its published 443 doesn't take the VM's connections, and an --internal network reaches nothing. from: a Debian 12 VM and an Alpine one each pass the same checks on the allowlist tier, and with the service stopped, Lima's DNS and a public server answer nothing.

A company proxy

Behind a company proxy, nothing reaches the internet without going through it, so each VM's proxy goes through it too (how), and each build goes through a proxy of devvm's for the build alone, which goes through it. The design keeps two things: the proxy still decides every request by the name the VM asked for, and the company proxy's password reaches nothing of a VM's or a build's.

What it's built from: the host's HTTPS_PROXY, HTTP_PROXY and NO_PROXY, read from devvm's environment (backend.ReadHostProxy) when a VM's proxy starts, or config.toml's [proxy] when the environment sets neither proxy (settings.HostProxy), checked (HostProxy.Upstream: only http:// proxies), and written into the proxy's config, proxy.json in the VM's run folder, vms/<hash>/run/ (mode 600), as upstream (internal/proxy/upstream.go). config.toml is a file people copy and keep with their dotfiles, so it never holds the password: its URL names the user, and the password is the proxy secret (proxy.UpstreamSecret), in the Keychain or devvm's secrets folder, which the proxy looks up through IO.Secret as it starts (upstreamPassword), so no file of devvm's holds it either. It's a host-only secret (secrets.Secret.HostOnly): no VM is ever bound to it. The proxy opens its own CONNECT through the company proxy, by name, with Proxy-Authorization: Basic from the URL, for tunnels and for the TLS connections it makes to put secrets in, which check the server against the system's roots and the user's CAs. Plain HTTP goes to the company proxy in absolute form. A change to the settings starts the VM's proxy again at devvm's next run, and an old proxy that won't stop fails the start (proxy_stop_failed) rather than run on with its old settings.

What an upstream changes: the proxy resolves a name and dials the addresses it checked only when it connects directly. Through a company proxy, the company proxy resolves the name, so the floor can't hold it to checked addresses:

  • An address the VM asks for is judged as before, and localhost, *.localhost and loopback and unspecified addresses never go upstream, so the floor refuses them as before unless a rule names them. A host whose last label is all digits or starts with 0x (127.1, 2130706433, 0x7f000001) is refused as no host name (hostOK), because a company proxy that reads it as inet_aton does would reach an address the floor never judged.
  • A name is refused when this machine's resolver answers with any internal or denied address (floorUpstream). The proxy looks it up absolute, as it does for a direct connection (egress.lookupName), so this machine's DNS search domain never turns api into api.corp.example.com, a name that no rule judged. A name this machine can't resolve within three seconds goes upstream unjudged only when the policy names it, as itself or under *.domain (policy.byName). When only ** allows it, the proxy refuses it (errUnresolved), because ** would otherwise send the company proxy any name the VM makes up, and the company proxy may resolve such a name to its own network's hosts.
  • The company proxy may still resolve a name differently, or later, than this machine did (DNS rebinding between the two lookups). It may also add its own search domain to any name it's sent, before or after it tries the name as written, depending on its resolver. A Kubernetes pod's resolver, for example, uses ndots:5, so it tries the search domain first for any name with fewer than five dots. So a name that a rule names, such as jenkins, may reach jenkins.corp.example.com through it, and a name that resolves here may reach another under the company's search domain there. A VM that controls a name under an allowed domain can choose the unjudged path: its name server can fail, or answer after the proxy's three seconds, and then answer the company proxy with an internal address.
  • So under a name the policy lists, a VM reaches whatever the company proxy reaches: its company's internal hosts, and the company proxy's own host, including this machine's loopback when the company proxy runs on this machine (a local proxy that a VPN client runs, for example). Address denies apply only to the addresses this machine resolves. The allowlist stays the limit: a name the VM's policy doesn't allow never reaches the company proxy.
  • The proxy reads at most 64 KiB of the company proxy's answer to CONNECT (maxConnectReply), so an answer whose headers never end fails the request instead of filling memory.
  • The company proxy sees every allowed host name and port, and with a CA in the user's CA folder, it reads TLS too, as it does for this machine.

Credentials: the company proxy's user and password are in no process's arguments (only the file's path is), in no log (the event log's upstream field and the proxy's own log name the company proxy as host:port, and the URL the proxy's HTTP transport uses has no user), and in no request but the company proxy's own: the proxy drops the VM's Proxy-Authorization and sets the company proxy's only for a request it sends there. The VM never sees them, not even in a refusal, which names the company proxy by host:port and its status code.

Builds: a build runs code that isn't devvm's: layer scripts run third-party installers, and with --from, the container image's own shell and package manager run as root in the build VM. So a build never gets the company proxy's settings. Behind a company proxy, each build goes through a proxy of devvm's on the host for that build alone (backend.ProxyStarter). It's devvm _proxy -config with the same config as a VM's proxy (proxy.Config): a policy file of **, which allows any host on ports 80 and 443 but the host's own and internal addresses, a new random password, the company proxy's settings as its upstream, and its lifeline on the build VM's hostagent, all in one file of mode 600. The build gets only http://devvm:<password>@<host>:<port>, in each proxy variable the host sets, and the host's NO_PROXY. When the build ends, devvm stops that proxy and deletes its config, which holds the password and the company proxy's, and a successful build's folder goes too. The password is worthless once the proxy has stopped, and the build never sees the company proxy's address, user or password. Without a company proxy, builds start no proxy and get no proxy settings.

  • Lima: the build VM (an image's, the tools build's or --from's conversion VM) reaches the proxy at 192.168.5.2, the host's address on Lima's user-mode network, with vz and with QEMU, and on macOS its Seatbelt profile allows that one port of the host's loopback alongside its ssh port. The proxy runs on the host, so a company proxy on this machine's loopback, such as one a VPN client runs, works for builds on macOS too. Lima's propagateProxyEnv would write the host's proxy settings into the guest's /etc/environment between #LIMA-START and #LIMA-END at each boot (Lima's 07-etc-environment.sh), and a stopped build VM's disk would keep that block, so build VMs start with propagateProxyEnv: false, and only a VM on Lima's own network whose guest doesn't name devvm's proxy (NetDirect without Confinement.GuestProxy) starts with it on. Every project VM names its proxy, an open one's included, so every project VM starts with it off, and its first start makes that change in the edit that adds its proxy to its environment. Lima also logs the proxy settings it reads, password and all, into devvm's run log, so devvm runs limactl without them, and only a start with propagateProxyEnv on gets them back. Each build script gets the build proxy's variables exported at its start, on its input with the script (internal/backend/lima/buildproxy.go), and /etc/sudoers.d/devvm-build-proxy keeps them for sudo until the scripts end. The build proxy's files and logs are in the build VM's folder, in run/builds/<name>/run/build-proxy/ in devvm's data folder.
  • --from's conversion: oci/build.sh runs as root with the build proxy's variables for crane. The container image's own code runs only in a chroot under env -i: the /etc/os-release check gets PATH alone, and chroot_run (bootify.sh, the CAs' ca.sh) gets PATH, HOME, LC_ALL and the build proxy's variables, for bootify.sh's package downloads.

The build's policy is ** alone, so on its own the build's proxy would refuse every name this machine can't resolve, and where only the company proxy resolves outside names, a build would reach nothing by name. Lima's build proxies start with upstream_unresolved in their config, which sends such names on to the company proxy unjudged. The refusal would protect little there, because without a company proxy those builds are on Lima's user-mode network and reach internal addresses directly.

End-to-end checks (Lima):

  • images: a layer built with a fake company proxy's password in HTTPS_PROXY and HTTP_PROXY (a closed port, NO_PROXY=*): its script and sudo see the build's proxy at 192.168.5.2 with user devvm, never the password, the build's proxy is gone afterwards, and neither the image's whole disk, nor Lima's files for it, nor devvm's logs hold the password;
  • from: a company proxy of the run's own with a password, and a --from alpine:3.21 base, with every feature, and a layer on it: the registry, Alpine's mirror and the layer's own download reach the company proxy through the builds' proxies; what the layer's commands and sudo have is the build's proxy with a password of its own; and the password is in no converted disk, image, log, build file or process's arguments;
  • network: a company proxy of the run's own (a devvm _proxy with a password, allowing any host): the VM's next launch with it in devvm's environment starts the VM's proxy again with -upstream; an allowed host goes through it by name (its event log) and the VM's event log names it; a host the VM's policy doesn't allow gets 403 and never reaches it; its password is in no process's arguments, no log and nothing of the VM's; the launch after, without it, starts the VM's proxy again going directly.

Not covered: https:// and socks5:// company proxies, which devvm refuses (upstream_proxy_scheme); proxy auto-configuration (PAC) files and the macOS system proxy, which devvm doesn't read; Kerberos or NTLM authentication. An open VM goes through its proxy as every VM does, so no project VM gets the host's settings in its /etc/environment. What devvm's redaction of Lima's logs leaves open is under your company proxy's password.

One form of a host

Every check that judges or compares a host reads it in one form, proxy.NormHost's, so a deny, a binding, a risk or a warning can never hold for one spelling of a host and miss another. NormHost lowercases a host of printable ASCII, in ASCII alone, and drops its one trailing dot, unless the host is an address, whose dot can only be its IPv6 zone's. Any other host keeps its case and its dots, and HostOK refuses it, because Unicode's case folding turns some letters into ASCII ones, such as the Kelvin sign into k. A host with two trailing dots or more keeps them all, which HostOK refuses, so NormHost gives the same host however many times it runs, and a caller that reads a host again can't turn evil.test.. into evil.test. A matcher takes a proxy.Host, which only NormHost makes, and the structure test refuses another copy (the checks on owners).

The shapes each reader meets. Each reader has a differential fuzz target (FuzzHostSites in internal/proxy, and one beside each reader elsewhere), which checks it against a frozen copy of the readers that each folded and trimmed a host its own way, and allows only these differences:

  • A rule's host and its ! read exactly as the frozen copy reads them, so a line is the same rule or no rule, and a line that starts with ! but isn't a rule is a broken deny, which makes the policy deny everything, never a valid deny. The frozen state's policy files, bindings and links read the same too (TestFixtureHosts).
  • Two trailing dots in a request's host, an SNI or a host Allows or Denies judges stay, where the copy drops one. The proxy answers 400 to both, and no rule but ** matches either spelling, while ** matches both.
  • The policy's own matching (rulesFor, quiet, byName) and devvm network lock's risks and ticks don't fold a host that isn't ASCII, where the copy folds it in Unicode. Neither meets such a host, because the proxy refuses it before the policy sees it, and the lock judges only hosts the proxy took.
  • Brackets hold only an IPv6 address, one pair of them, as in a rule, so HostOK and Host.Addr take an address bare or as [::1], never with a stray bracket, and NormHost keeps a dot after a bracket ([::1].), so that's no address either. A request for [evil.com]:443, [1.2.3.4]:443, 1.2.3.4] or [[::1]] gets 400, where net.SplitHostPort or a trim took the brackets off and the name or address in them was judged. An SNI in brackets is refused as no host name rather than as an address.
  • An IPv6 address whose zone ends in a dot keeps it, so ::1%. is the zoned address it is, where the copy dropped the dot and left ::1%, an empty zone, which is no address. The proxy answers 400 to both, and an address with a zone is never the internet's (proxy.Public), so a promisor remote at one counts as private and --from's registry at one isn't public.
  • A host with a stray bracket around an address is an address, so an MCP server there (https://1.2.3.4]/, whose hostname Go's URL parser gives as 1.2.3.4]) gets no binding.
  • A line that isn't a rule, which devvm network rm and its duplicate check compare as text, matches another line only when the two differ in nothing but the case of ASCII letters and one trailing dot, so a Kelvin sign typed for a k never names the rule with the k, such as the deny !kubernetes.io.
  • An SNI's trailing dot on the transparent path is dropped, as a request's is. crypto/tls refuses such a ClientHello, so none reaches it.
  • A NO_PROXY name that isn't ASCII matches no host, so the Kelvin sign's kubernetes.io doesn't send kubernetes.io directly, and the request goes through the company proxy.
  • A NO_PROXY entry with port 0, which no request has, sends nothing directly, as one with a port past 65535 doesn't, where the copy read git.test:0 as git.test on every port (found by FuzzNoProxy). Neither does an entry whose port isn't in plain decimal, such as git.test:080 or git.test:+80, which Go's clients match against no request, where the copy read it as port 80.
  • A secret's --host or an MCP server's host that isn't ASCII is refused, as the proxy refuses it, rather than taken as the ASCII host its letters fold into.
  • --from's registry isn't on the internet when its name is one the proxy doesn't take (HostOK), such as one with anything but printable ASCII, a bracket that a trailing dot hid ([::1].) or a shorthand address (10.1), none of which a registry's name is, so a registry is never more public than the copy finds it.
  • A partial clone's promisor remote loses its trailing dot, so a warning names example.com rather than example.com., and localhost. or 127.0.0.1. counts as private, as the proxy refuses it. The Kelvin sign isn't folded.
  • A remote's ssh host, which finds a VM's alias in the ssh config, keeps its own reading, lowercased with its trailing dot kept, as ssh reads it, because it's no host a policy judges.

The desktop

devvm desktop shows a VM's desktop on this machine with VNC, and keeps two things: no one on this machine or the network reaches the desktop without the VM's password, and the desktop gives the VM no new way out. Both hold whatever the VM's own server does, because root in the VM can replace it (how).

What it's built from: the built-in desktop layer (assets/layers/desktop.sh): Xfce and TigerVNC's Xvnc from the distribution's archive, and /usr/local/bin/devvm-desktop, which starts Xvnc on a socket of the VM's user's own (/run/devvm-desktop/vnc.sock, mode 600 in a 700 folder), with no TCP port and no password, then an Xfce session. On this machine, internal/desktop's Relay, which devvm desktop runs (internal/vm/desktop.go): a listener on 127.0.0.1 alone (platform.ListenLoopback, without address reuse), on the port the VM's state records (the ports section's host.desktop, chosen by ports.Allocator and among ports.Used), and for each viewer that passes its check, an ssh -W channel to the socket through devvm's ssh config's entry for the VM. Only a VM made with the layer has the desktop (image.DesktopLayer), because it adds about 370 MB to an image, so base and the VMs without it stay that much smaller.

Why devvm's own relay, not the port forwarder: the forwarder forwards every port a VM listens on from its start, on the same port number. A VNC server on a port would have been on this machine's loopback at every start, without anyone running devvm desktop, on a port another VM's desktop or macOS's own Screen Sharing server (5900) can have. The relay is open only while devvm desktop runs, on a port of the VM's own, and checks the password itself, which the forwarder, a byte copier, can't.

The password: VNC's own authentication (RFB security type 2: DES of a 16-byte challenge, desktop.Response) is what macOS's Screen Sharing speaks to a server that isn't a Mac, and it takes 8 characters. devvm's are random, from 31 characters (about 40 bits), checked one at a time with a second's wait after a wrong one, so an online guess takes thousands of years. The relay checks it before it starts any ssh, so a wrong viewer costs the VM nothing. It's kept in the VM's state (the desktop section's made.password, mode 600), shown only with the address (desktop_ready, a message, not the run log), and never sent to the VM, so a VM can't use it to reach its own desktop's port. Screen Sharing gets the address alone (open vnc://127.0.0.1:PORT), not the password, which would be in open's arguments where any process on this machine reads them.

What keeps the VNC connection from carrying the VM out. Every connection starts on this machine: a viewer connects to the relay, and the relay asks devvm's ssh for a local channel (-W) that the VM's sshd connects to the VM's own socket. The ssh asks for no session, agent, X11, tunnel or remote forward, and OpenSSH's client refuses a channel the server opens unasked, as for the forwarder. What the VM sends back goes only to the viewer that connected. The VM's server reaches nothing on this machine, so the VM's tier holds as it is: the VM's own connections still reach only its proxy, and devvm allows no new host for the desktop.

The clipboard: off unless --clipboard. Without it, Xvnc starts with AcceptCutText, SendCutText, SetPrimary and SendPrimary off, and the relay drops every ClientCutText from the viewer, extended clipboard ones too (internal/desktop/filter.go). It reads the viewer's messages by their lengths (RFC 6143's and the extensions TigerVNC offers: fences, continuous updates, desktop size, xvp, GII, QEMU's key and audio events) and ends the connection on a type it doesn't know, so nothing it can't read reaches the VM. The other way, from the VM to the viewer, isn't read: following the server's ServerCutText would mean decoding every screen update's encoding. A VM whose server was changed can send its clipboard to the viewer, so Screen Sharing's Use Shared Clipboard setting is what keeps it off this machine then.

The local proxy, for browsers: Chrome, Chromium and Firefox ignore the password in the VM's HTTP_PROXY and ask for it on every site, so the desktop's session uses devvm-local-proxy instead (how), which the guest setup writes (assets/guest/sync.sh) and socat serves. It gives no program a power it lacked, because the password it adds is the one the VM's environment already holds, and every program in the VM can read it there. What it must not do is hand the password to anything outside the VM, or send it anywhere but the VM's proxy:

  • Where it listens: 127.0.77.1:3128 (proxy.LocalProxyAddr, proxy.LocalProxyPort), on the VM's loopback alone (bind=), taking connections from 127.0.0.0/8 alone (range=). The port forwarder never forwards a server on that address (vmssh's dialAddr, proxy.IsLocalProxyAddr), so a VM that forwards every port doesn't put a proxy that needs no password on this machine's localhost, where other users and programs would reach the VM's proxy, and its secrets, without the password.
  • Where the password goes: only to the VM's proxy, whose address is written into the script with the password, never to an address a request names. It's in the one Proxy-Authorization header the local proxy adds, after it drops the client's, and devvm's proxy removes that header before it forwards a request. A CONNECT's tunnel carries nothing of the local proxy's after its head.
  • Web pages: a page can reach the loopback as a server, but its requests are in origin form (GET /), which the local proxy refuses with 400 before it connects anywhere. A page can't send a CONNECT or an absolute-form request line, and DNS rebinding changes only the Host header, so a page can't use the local proxy to reach the VM's proxy.
  • One request per connection: a request that isn't a CONNECT goes with Connection: close, because the local proxy reads only a connection's first head, so no later request on the connection reaches the VM's proxy without the password, as it would otherwise get 407 and the browser's prompt.
  • The file: /usr/local/bin/devvm-local-proxy holds the password, mode 700 and the VM's user's, which is stricter than the VM's /etc/environment, where the same password already is.

The tier holds as it is: the VM's proxy decides each request the local proxy sends, and a host the tier doesn't allow gets its 403.

End-to-end checks (tests/e2e):

  • desktop (Lima): a VM of base without the desktop's programs, which devvm desktop refuses (desktop_no_layer); then a VM with the desktop layer on the allowlist tier: the relay on 127.0.0.1 alone, its port and password in the VM's state; a wrong password refused, the password let in, with the VM's ServerInit and a screen update (TestE2EDesktop); Xvnc on its user's socket (700, 600) and no TCP port, the clipboard off; the password in no file of the VM's, no run log and no host process's arguments while devvm desktop started; the self-check passed and no direct connection out, nor to the desktop's port on this machine; the Xfce session's proxy variables set to the local proxy, which listens on 127.0.77.1:3128 alone, takes curl without a password to an allowed host, gives a blocked one the proxy's 403 (CONNECT and plain HTTP), refuses an origin-form request with 400, and isn't forwarded to this machine; root's own server in place of Xvnc (no password, its socket anyone's, recording what reaches it): a wrong viewer never reaches it, and the viewer's clipboard never does while its key event does; Ctrl+C closing the port; --clipboard on the same port, the clipboard on.

Not covered: the VM's clipboard sent to a viewer that takes it, by a server root changed; Screen Sharing itself, which no check drives, so its messages are the relay's reading of the protocol; a program on this machine with the password, which reaches the desktop as you do; a program on this machine, or a VM that reaches this machine's loopback, that keeps the relay's 8 connections busy or keeps failing its check, which keeps viewers out for as long as it does, and gets no further; the browsers themselves, which no check drives, so that they read the session's proxy variables rests on Chrome's and Firefox's documented behavior on Xfce, and the local proxy's handling of requests on its unit test (netpolicy's TestLocalProxy) and curl.

Pasting images

devvm paste gets an image, a PDF, or one copied file, from this machine's clipboard to an agent in the VM (how). It keeps four things. The VM gets the clipboard only when you run the command, and only an image, a PDF or a copied file. A copied file goes only after you say yes to its path on this machine (paste_file_ask), because the clipboard can name any file of yours, such as one a web page or another program put there. Nothing the VM says reaches your clipboard. And devvm leaves no process of its own running for it.

--send-file answers the question only for a file below the folder the VM mounts, which the VM can read already. confirmFile decides with sendFileAnswers: inFolder compares the cleaned path that OpenNoLinks opened with the folder's physical path, and OpenNoLinks must have followed no link at all, because a root-owned link below the folder, such as one a root container made on a Linux host, can lead anywhere. It never answers for a --clone VM. A file anywhere else is refused where devvm can't ask (paste_file_outside), and so is one reached through a link (paste_file_through_link), so a hotkey or a script can't send a file it never showed. There's no list of credential folders that devvm refuses outright, because it could never name every place a key is kept, and the question shows every path.

What it's built from: internal/platform's clipboard readers, vm.Paste, and config.toml's paste-dir.

On macOS, clipboard_darwin.go runs osascript with a JavaScript for Automation script through NSPasteboard. The script takes a PDF (com.adobe.pdf) first, as it is, before the picture of it and the temporary file of its own that Preview puts beside it. Then it asks for file URLs alone (readObjectsForClasses with NSPasteboardURLReadingFileURLsOnlyKey), counts several and reports one's path. Otherwise it writes a PNG, JPEG, GIF or WebP as it is, or a TIFF made a PNG, to a file in a private folder devvm makes and deletes, only when it's within the cap. The copy back is pbcopy. Both tools run by their paths in /usr/bin, never found on PATH.

On Linux, clipboard_linux.go runs wl-paste --list-types and --type on Wayland, and xclip's TARGETS and -t on X11, taking application/pdf before a file reference and the image types. The copy back is wl-copy or xclip -i. Each comes from the first of /usr/bin, /bin, /usr/local/bin and NixOS's /run/current-system/sw/bin that has it, never from PATH, because PATH can hold a project's folder, such as direnv's PATH_add or node_modules/.bin, and the VM writes those.

Every clipboard tool runs with exec.CommandContext (clipboard_tool.go), and devvm reads its output, never through the run log, so the image stays out of it. Each tool is stopped after 30 seconds, as a tool waits on a program that holds the clipboard and doesn't answer: a read gives paste_tool_slow, and a copy back gives a warning. Its pipes are closed a second after it ends, as a child of its may keep them.

vm.Paste (internal/vm/paste.go) finds the VM as every command does, refuses a stopped one, and reads the clipboard before touching the VM. It names the file on this machine: paste-YYYYMMDD-HHMMSS-8hex, then the image's or the PDF's extension, or the copied file's when it's letters and digits alone and at most 16 of them, and nothing else of the file's name. It runs assets/guest/paste.sh in the VM as sh -c's script, so nothing of it is left on disk. config.toml's paste-dir (settings.PasteDir) is the folder in every VM, which each launch makes through sync.sh (DEVVM_PASTE_DIR), mode 700 and the user's own.

Why push, not pull. A VM that pulls the clipboard on Ctrl+V, through a stand-in xclip and a channel to this machine, would need three things. It would need a server of devvm's on this machine for as long as a session lasts, and devvm runs limactl shell in its own place, so no devvm process exists during a session. It would need a remote forward into the VM's sshd, which allows them on 127.77.0.0/16 alone, for links. And anything in the VM could read your clipboard at any moment while a session is open, a screenshot of your password manager included. With push, only the host starts the transfer, and only an image, a PDF or a file crosses. Stand-ins for xclip and wl-paste in the VM would reach only Claude Code and pi, because Codex and opencode read X11 or Wayland in their own process, and both already handle a pasted path.

What the VM can't do. It can't ask for the clipboard, because devvm reads it once, when you run the command. devvm asks only for a file's reference, a PDF and image types, never text, then checks an image's or a PDF's bytes against the type (http.DetectContentType, for which a PDF starts with %PDF-). Text is never taken for a file. AppleScript's the clipboard as «class furl» makes any text a path, /Users/you/.ssh/id_ed25519 as it is and hello as /hello, so the macOS reader asks NSPasteboard for file URLs alone, which text never gives. A copied file whose path can't be found is refused (paste_file_gone) rather than Finder's icon beside it sent.

It can't write to your clipboard. The path is built on this machine from paste-dir and a name devvm picks, both from a fixed set of characters, before the VM runs anything. Of a copied file's own name only its extension is kept, letters and digits alone, because a file in the project folder is named by the VM. So what reaches your clipboard is devvm's own path, with no space, quote or newline in it, which can't run anything when you paste it into a terminal.

It can't keep devvm reading or waiting. The one thing devvm reads back from the VM is a count, parsed as a whole number from bounded output. Each of paste.sh's commands is stopped once it prints past 32 bytes on stdout or 4 MiB on stderr, so a VM that prints without end can't keep devvm reading. It's also stopped past its time, 10 minutes for put, which carries up to 64 MiB, and 2 for count and rm, so a VM that never answers can't keep devvm waiting. The command then fails as it does for any other failure of the script (paste_not_sent, paste_count_failed, paste_rm_not_done). It gets no SSH agent, because the writes and counts go through the backend's Exec as it is, never target.exec, as the clone checks do.

It can't send a file of yours through a link. A copied file may be in the project folder, which the VM writes, so its path is cleaned, never resolved first, and opened as named following no link but the system's. platform.OpenNoLinks opens each component from its parent with O_NOFOLLOW, through golang.org/x/sys/unix's Openat, because the standard library exports no Openat on macOS and internal/safefile is standard library only. It reads a link on the way with Readlinkat and follows it only when Fstatat says root owns it, and the folder's Fstat says root owns that too and neither its group nor others can write it, as for macOS's /tmp, /var and /etc in /, for at most 40 hops. Root owning the link isn't enough on its own, because a link of root's can be hard-linked into a folder of yours, and in a folder only root can change, no one else can swap the link between its Fstatat and its Readlinkat. It never follows the file itself, and it opens it with O_NONBLOCK and O_NOCTTY, so a FIFO never makes devvm wait and a terminal never becomes devvm's.

A link the VM makes in a mount is the user's on this machine, never root's. So a link in the file's place, a folder's link planted before the copy or swapped in after it, and a copied folder's reference whose trailing slash hid a link all fail (paste_file_link) rather than send what they point to, and your own links do too. Every step goes through a file descriptor, so there's no moment for a swap between a check and the open. The file opened is then checked and read as every file a VM can write is, by internal/safefile (Checked, then ReadAll): a regular file within the cap of 64 MiB, the cap an image is held to as well.

In the VM, paste.sh writes with umask 077 to a .part name and renames it, and it refuses a paste-dir that's a link, not a folder or not the user's. Its count and rm see only regular files at the folder's top level with devvm's names, never anything else in a folder that may be yours. Root in the VM can get around any check the VM runs, which gives it nothing it couldn't do to a file in the project folder.

What's left on this machine: on Linux, wl-copy or xclip serves the path until you copy something else, because a Linux clipboard's contents live in the program that copied them. It isn't devvm's process, and devvm runs it with no pipes on its output, because Go's Wait waits for a child that inherited them. On macOS, nothing.

End-to-end checks (tests/e2e, the project section): with stand-in clipboard tools in a test build's DEVVM_CLIP_TOOLS, devvm paste --json puts the copied image into the running VM, where its SHA-256 matches, mode 600 in the folder of mode 700, and the stand-in copier got the path. devvm paste rm --force deletes it and leaves a file of the user's in the folder, and a stopped VM is refused before the clipboard is read.

The CLI tests (testdata/script/paste.txtar, paste_rm.txtar) drive the rest against the stubs: the types read, the bytes sent, each refusal, the launch's offer and config.toml's paste-dir. On macOS, TestReadClipPasteboard runs the real script against a pasteboard of the test's own, never the clipboard. Text that's a path or a file:// URL is no file, nor is a file:// URL as public.url. A file URL with Finder's .icns icon beside it is the file, a file reference URL is resolved, two files are counted, and a file that's gone is refused. A PNG and a TIFF are read as PNGs, beside text too. A PDF is read as it is, beside its picture and beside the temporary file a thumbnail copied in Preview names, while a file URL beside a JPEG, as Photos copies, is the file. One past the cap is refused before it's written.

Not covered: the real clipboard, which no automated check reads. The copies of Finder (one file URL per file, with an .icns icon), Photos (a JPEG and a file URL), Preview (a PDF with a TIFF, and a thumbnail's temporary file beside them), and Safari, Chrome and Firefox (a TIFF or a PNG) were checked by hand on macOS, and TestReadClipPasteboard writes the same types to its own pasteboard, so a change in what an app copies would need checking by hand again. Also not covered: image types other than PNG, JPEG, GIF, WebP and TIFF, which devvm doesn't read on macOS; whether macOS asks before osascript reads the clipboard, which depends on the release and its privacy settings; Linux's clipboard tools, which only the stubs stand in for; and the agents' own reading of a pasted path, which their releases change.

Base's image and packages

base starts from the newest Ubuntu cloud image on each machine, and its packages are the newest when each key of base first builds, so devvm's own files pin neither and need no bumps (how, packages). What it trusts, and where:

  • The image: Ubuntu's cloud image key alone, pinned in devvm's files. devvm checks the release's SHA256SUMS signature itself, in Go, so a host without gpgv checks it too, and a bad signature is refused, never passed over for an older release. The listing that names the newest release is unsigned, so a server or network that can change it can only hold devvm back to an older signed release, over HTTPS. The signed SHA256SUMS names files, not its release, so such a server could also serve an older release's files under a newer release's name, which devvm then records as the pin; that holds base back the same way, and it makes the package check's date stricter, not looser. The pinned SHA-256 then decides every later download.
  • The packages: Ubuntu's archive key, through apt in the build VM, which holds nothing but Ubuntu's image and devvm's own scripts while it records. A mirror only serves files, and apt checks each against the archive key, so ubuntu-mirror can't install a package Ubuntu didn't publish. Ubuntu's InRelease files carry no Valid-Until, and the build VM has no lists before, so a stale or hostile mirror, or anyone on an http:// path to one, can serve an older signed state of the archive. devvm refuses one older than the archive state the pinned cloud image was built from, naming the mirror (packages_stale_mirror, packages_stale without one): every pocket but the release's must be dated no more than a day before the image's release, and the release pocket no earlier than Ubuntu's release day (Release.Stale). So a recorded state is never older than the pinned image. A mirror that fell behind after the pinned release still gets recorded, so freshness past the pin's date rests on the mirror, and on HTTPS for Ubuntu's own.
  • The cache: a first build records what its own apt checked, and devvm checks it again on this machine before it keeps anything. The build hands back the InRelease files and package lists apt used, and devvm verifies each InRelease with Ubuntu's archive key, pinned in its files, in Go (pgp.go's clearsigned messages). Each list must be one a verified InRelease gives the SHA-256 and size of, and each package one a list gives the SHA-256 of, so the recording VM can't add a package Ubuntu didn't publish, even with root, and the set keeps the archive's own entry for each package. devvm keeps each file under its own SHA-256 and each key's set once. What comes back from the VM is checked for shape, hashes and size (at most 20,000 entries and 16 GiB of packages, 2 GiB of lists) before anything is kept, so a build VM can't put a file under another file's name, change another key's set, or write outside the cache. A key's set is never written again, so a later build can't change it either. The recording VM can't record an older version than apt would install either: the build must hand back resolute-updates' and resolute-security's InRelease files with lists for the recorded packages' architectures, and every non-empty list that each InRelease it hands back gives for the recorded packages' architectures, and devvm refuses a package that the release pocket, -updates or -security lists a newer version of, ordered as dpkg --compare-versions orders them (packages_lists_missing, packages_not_newest). apt in the build takes phased updates too, so the newest version is what it installs. A replay checks each file's SHA-256 on this machine before it sends it, and apt in the VM checks it again against the set's entry. Replays trust apt's entries as recorded (trusted=yes on a local repository of files devvm checked), because the archive's signature covers the archive's lists, not a set of packages taken from them.
  • What it doesn't stop: anything with root in the recording VM before apt.sh end (a feature's script, a compromised pinned download) chooses which of Ubuntu's signed packages get recorded, because the host checks that each package is the archive's and the newest that the lists handed back have, not that apt chose it. It can record a package base doesn't ask for, or one from -backports, but never one from -proposed. It can also hand back an older signed state of -updates and -security than the archive's newest, dated as early as a day before the pinned image's release, which the stale check allows, and record the newest versions of that state. Every later build of that key replays what it recorded, as the same image would. It can also change the image itself, which the image's key doesn't cover. devvm rebuild base records anew. Packages for --from bases and for layers come from their sources as they are, unpinned.
  • Breakage from upstream: users now build from images and packages that e2e hasn't run. If the newest image doesn't boot, a first build tries the release before it (how), which covers a release whose kernel Lima can't start, but not packages that break base.sh or a VM later. A scheduled build of base from the newest image and packages, on CI or the test machines, should catch a break before users do; it isn't built yet.

Shared tools

Each tool version is one compressed EROFS image, loop-mounted read-only in each VM from a read-only share (details).

  • Measured (macOS): ten tools take 0.85 GB as images (1.5 GB installed), once for every VM and mix. Start times from an image match a local disk warm (node -e 0 13 ms vs 14 ms, claude --version 3 ms), and are 10–30 ms slower cold. Mounting five images takes 0.15 s; VM start is unchanged.
  • Why images, not a shared folder: tools run from a virtiofs folder were about 3× slower warm (node -e 0 38 ms, claude --version 30 ms), the Mac's case-insensitive disk collided 33 file names in Python's terminfo, and mise's version links failed in a read-only folder.
  • Why not per-tool layers: an image chain for every mix of languages and agents repeats each agent's files in every mix.
  • Where they build: a tool image is shared by every VM whose tools need its key, and its build runs whatever runs as root in its build VM, so the key alone can't keep one VM's base out of another VM's tools. A glibc tool image therefore always builds in a clone of devvm's own Ubuntu base, on every backend, even for a VM on a --from Debian or Ubuntu image, whose code would otherwise run as root in the build of images that Ubuntu VMs then mount. --from VMs mount those images, because the tools are their projects' own prebuilt releases, which run on any glibc new enough, and devvm still refuses a tool that needs a newer glibc than the image has (shared tools and glibc). A musl tool image can only build on Alpine, so it builds in the VM's own --from base, and its key hashes that base's digest, so it's only ever another VM's on the same container image. Before it builds, devvm checks the base's record against what the images are for, and refuses any other base (tools_wrong_base, building tools). The cost is a build of devvm's own base for a --from VM's first glibc tools when it isn't built yet.
  • A VM for each tool: a tool's installer runs as root in its build VM, and a tool image's key hashes only its own tool's inputs, so tools built together in one VM could write into each other's images: through a shared work folder, a process left running until the next tool's mkfs.erofs, or root replacing mise or mkfs.erofs itself. A fresh folder for each tool and killing its processes wouldn't stop root, so each tool builds in a VM of its own, with an output folder of its own, and only that tool's image leaves it (building tools). Measured on Fedora 43 (bare-metal x86_64, Lima with QEMU and KVM), building node, pnpm and bun took about 16 s in one VM and about 34 s in three, the same in two runs each, so each extra tool costs about 9 s, once for each tool version.
  • Why a tool that doesn't mount fails the launch: mise would otherwise download the same version into the VM on first use, which gives that VM a private copy, a download nobody asked for, and one that the VM's tier may block, all without a word (how).
  • Instead of Nix: Nix and NixOS were weighed as the way to deliver the shared tools and rejected, because NixOS breaks prebuilt binaries, and a Nix hidden under the tools shows through in read-only-store errors. The nix layer is separate, and you choose it. It gives a project that uses Nix a Nix of its own in its VM, with its own store and daemon, and the shared tools stay as they are beside it.

The shared Nix cache

VMs with the nix layer share their downloads from cache.nixos.org through a cache that only the host fills (how). It's the first thing that VMs share, so the design keeps two things: each VM's Nix store stays its own, and no VM can change what another VM gets.

Why a cache the host fills, not a shared store: one store, or one daemon, shared between VMs is what Nix's own store vulnerabilities break. CVE-2026-110450 (the daemon's store corrupted through repair), CVE-2026-39860 and the CVE-2024-27297 family (a fixed-output derivation that changes its output after Nix registered it) each let a client of the daemon change paths in its store, and in a shared store, every other VM would then trust those paths. A VM's own builds are worse: a path a VM built has no signature that another VM could check, short of a key that trusts that VM, and then every VM trusts every other. A binary cache keeps the trust where Nix already has it. Each VM's Nix fetches from the cache as from cache.nixos.org, checks cache.nixos.org's signature and the NarHash itself, and adds the path to its own store, so the cache only saves downloads.

What the host checks, and what each VM checks:

  • The proxy (internal/proxy/nixcache.go) takes only GET and HEAD of nix-cache-info, <32 nix32>.narinfo and nar/<52 nix32>.nar with no suffix or .xz, .zst or .bz2, with no query and nothing escaped (nixPath, fuzzed by FuzzNixPath), and 400 for anything else. It makes up nix-cache-info itself.
  • It fetches from https://cache.nixos.org alone, only when the VM's policy allows cache.nixos.org:443 and, by method and path, a GET of the path the VM asked for (policy.judge), through the floor or the company proxy (dialOut), with the system's roots and the user's CAs, following no redirect, and sending only its own GET and User-Agent.
  • A narinfo is kept when its StorePath is the path asked for, its URL is a NAR path of the pattern above, its hashes are SHA-256 in Nix's base 32, each reference is a store path's base name, and a Sig by cache.nixos.org-1 (the Ed25519 key pinned in nixKey) verifies over 1;StorePath;NarHash;NarSize;References, the references as full store paths, sorted and joined by commas (parseNarinfo, against a narinfo of cache.nixos.org's own in internal/proxy/testdata/nix/). The bytes kept are cache.nixos.org's, as they came.
  • A narinfo's URL must be named by its own NarHash or FileHash, since the URL isn't signed. A NAR is fetched only after a narinfo this proxy checked names its URL (nixKnown, at most 65536 entries), and kept only when its SHA-256 and size are that narinfo's FileHash and FileSize, read through a limit of FileSize plus one byte. A HEAD never fetches one.
  • Each VM's Nix checks the signature again and the NarHash, which the host can't: the compression is xz or zstd, which aren't in Go's standard library, and internal/proxy takes nothing else. The spike showed a VM's Nix refuses both a narinfo with an added reference and a corrupted NAR.
  • Files go into a temporary file in the folder (.tmp-*, 600) and are renamed into place, in folders of 700. Not-found answers and errors are never kept, and the VM gets 404, so its Nix goes to cache.nixos.org itself.

The cap: nix-cache.size, 10 GiB when it's off, passed in the proxy's config as nix_cache_max. Before a proxy writes a file, it takes the file's room under an exclusive flock on .lock (reserve), in whole 4 KiB blocks. When .size, the running total, is missing or the new file would pass the cap, it counts the folder again, each file by the larger of its size and its blocks, and deletes the least recently used files, by modification time, which a hit sets, down to nine tenths of the cap. A NAR being fetched is made its full size at once and counts, but is never deleted, so a fetch that would pass the cap with them is refused. A fetch that fails gives its room back. One proxy fetches each NAR once however many requests ask for it, and at most four at once. A NAR whose FileSize is over the cap isn't fetched. devvm gc, its --nix-cache and the daily retention run trim under the same lock (TrimNixCache). A temporary file over an hour old is a dead proxy's, and the next count deletes it.

What stays open:

  • Timing and filling the cache: Attack vectors lists what one VM learns of another by how fast the cache answers, and how a VM that fills the cache to its cap pushes other VMs' paths out. Hiding the timing would mean waiting as long as a fetch on every hit, which is the saving.
  • Private caches (Cachix, a netrc) are never shared: only root in the VM can add a substituter, and Nix reaches it through the allowlist directly.

Options weighed:

  • Nix's local overlay store, the VM's store over a read-only lower store shared from the host. It works on Lima, but it's still experimental in Nix 2.35, the lower store can't change while it's mounted, so sharing new paths means remounting, and a garbage collection by a daemon not set up for it writes whiteouts that hide lower paths from that VM for good.
  • Packages fetched into an image, by a custom layer that runs nix build while the image builds (the recipe). Clones share them on disk at no cost, but only what's in the image, and a changed flake.lock needs a rebuild.
  • Open VMs: every VM has its own proxy, an open one's included, so open VMs share the cache through it, with the VM's password, as confined ones do. Ruled out: a shared loopback listener without a password, because anything on the host or any VM that reaches the host's loopback could use it; and the cache folder mounted read-only into VMs, which leaves the VM's Nix to read the files and the host with nothing to fill it.

Review (the security-audit skill, on nixcache.go, its callers and the VM's setup):

  • What a VM sends (headers, a body, a query, an escaped path, another method): ruled out: nixGet makes a request of its own from the checked path, the VM's User-Agent and path go only to its own event log, and what's kept is cache.nixos.org's body under a name of the pattern.
  • A path out of the folder (.., %2e, a symlink): ruled out: the names hold only Nix's base 32, which has no /, . or %, and can't be .lock, .size or .tmp-*; the folder is in devvm's data folder, which no backend mounts, so nothing in a VM can put a file or link there.
  • Upstream elsewhere (a redirect, DNS rebinding, a company proxy): ruled out: every dial is dialOut(cache.nixos.org, 443), through the floor or the company proxy as any request, ServerName is fixed and no redirect is followed; the client is made after the user's CAs are read.
  • A NAR kept under another NAR's name: confirmed, fixed. A narinfo's URL, FileHash and FileSize aren't signed, so a bad upstream (or a CA in the user's CA folder) could pair a real narinfo with another NAR's URL and a file of its own, and every VM would then get that file for the other NAR, which its Nix refuses, until a trim. parseNarinfo takes a URL only when it's named by the narinfo's own NarHash or FileHash, and a hit whose size isn't that of the narinfo this proxy checked is dropped and fetched again; unit-tested.
  • The cap under many proxies: confirmed, fixed. Files being fetched didn't count and were written before any room was taken, so one VM's parallel requests could put many NARs' worth on the host's disk past the cap, and a small narinfo takes a whole block. Now a fetch takes its room under the lock first, makes its file its full size at once, and is refused when the files being fetched leave no room (reserve); sizes count whole blocks; one proxy fetches each NAR once, however many ask, and at most four at once (fetchOnce); a narinfo is written under the lock; unit-tested (40 writers at once, a full cache, eight requests for one NAR).
  • A HEAD that downloads: confirmed, fixed: a HEAD for a NAR the cache doesn't have answers 404 without fetching it.
  • Parser differences (spaces, \r, a key twice, references twice): ruled out: they only refuse, and each VM's Nix parses and checks the bytes again, so no narinfo the host keeps means something else to Nix.
  • One VM learning of another: timing only: hits and fetches answer with the same bytes and headers (no Last-Modified or ETag), events go to the VM's own log, /blocked holds none of them, and errors in the body say nothing of the host.
  • The VM's own settings: ruled out: devvm-cache.conf and the !include line are root's, in that VM; only root is a trusted user, and root in a VM changes only its own Nix, while the cache takes nothing from any VM.
  • Memory: ruled out: a narinfo is read up to 1 MiB, and nixKnown holds at most 65536 entries per proxy.

End-to-end checks (tests/e2e, nix): the VM's Nix has the cache first and cache.nixos.org's key alone; nix run nixpkgs#hello comes through the cache, fetched by the host into the folder (files 600, folders 700); a VM's PUT and POST, a URL in the path, a query and .. get 400, a NAR no checked narinfo names and a path cache.nixos.org doesn't have get 404, and the host keeps none of them; a second VM gets the first's paths as hits and fetches none; after devvm network open, the open VM's nix-daemon still goes through its proxy and keeps the cache first.

A CA per VM

To put a secret in, a VM's proxy shows the VM certificates from a CA that the VM trusts, and inside the VM that CA vouches for any site. So each VM has CAs of its own, and the design keeps two things: a CA's key never leaves this machine, and no VM's proxy can make a certificate that another VM accepts (how).

What it's built from: trust.InitCA, at each launch, whatever the VM's tier, readies the VM's current CA and its next one in vms/<hash>/run/ca/ (paths.VM.CA): ECDSA P-256, 30 days and an hour each, the next one starting a week and an hour before the current one ends. The proxy's config names the four files (ca, ca_key, ca_next, ca_next_key) and their certificates' SHA-256 (ca_sha256, ca_next_sha256), so a replaced CA starts the proxy again. The proxy signs with the next CA from an hour after its start (ca.signer), and the VM's setup installs both certificates, devvm-proxy.crt and devvm-proxy-next.crt, so the switch needs neither a launch nor a new proxy. The guest never fetches a CA: its trust comes only from the setup that devvm sends over ssh at each launch.

Threat check (the security-audit skill, guidance mode, its data isolation and lifecycle companion). Leads, each ruled out, fixed or listed:

  • One VM's CA signing for another: ruled out. Each proxy's config is devvm's, mode 600 in the VM's own run folder, and names only that VM's files, and a VM reaches no other VM's proxy without that VM's password. A VM trusts only the certificates its own setup sends, and the setup removes any other devvm-*.crt.
  • The keys reaching a VM: ruled out. The setup sends the two certificates and nothing else from the folder, /ca.pem serves certificates only, and no VM mounts devvm's data folder. The CLI tests check the setup's files for a private key, and e2e searches the VM's /etc, /home, /root and /usr/local for each key.
  • Key files: the folder is mode 700 and each key mode 600, written whole through a temporary file. Fixed: the proxy read the CA's files through tls.LoadX509KeyPair, which follows links and takes any mode, and it now reads them as the user's own regular files, not links, with a key no one else may read or write, of at most 64 KiB (loadCA, readPrivate). On macOS each VM's CA folder is kept out of Time Machine at each launch.
  • Expiry and rotation: a CA lasts 30 days and an hour, and each certificate it makes a day, never past the CA's end. Listed: the next CA's key is on disk for up to 23 days before that CA starts, so a copy of it taken then works until that CA ends, up to 53 days after the copy. A VM that isn't opened again stays verifiable for at least 30 days less an hour after its last launch, which is the trade the successor buys.
  • Two launches of one VM at once: fixed. InitCA holds the CA folder's lock, run/ca/lock, while it reads and writes the CAs, so two launches at once take turns and never leave a key and a certificate from different runs (TestInitCATogether).
  • Lifecycle: a remake keeps the VM's folder and its CAs. devvm rm, devvm gc --orphans and the deletion of a VM whose creation was interrupted delete the folder with the keys. A change of tier keeps the CAs, because every tier's proxy signs with them.
  • Issuer confusion: fixed before it could arise: each CA's name holds its serial, so a VM's two CAs never share a subject, which some verifiers look issuers up by.
  • Clock skew: the switch waits an hour past the next CA's start, so a VM whose clock is up to an hour behind still accepts the certificates.

End-to-end checks (tests/e2e, network): two confined VMs have different CAs; each VM trusts its own two and none of the other's, and its /etc/ssl/devvm.pem holds the next one; no key is anywhere in the VM, and the keys are mode 600; each proxy serves its own CAs at /ca.pem, and a certificate it presents for a bound host verifies with its own VM's CAs and not with the other's; devvm rm deletes one VM's CAs and leaves the other's. The switch itself is checked by unit tests (TestNextCASigns, TestInitCASwitch), because it happens weeks after a launch.

A link lets a program in one VM, the client, reach a TCP service in another VM, the target, by name, as in postgres://db:5432/app. Links work on every tier, within the tier rule below. You run devvm link publish 5432 in the target's folder to offer the port to any of your VMs, and devvm link add db 5432 in the client's folder to reach it as db:5432 and db.devvm.internal:5432. A link carries its connections over ssh through the host, so it uses neither VM's network, and the design keeps every guarantee that the tiers' confinement and port forwarding give. The review of the code checks it against the threat check below.

The rules:

  • A link is reached only by its name. The client reaches the target's port at the link's short name and at NAME.devvm.internal, and never at its own 127.0.0.1 or ::1, so localhost:PORT in the client stays the client's own. The short name is the target's folder part, or the name given with --as NAME, and the target's full VM name is never a hostname. .internal is reserved for private use, so NAME.devvm.internal names no host on the internet.
  • The target publishes. A port is reached only once the target's folder has published it with devvm link publish, which offers it to any of your VMs. Each link is still made from the client's folder, with devvm link add.
  • A client links only to a target on its own tier or a stricter one. A link joins the two VMs' trust (below), so a client linked to a target on a lower tier would reach more through the target than its own tier allows: an allowlist client linked to an internet or open target would reach the internet through it. devvm checks the rule when the link is made, at each launch of the client, on every connection, and when devvm network gives the target a tier lower than the client's or the client one higher than a target's, both of which it refuses while such a link exists (link_tier_mismatch). For a client on a confined tier, on every connection the target's tier must also be enforced as the target runs (netpolicy.Listed), not only recorded in its state: devvm network allowlist on a running open target takes effect at its next start, and a target whose self-check failed may reach the internet directly, so until then the connection is refused as unenforced. devvm link add, devvm link publish of a port such a client links to, and the client's launch warn of a running target in this state with the same check (link_target_unenforced), refusing nothing, and a stopped target isn't warned of, because its tier applies when it next starts. An open client may link to a target on any tier.
  • A connection never starts a VM. A connection to a stopped target fails, and devvm logs why in the client's event log, but the target stays stopped.
  • devvm records links on the host, in each VM's state under ~/.local/share/devvm, never in a project folder or a VM. The client's VM gets only the names and addresses it needs, which devvm checks before it sends them.

A link joins the two VMs' trust. Code in the client can often run code in the target through the target's own service, such as Postgres's COPY … TO PROGRAM, and it then has whatever the target has: its network, the secrets its proxy puts into requests, and its project folder. devvm doesn't try to stop that, because it's the service's own behavior. So a link is safe only between VMs you'd trust with each other's reach, and devvm link add says so when it makes one. The tier rule above keeps a link from widening the client's tier.

What it's built from:

  • A VM's identity. Every VM gets a random ID when devvm makes it, recorded in its state. A link records the target's VM name and its ID when it's made, so a VM made again in the target's folder, which has the same name and a new ID, isn't the linked target, and a second VM with the same folder name that appears later changes nothing.
  • Which VM a link names. devvm link add TARGET PORT takes a VM's full name, its ssh alias (devvm-<folder>, as its state records it), a folder's path, or a folder's name, which is matched against the folder that each VM's state records, so a VM whose backend cut its name still matches its whole folder name. A folder name that matches several VMs is refused, with each VM and its folder listed.
  • The published ports are in the target's state, a list of ports and ranges as devvm ports takes them, without all. devvm link unpublish takes ports out of the list, and a link to a port that isn't published is refused on its next connection.
  • An address per target. Each target a client links to gets an address of its own in 127.77.0.0/16, chosen when the first link to it is made and kept for every port of that target in that client, so two targets can share a port. The client listens on the target's own port, so devvm link add db 80 listens on port 80. The addresses are internal and appear only on these pages.
  • Names in the client. The setup that devvm sends at each launch writes a block marked # devvm links begin and # devvm links end into the client's /etc/hosts, with a line 127.77.x.y NAME NAME.devvm.internal for each target, and replaces the block whole, writing the file in place rather than renaming over it. devvm sends the same block over ssh as root when links change on a running client, and it applies at once. No link name goes into NO_PROXY or no_proxy, which name the VM alone, because a running VM can't take a new environment: HTTP clients with the VM's proxy settings reach a link through the proxy (below). So a change of links changes no VM's environment, restarts no daemon, and on Lima runs no limactl edit, which would give the VM new ssh host keys.
  • The client's sshd. Every VM's sshd allows remote forwards to 127.77.0.0/16 alone, with one rule written when the image is built, so no link rewrites or reloads it. That's 00-devvm.conf from assets/layers/base.sh, which sets AllowTcpForwarding all, GatewayPorts clientspecified and PermitListen 127.77.*:*, and keep AllowStreamLocalForwarding local, PermitTunnel no and X11Forwarding no. Without clientspecified, sshd would bind every remote forward on the VM's loopback, 127.0.0.1. sshd matches the address a request names against the rule as text, so 0.0.0.0, 127.0.0.1, ::1, localhost and * are refused, and only devvm on the host asks for these forwards, always with a numeric address. The rule is a safeguard for an honest VM, because root in the VM can change sshd, and the boundary is the host's ssh client (below).
  • Low ports. At each start, the setup sets net.ipv4.ip_unprivileged_port_start to 0 where it's 1024, which is on Lima's Alpine VMs, so sshd can listen on a link's port below 1024 for the VM's user. Lima's Ubuntu and Debian VMs already have 0, so devvm leaves it there.
  • The link session. For each running client with links, a hidden command, devvm _links, runs on the host as one detached process. It keeps an ssh connection of its own to the client, never the forwarder's master, with the options of internal/vmssh: -F none, BatchMode, the VM's key alone (IdentitiesOnly, IdentityAgent=none), its pinned host key, ForwardAgent=no, ForwardX11=no, Tunnel=no, PermitRemoteOpen=none, PermitLocalCommand=no and ProxyJump=none. It starts that connection as a master with ClearAllForwardings=yes, so the master asks for nothing at first, and adds each link with ssh -O forward -R 127.77.x.y:PORT:<socket> and removes it with ssh -O cancel, at its start and while the client runs. A cancel keeps the connections that are open, and the master ending drops them. Each link is its own -O forward, never ExitOnForwardFailure for all of them, so a link whose address a program in the client already holds fails alone, with an error naming the link (link_port_taken).
  • The sockets. Each link's forward ends at a unix socket on the host, mode 600 in devvm's run folder ~/.local/share/devvm/run (mode 700), named by a hash of the client, the address and the port, because a socket's path has fewer than 104 characters. The masters' control sockets are in the same folder, named by a hash of the client, and for a master to a target, of the target and its start too. A stale socket at the path is replaced, anything else there is refused, and the socket goes when its link or the process ends.
  • Each connection. When a program in the client connects to a link's address, the client's sshd opens a channel to the host for the forward, and the host's ssh connects it to that link's socket. devvm _links then reads the links state again and checks that the link still exists, that the target's ID matches, that the port is published, that the tier rule holds, that the target runs as its backend says, and, for a client on a confined tier, that the target's tier is enforced as it runs. The connections to one target share what its backend says of its run, which is whether it runs, its start and its ssh. One lookup is in flight for each target, and its answer is reused for one second (linkRunFor), so a burst of 256 connections asks the backend once rather than once for each. A connection that closes while its lookup runs finds the target stopped, but that lookup isn't kept, and the connections waiting on it look again, so they get the target's real answer. A target that stops is noticed within that second, and the connection's other checks, the tier's as the target runs included, are made for each connection. That tier check asks the backend again, and a stopped VM never runs confined, so for a client on a confined tier it notices at once that the target stopped. When the backend then says the target no longer runs on the start that was looked up, the connection is refused as link_target_stopped, not as unenforced. It then carries the connection with ssh -S <master> -o ProxyCommand=/usr/bin/false -W 127.0.0.1:PORT through a master to the target that it keeps, one per target, with the target's key and pinned host key. The target's sshd connects to the target's own loopback. When the master is gone, -S alone would make a connection of its own, and ProxyCommand=/usr/bin/false makes that connection fail, so a channel goes through the master or nowhere. A target's master ends when the target stops, and the next one reads the target's known hosts again, because a VM whose Lima config changed gets new host keys when it boots. Each relay's ssh (-W) waits for the target's sshd to end its channel, so each runs with a context of its own (vmssh.relayConns, which the port forwarder's forwards also use). The link's removal and its master's replacement close its connection and cancel that context under the session's lock, which kills the ssh (exec.CommandContext), and a relay that ends by itself releases its context. So a removed link's open connections end with it, and a target that never ends a channel can't keep the relay's ssh process, or one of the 256, past either. A link whose address and port lead to another target at the next sync, as a link removed and another added within one second would, cuts the old target's connections and starts a new set for the new one, and a connection accepted before that change is cut with the old set. While a link lasts, the relay's grace (pipeSSH, as for the forwarder) kills an ssh whose client in the client VM has closed and whose target has sent nothing for 30 seconds. devvm never starts the target. At most 256 connections are carried at once, and the next one is refused and logged. A link's socket holds 128 connections waiting to be accepted on macOS, and the process accepts nothing while it starts an ssh, so its accept loop only accepts, and hands a burst on whole once 5 ms pass with nothing more waiting, the first has waited 50 ms, or 257 wait. Another goroutine then carries or refuses each connection in it, logging each refusal before it closes the connection, while the loop goes on accepting the next burst, and the loop waits for that goroutine only once 257 of the next burst wait. So every connection in a burst is carried or refused with link_limit, and none is refused by the socket unlogged.
  • The proxy's entrance. In a client on any tier, an HTTP client that honors HTTP_PROXY sends db:5432 to the VM's proxy, and the proxy is a second entrance to the same socket, so a link added while the client runs works at once without a restart. devvm _links writes every link the client has, carried or not, to links.json in the client's run folder, vms/<hash>/run/ (mode 600, written whole) whenever they change or the file is gone, with each link's names, address, port, target and socket. A link it doesn't carry has no socket, and a session that ended leaves its list, so the proxy refuses those links (502, link_refused) instead of asking its rules, which could send db to a host the host's resolver or a company proxy finds by that name. devvm removes the list with the VM. devvm puts the path in the proxy's config as links, and its run folder, where the sockets are, as link_sockets, so internal/proxy stays standard library only, and the proxy reads the list for every request, after the VM's password and before any rule, as it does for devvm.proxy. It matches CONNECT NAME:PORT and absolute-form GET http://NAME:PORT/ exactly, after one normalization: lower case, one trailing dot dropped, and NAME.devvm.internal as the list names it. It takes an entry only when the entry's socket is the one that proxy.LinkSocket names from devvm's run folder, this VM, the entry's address and its port, which is also the name vmssh.Links.Socket gives the socket. It then connects to the socket and passes the bytes as they are: no SNI check, no interception, no secret put in, even when a secret's hosts would match, and no rule asked. An absolute-form request goes over a new connection to the socket for each request, without the proxy's headers, and HTTPS in absolute form gets 400. devvm _links's checks of each connection apply to both entrances unchanged, and it logs the connection once, as link. A stale entry fails there, or finds no socket, which the proxy answers with 502 and logs as link_refused (not carried). The proxy also refuses any other name under devvm.internal, logged as a refused block, so a long name never reaches the rules. An absolute-form request to a link ends when the client gives it up, so a target that never answers can't hold the client's 256 connections. Anything else not on the list meets the floor and the rules as before, so a short name the client has no link for, before its first session lists it, is the rules' to decide.
  • Events. devvm _links writes link, link_refused (with why), link_target_stopped and link_limit events to the client's event log, in the proxy's JSON-lines format, with the link's name as the host and the target VM as target, so devvm network log shows them. Every client gets an event log for them, whatever its tier. devvm _links writes it with the proxy's own writer, which rotates it past 10 MiB by the proxy's rule and follows the file to its new name when the other writer rotated it, so the two writers never lose each other's lines.
  • The forwarder skips links. The port forwarder (vmssh.Forwarder) forwards a server on any loopback address of the VM's, so it would put a link's listener on the host's 127.0.0.1 and ::1. It never forwards a listener whose address is in 127.77.0.0/16, on any VM, so a server of the client's own on 127.0.0.1 with the same port is forwarded as usual. Lima's own forwards don't take it either, because devvm's rules ignore every port first, and Lima's fallback rule matches 127.0.0.1 and the bind addresses 0.0.0.0, :: and ::1 alone.
  • In VMs' lives. A launch starts devvm _links once the client runs and its setup is done, warns once for each stopped target (link_target_stopped) without starting it, and skips a link whose tier rule no longer holds, with link_tier_mismatch. For a client on a confined tier, it also warns once for each running target whose tier isn't enforced (link_target_unenforced). devvm link add and devvm link rm on a running client change its setup and its running devvm _links at once, and on a stopped client they apply at its next start. devvm stop stops devvm _links with the client, which ends its connections and removes its sockets, and the process also ends once the client no longer runs the start it was made for, as the forwarder does, or has no links left. devvm rm of a client removes its links with its state, and devvm rm of a target removes every link to it from every client's state and names the clients that lost one, deleting nothing else of theirs. devvm link unpublish of a port with links names the clients that link to it. Both backends must have the link feature, which needs ssh on both VMs, and devvm checks it with Review.Require when a link is made and at each launch.

What keeps a link from carrying a VM out. Every connection starts on the host, and neither VM's network carries it:

  • A confined VM reaches only its proxy and the links you made. The link's bytes travel inside ssh connections that the host opens, so no backend's confinement changes, and the client's own connections, including sshd's, stay confined as before. Through its proxy, a VM reaches only the sockets of its own links: a request names a host and a port, never a socket, the proxy's list is in the VM's run folder, which no VM can write, and the proxy takes an entry only when its socket is the one devvm names for that VM's link at that address and port.
  • The VM can't choose where its connections go on the host. OpenSSH's client accepts a forwarded channel only for a listener it asked for, and connects it only where it chose, which is the link's socket. A channel the client's sshd opens for any other address or port, or of any other kind, is refused, whatever sshd root in the client runs. The forwarder's master asks for no remote forward, and the link session is a connection of its own, so links don't change what the ports note says.
  • Other users and VMs can't use a link. Its end on the host is a unix socket of yours, mode 600 in a folder of mode 700, so no other user on the host reaches it, and neither does a VM that reaches the host's loopback. Programs of yours on the host can connect to it, as they can already ssh into the target by the name devvm host shows.
  • A target's service isn't put on the host's localhost. -W reaches the target's loopback through its sshd, and the forwarder never forwards 127.77.0.0/16, so a link listens nowhere on the host.
  • Each VM's own ssh rules hold. Host keys are pinned, each VM has its own key, and no agent is forwarded (ForwardAgent=no, IdentityAgent=none), as for the forwarder. devvm takes a client's or a target's ssh only as its backend gives it on the host's loopback, 127.0.0.1, with a user and a key, and it refuses any other address, as the ssh config's entries do.

Why not a shared network, the proxy, or a host port:

  • A network shared between VMs would bypass the proxy and the VMs' confinement. On Lima it needs a root helper, and QEMU can't make one.
  • CONNECT through the proxy as the only way in would work only for programs that use the VM's proxy settings, and a raw TCP client in every VM would need a tool of devvm's to make the connection. The proxy is a second entrance instead, for HTTP clients, beside the ssh forward that carries every link on every VM.
  • The target's port forwarded to the host's localhost is refused by the proxy's floor, is reached by any open VM and any program on the host, and is a port that a host program can take first.

What the prototype showed. devvm's prototype ran in the e2e sandbox, and nothing needed the link feature off:

  • macOS's ssh 10.3p1 and Linux hosts' ssh 9.6p1 and 10.2p1 accept -R 127.77.x.y:PORT:<unix socket>, and -O forward and -O cancel work on a master started with ClearAllForwardings=yes. A cancel keeps open connections, ending the master drops them, and a session keeps the PermitListen it connected with.
  • sshd 9.2p1 (Debian 12, --from), 10.2p1 (Ubuntu 26.04) and 10.3p1 (Alpine), with GatewayPorts clientspecified and PermitListen naming one address, bind that address alone and refuse 0.0.0.0, 127.0.0.1, ::1, localhost, *, other ports and port 0. The glob 127.77.*:* works the same way and matches the requested address as text.
  • All of them honor ip_unprivileged_port_start, which is 0 by default on Lima's Ubuntu and Debian VMs, and 1024 on Lima's Alpine VMs.
  • SIGHUP keeps sessions and open connections under systemd and OpenRC. Lima's Ubuntu VMs (an sshd per connection over vsock) read the config at every connection. sshd's rule is written once, so links don't depend on either.
  • ssh -W through a kept master works over Lima's ssh, and a new master after the target restarts reads its rewritten known hosts, while Lima keeps its key. Without a master, -S connects on its own unless ProxyCommand=/usr/bin/false.
  • glibc 2.36 and 2.43 and musl 1.2.6 resolve /etc/hosts names in 127.77.0.0/16, and Go, Node 18, 22 and 24, curl, Python and libpq 15 and 18 reach db and db.devvm.internal. HTTP clients honor NO_PROXY with db,.devvm.internal, Node 22 needs the leading dot, and Node 18's fetch ignores proxies.
  • devvm's port forwarder put a link's listener on the host's 127.0.0.1 and ::1, which is why it skips 127.77.0.0/16.
  • The prototype didn't run confined VMs, so the end-to-end checks do.

What it relies on: OpenSSH's client accepting forwarded channels only for listeners it asked for, and connecting each one only where it chose. It also relies on -O forward and -O cancel changing one master's forwards, on ProxyCommand=/usr/bin/false keeping -S from connecting without its master, and on the host's unix socket permissions. The pinned host keys are the ones the forwarder and ssh rely on. Lima's rules must ignore every port ahead of its fallback rule, and devvm's state on the host must hold each link's target, ID and port. The proxy's entrance relies on devvm's run folder and the VM's being yours alone, and on the proxy checking each entry's socket against the one it names itself from the VM, the address and the port.

What could break it: an OpenSSH release whose client accepts a channel for a listener it didn't ask for, which the end-to-end checks would see as a host connection devvm didn't make. A Lima release that forwards a listener on a 127.77 address despite the rules would put a link on the host's loopback, which the forwarder's own skip doesn't cover, and the end-to-end checks look for it on the host. A backend that started a target for a connection would break the rule that a connection never starts a VM, but devvm never asks a backend to start one then.

Not covered:

  • What the client does through the target's service. A link joins the two VMs' trust, as above, and what a VM does through a link lists what that leaves open.
  • Programs of yours on the host can connect to a link's socket and the masters' control sockets, as they can already reach the VMs.
  • Open connections outlive an unpublished port. devvm link unpublish refuses the next connection, while those that are open stay until they close, the client stops or the target does, because the link itself stays. A link that goes, by devvm link rm, devvm rm of its target or a group's change, ends its open connections (above). A target can't get a tier lower than a client's that links to it, because devvm network refuses it then, so no open connection breaks the tier rule.
  • A program in the client can take a link's address and port first, and that link then fails with link_port_taken until the program lets it go. Root in the client can also edit its own /etc/hosts, which changes only what the client reaches.
  • A link name hides a name the client would otherwise resolve, such as db under its search domain. devvm refuses localhost, the client's own hostname, another link's name and anything that isn't one DNS label.
  • A remote forward you ask for into a VM, with ssh -R through devvm's ssh config, may bind an address in 127.77.0.0/16 in that VM, as remote forwards you add says. sshd matches the rule as text and then resolves what it matched, which is why a host name that begins with 127.77. binds whatever address it resolves to in the VM. devvm's own forwards name addresses only.
  • Many connections: a client can keep 256 connections busy, which refuses its own further connections and makes the host run that many ssh processes.
  • The network rules don't apply to links, through the proxy or not, so devvm network deny db doesn't stop the link db. The published ports and the policy rule between the two VMs decide a link's connections, and devvm link rm removes one.
  • A link's short name before its first session lists it. Until devvm _links has written a client's list once, the proxy doesn't know db is a link, so a request for db:5432 meets the rules, and a rule such as ** sends it to whatever the host's resolver finds for db as a full name, such as in /etc/hosts, never under its search domain, or a company proxy finds by that name. After that, the list stays until devvm removes the VM, and NAME.devvm.internal is never the rules'.
  • Linux hosts are untested.

Threat check (the security-audit skill, guidance mode, its local IPC, data isolation and resource exhaustion companions). One row per lead, with what holds it and the end-to-end check that proves it:

Lead What holds it End-to-end check
A compromised client attacking the target through a link Accepted, bounded by the rules: only a published port, only on the target's loopback, and a client only to a target on its own tier or a stricter one The link reaches the published port, while an unpublished port and a port that isn't linked are refused, and after devvm link unpublish the next connection is refused
A client reaching a target on a lower tier Refused when the link is made, at the client's launch, on every connection, and by devvm network giving the target a lower tier than the client's or the client a higher one than the target's. For a client on a confined tier, on every connection the target's tier must also be enforced as it runs, so a target given a confined tier while running, outside its proxy until its next start, or one whose self-check failed, is refused (unenforced) An allowlist client and an open target are refused by devvm link add, at launch, after devvm network open on the target, and by devvm network allowlist on an open client linked to such a target. A target given the allowlist tier while it runs, which devvm ls shows as unenforced, has the link's next connection refused and logged as unenforced, while its server runs, devvm link add and the client's launch warn of it, and once restarted behind its proxy it's reached again
Root in the client opening a channel to an address or port the host didn't ask for OpenSSH's client refuses it and connects only to the link's socket With the client's sshd loosened by root (below), no host listener or connection appears that devvm didn't make, and only the link's socket is reached
Root in the client loosening sshd (PermitListen any, GatewayPorts yes, a restart) The host asks only for its links' numeric 127.77 addresses, and what sshd binds in the client is the client's own: root can already put a relay of its own on any of its addresses. With GatewayPorts yes, sshd binds each forward on every address of the client instead, so a second link on the same port can't bind, and a client forwarding every port would forward it, as it would root's relay. Nothing on the host changes After root rewrites the client's sshd config and restarts it, the link session asks only for the links' addresses and the link still works, and with PermitListen any alone nothing listens on the client's 0.0.0.0, 127.0.0.1 or ::1 for it. With GatewayPorts yes too, the link session still listens on no host TCP port and connects only to the VMs' sshd, and the check prints what the client binds
A VM making its proxy reach a socket that isn't one of its own links, or another VM's link A request names a host and a port, never a path. The list is in the VM's run folder (mode 700), which no VM can write, at a path devvm gives the proxy in its config, and the proxy reads it only as a regular file, not a symbolic link, that only you can write. An entry counts only when its socket is the one devvm names for this VM's link at that address and port in devvm's run folder (proxy.LinkSocket), and each proxy needs its own VM's password The client's proxy refuses, by GET and by CONNECT, a name or port it hasn't linked, a published port it hasn't linked, NAME.devvm.internal.devvm.internal, devvm.internal and a link's 127.77 address, and none of them reaches a link, while its own link answers. The target, on the allowlist tier and with no links, gets a refusal from its own proxy for the client's link name. Unit tests (internal/proxy/links_test.go) refuse an entry naming another VM's socket, a socket outside the sockets' folder (one in the list's own folder among them) or another port's, no link without the sockets' folder, a list that's a symbolic link, writable by others, of another version or not JSON, and a host that is a socket's path
An HTTP client in a confined client reaching a link added while it runs The proxy reads the list for every request, before any rule, and NAME stays out of NO_PROXY A link added to the running client is reached at once by curl through the VM's proxy, by GET and by CONNECT, NO_PROXY holds only localhost,127.0.0.1,::1, and the client's boot, its init's start and its pinned host keys are the same after
The proxy changing a link's bytes, or putting a secret into them The link's path tunnels the bytes as they are, before the SNI check, interception and secrets None of its own end to end. Unit tests send a ClientHello for another host and a placeholder through a link whose name and port a secret's hosts and an allow rule match, and the socket gets them as they were sent, and an absolute-form request reaches it without Proxy-Authorization
An honest VM's sshd binding a link where it shouldn't PermitListen 127.77.*:* with GatewayPorts clientspecified, written once in every VM sshd -T in every VM shows the settings, and ssh -R from inside the client to 0.0.0.0, 127.0.0.1, ::1 or another range fails
Another user's program, or a VM, using a link A unix socket, mode 600, in a folder of mode 700, and no host TCP port The socket is mode 600 in a 700 folder, and no host TCP port carries the link
A link listener forwarded to the host's localhost The forwarder skips 127.77.0.0/16, and Lima's rules ignore every port With the client forwarding every port, nothing from a link listens on the host, while a server of the client's own on 127.0.0.1 with the same port is forwarded as usual (its control)
A link reached on the client's localhost Names only, numeric 127.77 addresses Nothing from a link listens on the client's 127.0.0.1 or ::1, and a server of the client's own there runs
A VM made again in the target's folder inheriting a link The target's ID, recorded with the link After devvm rm of the target, the client's link is gone and the client is named, and a VM made again in that folder isn't linked
Many connections At most 256 at once, then refused and logged (link_limit), and an accept loop that takes a burst whole before it starts any relay and goes on accepting while the burst is carried or refused, so the socket's backlog never refuses one unlogged 256 connections at once, past the socket's backlog of 128 on macOS, are all carried, and a 257th is refused and devvm network log shows link_limit
A target holding a relay open, so its ssh and one of the 256 stay after its link goes Each relay's own context, which the link's removal and its target master's replacement cancel, killing its ssh and freeing its slot A connection that a program in the client holds open, to a target's server that never closes one, has its relay's ssh on this machine end after devvm link rm. Unit tests check the same with an ssh stand-in that never exits, for a removed link, a replaced master and a link whose target changed, with no goroutine left under -race
A target filling the client's 256 relays while its links last, by never ending the channels of connections the client's programs have closed The relay's grace: its ssh is killed once the client's side has closed and the target has sent nothing for 30 seconds, or 30 seconds after the client can take nothing more. One target can still hold relays that the client's programs keep open, which the client chooses, so there's no cap for each target None end to end, as an honest target ends its channels. Unit tests check it with an ssh stand-in that never exits: a closed and a half-closed client's relay end after the grace, and one the stand-in keeps answering goes on
A program in the client taking a link's address first Each link's own -O forward, failing alone with link_port_taken A server on a link's address and port before the link is added: that link fails with link_port_taken, and another link of the client's works
A malicious target's answers As any server's: they reach only the connection that asked None of its own: the target's bytes go back over the same connection
Root in the client, or a malicious target, writing a line into the session's log that reads as the session's own, such as a false link_port_taken or a hidden real one OpenSSH prints what the remote side sends, such as a disconnect's reason, with its newlines, at the LogLevel=ERROR the session's ssh uses. So devvm _links writes its ssh processes' output to its log a whole line at a time, each line behind ssh:, so only the session's own lines start with its prefix, which devvm link add and the launch read. A line in an error the session logs is indented, and the output of ssh -O is joined into one line None of its own. A unit test (internal/vmssh/links_test.go) runs a stub ssh that prints a disconnect's reason holding forged lines, one of them in pieces around a line of the session's, and the log holds only the session's own lines
A connection starting a stopped target Never: devvm _links checks the target runs and never starts it A connection to a stopped target fails, devvm network log shows link_target_stopped, and the target stays stopped. Restarted, it works again with its new host key
Lima's own ssh asking for remote forwards, as every VM's sshd allows them Lima's own ssh never asks for one, because devvm sets no reverse rule and its Lima home refuses settings it didn't write. Every VM's sshd allows remote forwards only on 127.77.*:*, so no other address binds, and on macOS a confined VM also has the hostagent's sandbox Lima's rules ignore every port, sshd -T shows permitlisten 127.77.*:*, and on a running Lima client, sshd listens on nothing but its own port and the link's addresses
A link name shadowing a real host One DNS label, never localhost, the client's hostname or another link's, plus NAME.devvm.internal under a reserved name The CLI tests refuse each, and end to end, --as NAME reaches the target by that name alone
Links changing on a running client -O forward and -O cancel, the setup over ssh, and the proxy's list devvm link add and devvm link rm on a running client apply within seconds, through the proxy too, without a restart
Two targets on one port An address per target Two targets publishing the same port are each reached by their own name
A link left behind devvm stop and devvm rm end the process and its sockets, and gc --orphans finds leftovers Removing either VM leaves no devvm _links process, socket or link state
Links on open and confined tiers The same mechanism on every tier The section runs with both VMs on the allowlist tier and both open, a port below 1024 such as 80 on Lima's Alpine VMs, and devvm network log shows link events on both tiers

Groups

A group is a named set of VMs that reach each other's published ports by name: you run devvm group join web in each VM's folder, and every member gets a link to each port that every other member publishes. Groups are built on links alone. A group adds nothing below the link session, so every connection of a group's link goes through the same session, sockets, proxy entrance and checks as a link made with devvm link add, and everything above holds for it.

The rules:

  • A VM is in one group at a time. devvm group join refuses a VM that's in another group (group_other), naming devvm group leave, and devvm group leave takes no name.
  • One tier. Every member of a group is on the same tier. devvm group join refuses a VM whose tier differs from the members' (group_tier_mismatch), and a group with a member whose network section can't be read, and devvm network is refused for a member (group_tier_fixed), naming the group and devvm group leave. So every link a group makes keeps the links' tier rule, and each of its connections is still checked against the states, with the target's tier enforced as it runs, and warned of with link_target_unenforced when the group makes the link.
  • Membership is recorded on the host, in each member's own state under ~/.local/share/devvm, as group and group_as in its links section, never in a project folder or a VM. A VM made again after devvm rm gets new state with a new ID, so it's in no group, and the links to the old VM, which record its ID, don't apply to it. devvm layer add, devvm layer rm and devvm update keep the VM's state, so the VM stays in its group (a VM made again).
  • A group's links are links, recorded in each member's links state with a mark of their own, so devvm group leave removes only those, and devvm link rm refuses them (link_from_group) while they still apply. Every connection of one is also checked against membership: a group's link applies only while its client and its target are in the same group (ungrouped otherwise), so a link that a leave cut short, or a race between two devvm commands, left behind carries nothing, and devvm link rm removes it. devvm group leave removes the leaver's own group links before it takes it out of the group, and running devvm group join again works out every member's links again. Each takes the client's address for that member and the member's name in the group: its folder part, or the name it joined with (--as NAME). devvm works out a member's group links again whenever a member joins or leaves, publishes or unpublishes a port, or adds or removes a link of its own, and it records and applies only the members whose links changed, naming the links each gains or loses (group_links_added, group_links_removed). A running member gets them at once, as devvm link add gives them, and a stopped one at its next start.
  • The user's links take precedence. A link made with devvm link add stays as it is: a port it links gets no group link, its name names that member's group links too, and when its name is another member's name in the group, that member's group links aren't made in that client, which is warned of (group_link_name_clash).
  • Names are unique in a group. devvm group join refuses a name another member has, as its name or its folder part (group_name_taken), and localhost (group_name_host). It also refuses a VM whose own hostname, its folder part, is another member's name, whether that's the member's folder part or the name it joined with (group_name_hostname), because the name would resolve to the joining VM itself, whatever name it joins as. The refusal names the fix: the other member leaves and joins again with another name, or the project goes in a folder with another name. So no member's name is another member's hostname, and groupLinks makes no link by such a name, or by localhost, all the same.
  • Joins take turns. Each devvm group join and devvm group leave, each publish and unpublish that works the members' links out again, and devvm rm of a VM hold a lock on the host, ~/.local/share/devvm/groups.lock (lockGroups), from reading the members' states to writing them. A join checks the group once before it asks to widen a parent folder's VM, and again once it holds the lock, with the VM's state read again, so two VMs joining at once are checked one after the other, and the second sees the first as a member. So the one tier and the names hold however the joins overlap. A devvm that waits for the lock does so under a status line (group_waiting). The lock is an OS lock (flock) on an open file, which the system lets go of when the process holding it ends, however it ends.
  • devvm rm of a member takes it out of its group, after devvm rm's removal of every link to it, and the group goes with its last member.

What a group adds to the link threat check. A group joins the trust of every member: code in any member can often run code in the others through the ports they publish, and then has their network, secrets and project folder. A member joining later gets that reach into every member, and they into it, without a command in their folders, so devvm group join says so on every join (group_trust). Nothing reaches more than the published ports on each member's own loopback, and the one tier keeps every member's tier whole.

Not covered:

  • Every member trusts every other, which what a VM does through a link lists.
  • A published range gives a link for each port in it, in every other member. A wide range means as many forwards in each member and as many sockets on the host, so publish only the ports you mean the group to reach.
  • devvm link add or devvm link rm at the same moment as a group's change can each write the same member's links whole, because those two don't take the groups lock, so the later write wins. A group link left that way is refused as ungrouped, and the next change works the links out again from the states.

Threat check (the security-audit skill, guidance mode, its local IPC, data isolation and resource exhaustion companions), what a group adds to the links' rows above:

Lead What holds it End-to-end check
A member reaching every other member's published ports Accepted, bounded by the links' rules: only published ports, only on each member's loopback, and said on every join (group_trust) Three members reach each other's published ports by name within seconds of the last join, and a port published by a member reaches the others at once
A member joining later It needs devvm group join in its own folder, on the host; membership is in each member's state on the host, which no VM writes. Every join says the group joins every member's trust The third VM's join gives the other two links to its published port and it links to theirs, and group_trust is said
A member reaching one on a lower tier One tier at devvm group join, checked again under the groups lock, devvm network refused for a member, and every connection checked as for any link An allowlist VM is refused by an open group, and an open one by an allowlist group; devvm network allowlist for a member is refused. Unit tests (TestGroupJoinsAtOnce) and the CLI tests join an allowlist VM and an open one at once, and only one gets in, every time
A member's name taking over a name the user chose The user's links take precedence, a name is unique in the group, localhost is refused, and so is a VM whose own hostname is a member's name The CLI tests refuse a taken name, another member's folder part, localhost, and a VM whose folder part is a member's folder part or the name it joined with, and drop a member's group links whose name one of the user's links has
Leaving or removing a member leaving links behind devvm group leave and devvm rm remove the group's links in every member, and the user's stay After devvm group leave, the leaver's and the others' group links are gone and their names don't resolve, while a link made with devvm link add still answers
A group's link outliving its group, from a leave cut short or a race Each connection checks that the client and the target are in the same group (ungrouped), and a leave removes the leaver's group links first Unit tests (TestCheckGroupLink) refuse a group's link once either VM is in another group or none, and keep the user's own
A VM made again inheriting membership Membership is in the VM's own state, which devvm rm deletes, so a VM made after it starts in no group. devvm layer add, devvm layer rm and devvm update keep the state, because they make the same VM again (below) The CLI tests: devvm rm of a member takes it out, and the last one's leaving removes the group

Read-only paths on Linux

macOS locks .git's hooks and config with the user-immutable flag, which Linux has only for root, so on Linux devvm makes them read-only where the VM sees them instead (.git protection on Linux hosts). Lima's read-only-paths feature is native: QEMU serves the project folder over 9p from its own mount namespace, and devvm binds each path over itself there. Landlock, a FUSE layer and a 9p server of devvm's own were ruled out: Landlock can't make paths read-only below a folder it allows writes in, and the other two would put devvm's code between the VM and every file of the project.

The guarantee: while a VM whose protection is on runs, nothing in it, root included, can write, replace, remove or rename .git's hooks, config and the rest of what's locked, of .git and of the submodules the check before its start found, or rename .git and those git folders. git in the VM commits as before. Nothing changes for this machine's own git, and nothing persists once QEMU ends. Where the host can't do it, the start is refused, or, for a VM made there, protection is off and devvm says so at each launch. devvm reports a VM that's on and runs without its pins, at each launch of it and at devvm stop. One gap is listed, not closed: a file that a git command on this machine renames over a pinned one while the VM runs is the guest's until it's pinned again, and devvm names it afterwards.

What could break it: a path that's a symlink, or under one, which mount(2) would follow out of the project folder; a file with another name; a host whose kernel refuses the namespace's capabilities; a pinned file that a git command on this machine replaces while the VM runs; QEMU, or a process it starts, undoing a pin; what keeps the pins ending while QEMU runs; a pin reaching this machine's own mounts; a VM started without devvm's wrapper.

Threat check (the security-audit skill, guidance mode, its local IPC companion's privileged-helper and local-file classes). Leads, each ruled out, fixed or listed:

  • A symlink at a pinned path, or above one: ruled out. The check that lists the paths skips any that isn't real (realInDir), and devvm _qemu pinned opens each path with openat2 beneath the project folder with RESOLVE_NO_SYMLINKS, refuses anything but a file or a folder, and binds the descriptor it opened, never the path. A refused path stops the start (TestRunPinned's symlinked hooks folder). The VM isn't running while QEMU's namespace pins, so only this machine's own programs could race the check.
  • The guest undoing a pin: ruled out. The guest has no way into QEMU's mount namespace, and 9p carries file operations, not mounts. A rename or removal of a mount point gets EBUSY, and a write EROFS (TestRunPinned; e2e).
  • QEMU undoing a pin: ruled out for QEMU as it runs. It runs as you, with no capability in any namespace (CapInh, CapPrm, CapEff and CapAmb 0; its bounding set stays whole, which gives nothing with no new privileges) and no-new-privileges, and the pins belong to the namespace devvm made, where only CAP_SYS_ADMIN could unmount them. Listed: a guest that breaks out of QEMU runs as you, and can reach .git through a process outside the namespace (/proc/<pid>/root), as it can every file of yours.
  • devvm _qemu pinned, which keeps CAP_SYS_ADMIN in the namespace: ruled out as a way in. It reads only DEVVM_QEMU_PINS, which devvm gives it, binds only those paths with the same checks, and ends with QEMU. The guest can make it work by filling .git with files, but each burst of changes makes one look at the pins.
  • What keeps the pins ending while QEMU runs: fixed. A separate keeper could end (an inotify limit, a misread parent) with QEMU running on, so devvm _qemu pinned runs QEMU as its child, killed when it ends, and a watch it can't set up on any of the folders refuses the start.
  • A change to a pin that goes unrecorded: fixed. devvm _qemu pinned refuses the start when it can't write the events file's first line. An event it can't add later goes to Lima's log with a warning, and to the file as a mark when it can, and the check names a record that's unreadable, holds a mark or a line that isn't an event, or lost its first line (git_pins_unrecorded). A file it can't write at all after the start stays listed, with Lima's log as its record.
  • A git command on this machine replacing .git/config: listed, and reported. The new file isn't pinned until devvm _qemu pinned pins it again, within milliseconds of the change, and in that window the guest can write it, put a file of its own in its place, which then gets the pin, open it for writing, a handle the pin doesn't take back, or give it another name. A guest that loops can win that window. Each pin made again, or that can't be, is recorded and named once the VM stops, and the watch's sums, which run on Linux with the pins too, name a file whose contents changed. macOS's flag has no such window.
  • A file with another name (a hard link): fixed. A bind covers one name, and the guest could write the file through another, so a regular file to pin, or one in a folder to pin, with more than one name is refused at the start (git_pin_linked), and one that gets another name while the VM runs isn't pinned again and is named.
  • A VM that's on running without its pins: fixed, reported. Each launch of a running VM and devvm stop read QEMU's mounts and name each pin it lacks, .git and the git folders as mount points and the rest read-only (git_pins_missing).
  • A pin reaching this machine's mounts: ruled out. The namespace's mounts are private, and a mount namespace owned by a user namespace gets none of its pins back to its parent's (checked on Fedora: this machine's mountinfo has none of them while the VM runs).
  • What's pinned, from the guest's index: ruled out. The VM writes the index, so it can add submodules, but devvm pins only real git folders inside the project folder (hostsafety.IsGitDir), so the worst it can do is make a folder of its own project read-only to itself.
  • DEVVM_QEMU_PINS: ruled out. devvm sets it for the start alone, _qemu checks that the folder is absolute and clean and that every path is relative and below it, and devvm takes it out of QEMU's environment.
  • An AppArmor profile for Ubuntu: ruled out for now. A profile with the userns rule for devvm's binary, in a folder you can write, would let any program running as you put itself there and get what Ubuntu's restriction holds back, so devvm offers none, and Ubuntu with the restriction on only watches .git.
  • .git/commondir: listed. A file has to be there to be pinned, and devvm puts nothing in .git that git doesn't, so the VM can still make one, which devvm reports at each check, as on macOS.
  • A VM started without devvm: reported. limactl start runs QEMU without devvm's wrapper, so without pins, as it runs without the network confinement (unenforced in devvm ls), and the next launch or devvm stop names its missing pins. Start VMs with devvm.
  • Files owned by another user: listed. QEMU's namespace maps only you, so a file in the project folder that another user owns shows as nobody's in the VM.

End-to-end checks (tests/e2e, the project section on a Linux host, run on Fedora 43 and Debian 13): QEMU runs in a namespace with .git/config and .git/hooks mounted read-only, with no capability and no-new-privileges; root in the VM can't add a hook, change, replace or remove the config, rename .git or move the hooks folder; git in the VM commits; git config on this machine reaches the VM, and the new config is read-only in the VM again; a submodule the VM adds is named by devvm stop, nothing of the namespace outlives the stop, and the next start pins the submodule's config but not a folder that isn't a git folder; devvm git-protect off on a running VM applies at its next start, which pins nothing; a VM left strict is on at its next launch, its diff.ignoreSubmodules = all taken out, and pinned again, and its next stop names nothing. Unit tests: TestRunPinned (a file renamed over a pinned one is pinned again and recorded; a hard link refuses the start), TestPinsInNamespace, TestKeep and TestProbePin on a Linux host, TestPinsOrder, TestPinsRefused, TestStartPins, TestPins, TestBindsWatch, TestReportPinEvents (a path's repeats in one line, each record it can't trust named), TestRecordPinEvent, TestPinWaits (a folder it can't watch fails the watch) and TestPinsMissing (.git not a mount point, a config not read-only).

Nested repos

A folder often holds git repos of its own besides its submodules, such as a workspace of several repos with no repo at its top. Every one of them is in the VM's mount, so .git protection covers each as it covers the folder's own repo (nested repos). Two other designs were weighed. Refusing such folders, or warning only, leaves the most common multi-repo layout without protection. A --clone of every repo keeps the VM out of the working trees altogether, which is what a workspace clone does for a user who doesn't need the VM to write them, so both are built.

The guarantee: in a VM made by this devvm, or one devvm git-protect on set, nothing in the VM can change the hooks and config of a nested repo that a walk of the stopped VM's folder found, with the same locks, pins and watch as the folder's own repo, and with the same reports at each check. It holds from the check that found the repo: a repo the VM makes while it runs, or a folder of its own the VM puts in a protected repo's place on Linux, is git's to use on this machine until the next stopped check names it, and what the walk can't find or the bound leaves out is named, or counted, not protected. A VM an earlier devvm made keeps protecting only its own repo until devvm git-protect on, because locking a repo's config breaks git config there, which the user didn't ask for. It's told once.

What could break it: the walk finding the wrong folders or too many; a lock or a read outside the mount through a nested repo's paths, which now have two bounds, the repo's top folder and the mount; the VM hiding a nested repo behind another one's protection; two VMs protecting one repo, where one's unlock would take the other's locks off; taking a strict VM's diff.ignoreSubmodules out, which unlocks a config to write it; and the cost of a check, which the VM can raise by making repos.

Threat check (the security-audit skill, guidance mode, its local IPC companion's local-file and race classes, with two independent reviews of the change, the second adversarial, which proved its two highs with real host git running a VM-planted core.fsmonitor). Leads, each fixed, ruled out or listed:

  • A nested repo hidden behind another's protection: fixed. The first version left a nested repo to any repo whose scan locked its git folder as a submodule's, and the VM writes the index that names submodules, so a gitlink with a .git file naming b/.git hid b's own submodules and worktrees from every scan (TestNestedGitlinkCantHide). The second left one to any repo whose .git its git folder was below, so a src/.git file naming a .git/evil the VM made, or a .git/modules/x whose commondir leads to one, was neither locked nor named. A repo is now left to another only when its git folder is one that repo's scan locks whole: its .git, a git folder under .git/modules that reads its own config, or a linked worktree whose commondir leads back. Anything else is scanned on its own and named (TestNestedIntoTopGit).
  • A protected nested repo made to look gone: fixed. devvm took a folder for a repo by a narrower test than git's, which also takes a HEAD with a commondir, and objects and refs that are files, so the VM could rename a protected repo's objects and refs, add a commondir to a git folder of its own, or rename .git to .GIT on macOS, or make it unreadable, and devvm dropped the repo as gone while git still used it, its pins and watch with it. The walk now takes anything named .git, any case on macOS, hostsafety.IsGitDir follows git's test, and a recorded repo stays while anything is at its .git (TestNestedNotGone, TestIsGitDir). git_nested_gone is a warning.
  • A bare repo the VM makes: listed, named. git takes a folder shaped like a git folder for a bare repo, and its config can name a work tree, so git run below one runs its core.fsmonitor. devvm names the ones it finds, and devvm doctor gives a tip until git's safe.bareRepository is explicit (git 2.38 and newer), which refuses them; devvm never changes your git config.
  • A path outside the mount: ruled out. Every lock, unlock and pin goes through realInDir, which takes the mount as its bound and refuses a path with a symlink in it below the mount, so a nested repo whose folder became a symlink is reported, not locked (TestLockNeverThroughSymlinks, TestRealInDirPins). The walk follows no symlink and stays on the mount's file system. The state records nested repos by local relative paths only.
  • Two VMs, one repo: fixed. On macOS both VMs set the same flag, so an unlock leaves what another VM's protection still covers, and names that VM (TestNestedUnlockKept, the git_nested script's nested VM). Unlocking a kept config for a moment, to take a strict VM's diff.ignoreSubmodules out, would let a running VM race it, so devvm skips a kept config there, and locks a config again when git can't change it (TestUnstrictKept, TestUnstrictFails). The ownership check fails closed: a state that can't be read keeps every path in the folder its state's folder is named after, and a VMs' folder that can't be read keeps everything (TestGitKeeper). Locking and recording, and unlocking, take one host lock (paths.Dirs.GitLock), so two commands at once can't unlock what the other just locked. A repo devvm stops protecting keeps its record in made.left, so its locks come off with the rest, and one that left the folder is named, as only chflags reaches it then (TestNestedLeftUnlocked).
  • A repo whose git folder is outside the folder: named. Its .git file is locked, and the VM can't reach where it leads, but another project's VM may write it, as for a submodule's (git_nested_gitdir_outside).
  • The watch hiding a change: fixed. The watch records a new or gone nested repo's sums without naming them, and it first skipped every path under such a repo's folder, so a repo nested in it went unwatched for a check. It now skips only the paths whose deepest repo is that one (TestRepoOf).
  • The bound used to hide a repo: fixed. The VM can make up to 100 repos cheaply, and the walk keeps the first 100, so the count past the bound is now named at every check, with the first ten of them, not only when it grows, as the VM could keep the count and change which repos are past it. The .git the walk sees where it doesn't look for repos, which a set-id walk on Linux sees, and the folders on other disks it doesn't enter, are counted and named.
  • Cost: fixed, and listed. A scan followed gitlinks that led back to a git folder it had followed, through a symlinked folder, up to eight deep, so the VM could make it run git without end; it now follows each git folder once, and one check's scans follow 1,000 in all, across every repo, and name a repo past that (TestEmbeddedOnce, TestScanBudget). A launch into a running VM scans no nested repo, so it costs what it did before them. A check scans eight repos at once, so 50 nested repos take under a second on an M3 Max, walk and locks included (BenchmarkNestedCheck). Listed: the watch's bounds grow with the repos, at most 2,000 sums for the folder's own repo and 200 for each nested one, each file read up to 16 MiB, so a VM that fills them makes a stopped check slow; a hooks folder filled to blind the watch is named at every check (git_watch_blind).
  • A nested repo's folder renamed on Linux: listed, reported. A pin makes .git a mount point, which the guest can't rename, but a nested repo's own folder isn't one, so the guest can rename ws/a, .git and all, and put another repo in its place, which git on this machine then reads until the next check names it (git_replaced). Pinning every folder down to each nested repo would refuse the VM's own moves of those folders. macOS has the same gap for every repo, the folder's own included.
  • A repo the VM makes while it runs: listed, reported. devvm can't lock what it hasn't found, so a repo the VM clones while it runs is git's repo for its folder from then on, shell prompts and editors included, and the VM's until the next stopped check names it, with the config keys and hooks in it that run programs (git_nested_appeared_runs), and locks it as it is. One deeper than four folders or under a skipped name is never named, only counted where a set-id walk sees it.
  • The pins' file: ruled out. A VM with many nested repos has more pins than one environment variable holds (MAX_ARG_STRLEN is 128 KiB), so the start writes them to run/git-pins.json in the VM's folder, private and whole, which the VM can't reach, and devvm _qemu reads it through no symlink, capped, and checks it again (TestPinsOrder, TestPinsRefused). The keeper's inotify watches are a few folders for each repo, far below the kernel's limit for 100 repos.

End-to-end checks (tests/e2e, the project section): a folder of two repos without one of its own gets a VM whose root can't add a hook or change the config of either repo, on macOS and on a Linux host that pins; on a Linux host that can't pin, devvm stop names the config the VM changed; devvm rm takes the locks off both; a repo whose .git file names a git folder the VM made under the folder's own .git is named at devvm stop; and a protected repo whose objects and refs the VM renamed, with a commondir to a git folder of its own, or whose .git it renamed to .GIT on macOS, stays protected. Unit tests: TestWalkRepos, TestIsGitDir, TestNestedIntoTopGit, TestNestedNotGone, TestScanBudget, TestRunsProgram, TestNestedLeftUnlocked, TestGitKeeper, TestBareExplicit, TestNestedProtected, TestNestedNoTopRepo, TestNestedExistingVM, TestNestedWatch, TestNestedPins, TestNestedGitdirInside, TestKeeps, TestMadeJSON and the 0.1.0 fixture's tests, whose state reads as a VM whose protection covers its own repo alone.

Workspace clones

devvm --clone in a folder of repos gives one VM a clone of each repo the user picks, each at its own path, so the paths between them work as on the host (folders of repos). It extends the one-repo clone rather than adding a mode beside it: the clone section's repos lists the repos by their paths relative to the folder, and a clone of the folder's own repo, the only kind devvm 0.1.0 made, reads as one repo at . with its remote and seed in made, so its state needs no migration. Every step that a one-repo clone takes for its repo, a workspace clone takes for each: the checks of --clone (checkRepoTop, cloneSource, gitprotect.OwnRepo), a remote of its own (freeRemote), a copy of its branches through the VM's own command channel to that repo's path (the copy into a clone VM), and at devvm rm or devvm clone off, the check of its work and the removal of its remote. The repos are found by the walk that .git protection makes (starter.walk), so the same depth, skipped folders and bound apply, and they're recorded once, when the VM is made or at devvm clone add, never at a launch.

Four choices keep it small. The seed copies each repo's refs as a one-repo clone's seed does, every branch, tag and remote-tracking branch, so a workspace repo behaves in the VM as a repo of its own does; the seed sends one pack for each repo, so this costs about what a clone of the repo does. A repo --clone can't copy is listed and left out, never fatal, so one odd repo doesn't stop the rest; the same holds for a repo whose three remote names are taken. The folder's own files outside every repo are copied once and never back, as a tar the host makes from what it reads beneath the folder, so a Makefile or a compose file works in the VM without becoming a sync. And devvm in one of the repos opens the folder's VM at that repo's path, because the VM has the repo there and mounts nothing of the host, so the finder's reason to pass over a parent's VM below a repo of its own, that the parent's VM can write that repo, doesn't hold; --here still makes the repo's own VM.

rm's check reads every repo at once: one script sent with the command (cloneState, never a copy on disk) prints each repo's branches, its status and its linked worktrees below the folder with their statuses, as length-prefixed records, so ten repos cost one ssh session, not thirty. devvm reads it as it reads anything from a VM, capped, by a parser that takes only what it asked for.

The guarantee: a workspace clone's VM gets nothing of the host but the branches the user's repos already have, the files outside them that devvm copied once, and the shared tools and agent folders every VM gets. Nothing from the VM runs on the host, changes a ref outside a repo's remote-tracking branches for the VM, or writes outside those repos' .git. Everything the VM says, its branch names, paths and statuses, is untrusted, checked before it's used and made printable before it's shown.

What could break it: a host file outside the folder reaching the VM through the copy, by a link, a hard link, a swap during the read or a special file; host git run in a folder the state names, or by what the VM serves; refs written outside refs/remotes/<remote>/; the clone check's answer read without a bound, or a path in it that leads out of the folder; the finder taking a VM that mounts the folder for one that doesn't.

Threat check (the security-audit skill, guidance mode, its local IPC companion's local-file class, and two independent adversarial reviews of the change, "the review" and "the second review" below). Leads, each fixed, ruled out or listed:

  • A host file through the copy: fixed. devvm first walked the folder by paths beneath an os.Root, which follows a link in the middle of a path while it stays in the root, so another VM that mounts a subfolder could swap a folder there for a link to an unchosen repo, or its .git, as the walk reached it, and the copy took that repo's files and config (the adversarial review). The walk now opens each folder from its parent's handle and checks it's the folder it listed (safefile.Root.OpenDir, TestOpenDir), and opens each file by its own name in its folder, without following a link at its end, checked to be a regular file once open, and refused when it has another hard link, which could be any file on its disk (OneLink). A folder shaped like a git dir, such as a bare mirror, was copied as plain files, which the review found too; it's now left out and counted. A link is copied as a link only when its target is relative and stays in the folder, never read through. Other disks, sockets, FIFOs and devices stay on the host, and files keep their permissions without set-id bits (TestWorkspaceFiles). A workspace clone copies the folder's files, so devvm refuses the folders it refuses to mount, such as the home folder (checkUnsafe). Listed: a secret the user keeps at the folder's top, such as an .env, is copied as any file is, which the docs say.
  • Host git in a folder the VM chose: fixed. Host git runs only in the repos devvm's state records, which only devvm writes, each at a clean path below the folder, and repos passes over any other. The review found that only the seed checked a recorded repo again, so once another VM, or the user, removed a repo's .git or put another folder in its place, devvm clone fetch and rm's fetch wrote the VM's objects and refs into whichever repo git found there, the folder's own above it included. Every fetch into a repo, and devvm clone off's undo adding its remote again, now checks first that the folder is still the top of a repo of its own (checkRepoTop): devvm clone fetch leaves it alone and names it, and rm and devvm clone off refuse and keep the VM (the clone_workspace script). Every host git command goes through hostgit, so no hook, fsmonitor, filter or GIT_* of the environment runs, and the push and fetch connect to the VM alone, whatever the repo's config says (gitSSHCommand).
  • Refs from the VM: ruled out. devvm clone fetch fetches with --refmap= and one refspec, +refs/heads/*:refs/remotes/<remote>/*, so the VM's branches land only under that repo's remote for the VM, whose name devvm chose, and host git refuses a ref name it can't take. rm's fetch writes new saved/ branches only, never over one (savedPrefix). The names devvm lists are host git's, read back, and shown through msg.Printable.
  • The clone check's answer: ruled out. devvm reads at most 8 MiB, and fails the check past that or after 2 minutes; each record must be whole, of a repo asked for, and each worktree's path clean, relative and below the folder, once, followed by its status (TestParseCloneState, TestWorktreePathPins). A VM that hides its work only loses its own work, which the docs say: devvm checks what the VM answers, not that it answers everything. A repo whose clone isn't at its path in the VM first read as having nothing to check, so a clone moved in the VM went with its work without a question (the review); it's now asked about, as uncommitted changes are (TestCloneChangesAcrossRepos).
  • The finder's carve-out: ruled out. It applies only to a state whose clone section is on and a workspace, which never mounts the folder; a VM made again with the folder mounted clears that section first (TestCoversRepo, the clone_workspace script).
  • A repo another VM can swap: fixed. A VM that mounts a subfolder holding a workspace repo, or the repo itself, can swap it for a link to another repo between devvm's check and its push or fetch, which would send another repo's history into the clone VM, or write the clone's refs into another repo (the second review). devvm now refuses such a repo when it finds the repos, at devvm clone add and before each push and fetch, and rm's check runs no host git in it, naming the VM (finder.mountsRepo, stillRepo, the clone_workspace_repo script); the check and git still race for a VM that mounts it only later, which the next command names.
  • A repo with worktrees or repos of its own: fixed. The second review found that a repo holding a linked worktree, as the docs' .worktrees/NAME layout makes, or a repo below it, became a workspace: --no-input scripts that 0.1.0 ran now refused, the worktree was copied as a repo of its own, recording a remote in the config it shares with its repo, and the folder's own clone showed the other clones as untracked, so rm always asked. A folder that's a repo gets its own clone unless --repos is given, a linked worktree of a repo in the folder is never a repo of its own (worktreeIn), each repo's remote is chosen once the one before is added, and the folder's own clone excludes the other clones and what the host's info/exclude names (repoExcludes, TestFindRepos, TestRepoExcludes, the clone_workspace_repo script). A folder of repos inside another repo's working tree is refused, as its copy would take that repo's files.
  • Work lost to a copy that didn't finish: fixed. devvm clone add records a repo before its copy, and a failed copy left it recorded and unseeded, which the command then called added, and rm passed over, so a push that reached the VM without its record went unchecked. A recorded, unseeded repo is now copied again by devvm clone add, fetched when its remote is recorded, and checked by rm when its clone is in the VM (the clone_workspace script's failed add, then its retry).
  • The verification pass: fixed. devvm clone add . gave the folder's own clone no excludes, so it showed the other clones as changes and rm always asked; it now gets every other repo's and the host's. A linked worktree whose repo another VM mounts wasn't refused; devvm now checks the repo its common dir is in too (mountingVM). Exclude lines took a repo's folder name as a pattern, so lib[2] wasn't left out, and a name with a line break could write a line that left out every new folder, hiding work from rm; git's pattern characters are now escaped, each line is anchored at both ends, and a repo whose name has a character msg.Safe refuses, a line break among them, is refused (TestRepoExcludes runs real git on them). A repo another VM mounts failed rm for the whole workspace; rm now reads its clone in the VM, checks every other repo, and asks before its work goes, never running host git in it. The VM's folder never made failed the check; it now reads as every repo gone. Each repo is checked again after rm's question, before its fetch. A retry whose push had landed sent it again, which the VM refused once its branch moved on; a repo the VM has with a commit is now left as it is, and only its remote added. The branches' bound of 10,000 is for all the repos of a check together.
  • A worktree hidden by the bound: fixed. The clone check's script counted the worktrees outside the folder towards its 101 before leaving them out, so 101 outside ones hid a changed one inside, and rm deleted without asking, for a one-repo clone too; it counts only those inside now (TestCloneStateScript). The repos' branches are capped at 10,000 in all per check, as each costs host git a lookup.
  • Cost: listed. The walk is .git protection's, bounded at 100 repos; the copy at 5,000 entries and 64 MiB, each file at 10 MiB. A VM can serve a pack without end, or many branches, which devvm clone fetch writes into the repo until the disk is full or the user presses Ctrl+C, as git fetch devvm would; a cap on what host git reads from the VM's ssh isn't built. The read of the clone, by rm and devvm clone off, shares the bounds of the read of the agents' worktrees (answer). devvm stops the VM's command past 8 MiB and gives up past 2 minutes, so when a VM writes without end, slowly or not, or never answers, the check fails and devvm keeps the VM, and --no-clone-check is the way out (TestWorkCheckBounded).

End-to-end checks (tests/e2e, the clone section): a folder of two repos and a file of its own gets one VM that mounts only the shared tools, with each repo's clone at its path holding every branch and the folder's file; an agent-like commit in each repo comes back with devvm clone fetch, listed as one branch with both repos; devvm clone add copies a third; rm without a terminal refuses with unfetched work in one repo, naming it, and keeps the VM; --no-clone-check deletes it and removes every repo's remote. Unit tests: TestDefaultBranch, TestSeedTips, TestIsWorkspace, TestChooseRepos, TestPickRepos, TestFindRepos, TestWorkspaceFiles, TestCloneChangesAcrossRepos, TestFetchedByBranch, TestCloneRepos, TestFixtureClonesReadAsOneRepo, TestCoversRepo, TestParseCloneState, TestCloneStateScript, TestOpenDir and TestRepoExcludes.

A VM made again

devvm layer add and devvm layer rm make a VM again from a new image, and devvm update from its own image's new build, while keeping devvm's state for it and its home folder (making a VM again). All three use the one remake, and three choices shape it.

Option B, a new disk. The layer's script never runs in the existing VM. Running it there would run a third-party installer next to the project's files, as root, on a disk the VM's own code has changed, and the image's key would then describe a disk that no longer matches it. A new disk from the image keeps every VM a copy of an image whose key hashes everything in it. Taking a layer out works the same way, because a layer has no script that undoes it, and only a new disk from an image without the layer leaves nothing of it behind.

The old disk is kept until the new VM has started. devvm stops the VM and renames its machine to devvm-<hash>-old (backend.Backend's Rename, limactl rename on Lima, which keeps the disk whole) before it makes the new one by the VM's name, rather than deleting it first. So a failed create, start or home copy puts the old VM back as it was, and only a remake that got its new VM started with its home folder deletes the old disk. Every backend renames a stopped VM, so none deletes the old disk early. The aside name is no project VM's name (vmname.IsVM), which keeps it out of devvm ls, the ssh config, the mounts devvm's SSH agent checks and devvm space's strays. It's 24 characters for every VM, two more than the shortest name a project VM can have, so in a Lima home whose path leaves room for fewer, the rename is refused (lima_home_too_long) before anything else changes, and the VM stays as it was, stopped.

The VM keeps its ID. A link records its target's id so that a different VM in the target's folder, made after devvm rm, never inherits the link (links between VMs). A remake isn't that case. The user runs it in the folder, on the host, and it keeps the VM's name, its state, its folder and its project, so its links, its group and its published ports are the user's choices for this project, and none of them is worth losing to a layer. A new ID would make every client's link to the VM replaced, and the user would have to add each again in every client's folder, which gives nothing a check needs: the clients reach the same project's published ports, on a VM the same person made again from an image devvm built. What changes is the VM's disk and its host keys. devvm reads the new host keys from the new disk's system files, which the home folder's copy never reaches, as for any VM that starts, and a link session's master to the target ends when the target stops, so the next one reads the new keys. A remake of a confined VM keeps it, with the same proxy password and salt, so the links' policy rule holds throughout.

The home folder's copy

The old VM's home folder is the VM's own data, which nothing on the host trusts. devvm runs tar --one-file-system --ignore-failed-read in the old VM as its user, so the stream holds nothing from a mount, such as the project folder or an agent's folder, and devvm reads it on the host with Go's archive/tar and compress/gzip (copyHome). Nothing unpacks it on the host. Each entry is kept or dropped there, and only what's kept is written, gzipped again, to home.tar.gz in the VM's folder, 600 in folders that are 700:

  • Types: regular files, folders and symlinks, and a hard link only to a regular file kept before it. Devices, FIFOs and anything else are dropped, so the new VM's tar creates none.
  • Paths: each is cleaned, and one that's absolute, has .. above the home folder or holds a control character is dropped, and so is the home folder's own entry, so its mode stays the new image's. So is any entry below a symlink kept before it, which tar would follow out of the home folder.
  • Modes and owners: the setuid, setgid and sticky bits are dropped, and so are the entry's owner and group, so the new VM's tar makes everything its user's.
  • What devvm writes itself: ~/.config/devvm (its environment, which holds the placeholders of the VM's secrets), ~/.ssh/authorized_keys, every agent's login files, whichever agents the VM has, but Claude Code's ~/.claude.json, whose per-folder state is history, the agents' folders that devvm links to their mounts and the files it copies from the host, all of which the new VM's setup writes again, and ~/.cache.

devvm puts the file into the new VM once it has started confined, as the VM's user, with tar --skip-old-files, so a file or folder the new image put in the home folder, ~/.bashrc among them, stays the image's, its metadata included, and the shell that runs tar there reads only the image's files. devvm's setup runs after it and writes its own files again. The file is deleted once the new disk has it, when the remake is undone, and with the VM's folder.

Not covered:

  • The home folder is as trusted as the old VM was. What its code wrote there, such as a shell snippet in ~/.bashrc.d, a ~/.ssh/config entry or an agent's settings, runs in the new VM as it would have in the old one. The new VM is the same project's VM, with the same reach, so this is no new access, and --clean-home starts from the image's home folder instead.
  • Its size isn't bounded. A VM can make its home folder as large as its disk, and the copy then takes as much room on the host, besides the old disk and the new one. A VM can already fill the host's disk through the project folder, which it writes, so this adds no new way to do it, and devvm checks for a VM's free space before the remake.
  • It's on the host's disk for the remake's minutes, with whatever the VM keeps in its home, such as keys or logins it made itself. The VM's disk holds the same data in devvm's Lima home, with the same permissions, so a backup of the data folder sees it either way.

Threat check (the security-audit skill, guidance mode, with its data isolation and lifecycle and resource exhaustion companions):

Lead What holds it Check
A hostile home folder writing outside the new VM's home through .., an absolute path or a symlink it planted copyHome drops each, on the host, before the new VM's tar sees the stream, and that tar runs as the VM's user Unit tests (TestCopyHome) keep files, folders, symlinks and hard links to kept files, and drop .., absolute paths, control characters, devices, FIFOs, setuid bits, owners, hard links out of the home folder and entries below a symlink
A hostile stream attacking the host It's parsed by memory-safe stdlib readers and never unpacked on the host, and it's written only into the VM's own folder, which only devvm writes TestCopyHome refuses a stream that isn't gzip
devvm's own files or the user's secrets carried across ~/.config/devvm, ~/.ssh/authorized_keys, the agents' logins and the files and folders devvm copies or links from the host are left out, and the new VM's setup writes them again TestCopyHome leaves them out, and the CLI tests check that a saved home holds .bash_history without ~/.config/devvm
The old VM's code influencing the new VM's setup or the restore itself The restore keeps what the image put in the home folder, its folders' metadata included (--skip-old-files), so the shell that runs it reads the image's ~/.bashrc, and devvm's setup runs after it The CLI tests check the restore's command and order; e2e checks that a file in ~ survives a remake and that the VM opens a shell afterwards
A remake halfway losing the VM The old machine is kept aside until the new one has started with its home folder, the cleanup puts it back on any failure or interrupt before then and never deletes the new one after, and a killed devvm leaves the remake section, which the next devvm finishes, while devvm gc --orphans skips the VM and devvm rm deletes both machines. The saved home folder goes only after the section does Unit tests (TestRemakeUndo, TestRemakePending, TestRemakeDone, TestRemakePendingChecked) and the CLI tests: a failed create and an interrupt put the old VM back as it was, a remake left with its old machine aside or gone is finished by the next devvm, checked again first, and one whose old machine wasn't deleted keeps its new machine
Two devvms on one remake The remake lock (run/remake.lock), held from finding the VM until the remake ends, with the state read again under it: a second devvm refuses (remake_running) rather than finishing a remake that's still running Unit test (TestRemakeHeld)
Links reaching a different VM The VM keeps its ID only when its state is kept, by the user's own remake in its folder, and a link session reads the new host keys once the target starts again Unit tests (TestAddLayers) check every state key but the image survives, the ID included, and e2e's project section checks that a VM made again keeps its settings
A parent folder's VM made again from a subfolder Asked only in a terminal (remake_parent_vm_ask), which --force never answers, and refused without one The CLI tests refuse it without a terminal and keep it when the answer is no

A folder's volume

A VM's state records its folder's volume beside the folder's device, inode and birth time, so a folder that moved while a restart gave its disk another device number keeps its VM (one VM per folder). The volume is macOS's volume UUID, from diskutil info -plist for the mount point and device read from the folder opened with no link on its path, or Linux's f_fsid on ext4, Btrfs and ZFS, read from that open folder. It's bound to the folder's inode and birth time, so a record that an older devvm left beside another folder names no volume.

The volume tells two disks apart that each have a folder with the same inode and birth time, which happens by chance or when a copy of a disk gets a volume ID of its own. It doesn't tell a disk from a copy that keeps the volume ID, and it isn't a secret or a signature:

  • Who can forge one: whoever can write a volume's metadata. On macOS that's root, any program running as you, which can attach a disk image it made with hdiutil without root and without asking, or anyone who makes a disk image, sets the UUID in its bytes and gets you to attach it. On Linux, tune2fs -U and btrfstune need write access to the block device, which is root's, and a crafted image needs a loop mount, which is root's unless your desktop lets you mount images. A crafted disk or image can set the inode and birth time too.
  • What it gets them: what a copy of the disk that keeps all three already gets. At another path, devvm offers the VM to the folder only when nothing is left at the old path and the folder is yours, and moves it only after you confirm. On a disk image or an external disk mounted with its owners ignored, as macOS mounts them by default, a folder can read as yours whoever made it, so that check holds little there. At the folder's own path, the forged disk has to be mounted over the folder's path, and then it gets the VM as the folder's disk would.
  • What a VM can do: nothing here. A VM can't attach a disk or write a volume's metadata on the host, and devvm reads the folder's identity, its owner, its mount point and its device from the folder opened with no link on its path, so a link a VM puts in a folder's place can't pass another folder off as it.

Threat check (the security-audit skill, guidance mode, with its data isolation companion):

Lead What holds it Check
A folder on another volume with the same inode and birth time, at the folder's own path after a restart A renumbered folder at its own path must be on the recorded volume when both are known (platform.KeepsVolume), checked when devvm finds the VM and again when the start records the new device Unit tests (TestKeepsVolume, TestRenumberedOnAnotherVolume)
A link swapped in while devvm reads the folder The identity, owner, mount point, device and f_fsid come from one folder opened with no link on its path (platform.StatFolder), and diskutil's answer must name that mount point and device Unit tests (TestStatFolderAndVolumeUUID, TestStatFolder, TestMovedFrom)
A diskutil that hangs or fails A lookup within 1 or 5 seconds, none after one fails in a run, and a volume that can't be told records no volume and matches no moved folder, while a renumbered folder at its own path is then judged by its device, inode and birth time alone, as for a state that records no volume Unit tests (TestVolumeOfCache, TestRecordFolder)
A disk the user mounts in its place Not held, because a disk mounted at the folder's path with the folder's volume ID, inode and birth time is the folder to devvm, as it is to any program Documented here and in one VM per folder

opencode's database in history exports

opencode 2 keeps its sessions and its logins in one SQLite database, ~/.local/share/opencode/opencode.db (opencode-<channel>.db for another channel's build), in WAL mode. An export of agents' history goes to this machine and can go into another VM of the folder, so it must carry the sessions without the logins. Leaving the database out would lose opencode's history, and opencode's own opencode session export runs opencode and its server once per session, which an export before devvm rm can't count on. devvm copies the database in the VM with the sqlite3 that base installs (sqlite3 on Debian and Ubuntu, sqlite on Alpine), as the VM's user, in a temporary folder in ~/.cache (opencodeClean):

  1. VACUUM INTO copies the database as one snapshot, with what its -wal file holds, so a login that opencode saved last, which is still only in the WAL, is in the copy and taken out with the rest.
  2. In the copy, devvm drops every trigger, so none can put a row back, and empties the tables that hold logins: opencode 2.2's credential (its logins and API keys), account and control_account (its console's access and refresh tokens) and account_state, the session_share table of an earlier opencode (each share's secret), and any other table whose name has credential, account, auth, secret, token or share in it, or that has a column such as secret, api_key, access_token or password, so a table that a later opencode adds for its logins is emptied too. It also deletes the rows of the kv table whose key starts with wellknown:config:, because each holds an organization's remote config, which opencode fetched with that organization's well-known login and which can hold the organization's keys. opencode fetches the config again once it has the login. It also empties what would run without asking in the VM that imports the copy (opencodeUnattended): opencode 2.4's automation table, each automation's trigger and the shell command it runs, which opencode approved once, as the automation was made, and never asks about again, its permission table, the requests you said always to allow in a project, its job table, the subagents' jobs, and its session_inbox table, a session's queued messages, which its service starts again when it starts (restart.ts), and any table whose name starts with one of those names. It sets to NULL, in every table, a column named time_suspended, which marks a session whose turn the service resumes on its own, and one named commands, a project's commands, whose start command opencode runs with bash -lc for each worktree it makes (opencodeNulled). It drops every view, as a view in an emptied table's name could show a renamed table's rows, and its check fails on any table with a generated column, which pragma_table_info doesn't list. Each session's own rules are the permission column of session_v2, a JSON array of rules, each with an effect of allow, deny or ask, so in every table with a permission column, its name in any case, devvm keeps only the deny and ask rules with a text action, and a value that isn't such an array becomes no rules (opencodeAllowRules). It writes each kept rule again from the values that sqlite3 read, because sqlite3 reads a key written twice by its first value and opencode's JSON.parse by its last, so "effect":"deny","effect":"allow" would otherwise stay as an allow rule for opencode. A kept rule whose resource is missing or isn't text gets *, which matches every resource, because opencode's rules need one. It reads that JSON only where a CASE has found it valid, because sqlite3 may read both sides of an AND and fail on text that isn't JSON.
  3. It takes out the record of opencode's migration that imports auth.json (20260805200742_import_legacy_credentials), so the opencode that next opens the copy imports the logins that devvm's setup wrote in its own VM's auth.json, as it does when it first makes its database.
  4. It turns WAL off, with secure_delete on, and runs VACUUM, which writes the file again, so no free page keeps a deleted row and no -wal or -journal file is left.
  5. It checks what sqlite3 printed, not only that it succeeded. Right after VACUUM INTO, the copy must have as many tables as the database, and at least one. At the end, devvm counts the triggers and views, the generated columns, the rows of each table it emptied, the values left in each column it set to NULL, the rows whose permission still holds anything but deny and ask rules, and the kv rows it deleted, and each count must be 0, so a sqlite3 that runs nothing and prints nothing fails the check too. When a check or any step fails, the database is left out of the export and the run log says why.

The export's tar leaves out the database and its -wal, -shm and -journal files as they are, matched within opencode's folder, and adds the copy at the database's path (--transform, which leaves symlinks' targets alone). The import does the same to an export it unpacks, in the VM, before anything reaches the home folder: it deletes the -wal, -shm and -journal files and any database that isn't a regular file, and puts in each database's copy, or deletes the database when the VM has no sqlite3 or the copy fails. Each sqlite3 runs with trusted_schema off, so an imported database's schema can't call the CLI's functions that write files.

Not covered:

  • A secret that's in a session itself, such as a key you pasted into a prompt, stays in the session, as it does in Claude Code's and Codex's transcripts.
  • A plugin's own storage and a remote workspace's binding stay. opencode keeps each plugin's storage in its kv table, under the plugin's own prefix, and each remote workspace's binding, the record its provider needs to reconnect, in its workspace table. opencode's built-in plugins keep model catalogs and session records there, but a plugin you install, or a workspace provider, that keeps a token there takes it into the export.
  • A VM without sqlite3, made from an image built without it, exports and imports no opencode database, and opencode's sessions are lost from that export.
  • opencode's own agents keep their rules. A session keeps its agent, and a turn is checked against that agent's built-in rules too, such as explore's, which allow its shell commands. With no suspended session, job or queued message, no turn starts until you send one.
  • A host password that looks like a variable's name or a number. Settings' copies keep a value that looks like an environment variable's name or a switch (envName, plainValue), so a service password set by hand in that form reached VMs as it was, with no devvm-redacted for the setup's clean-up to find; the release page says what to do.
  • The event table stays as it is. It holds the events that opencode's sessions were made from, a session.permissions event's rules among them, and opencode 2.4.1 writes an event into session_v2 as it publishes it (its session projector), not when it opens a database, so the copy's rules are the ones opencode reads. A later opencode that rebuilt its sessions from that table would read the allow rules again.
  • A remake's home folder copy keeps opencode's database with its logins, and its home key, because it's the same VM's data going into the same folder's new VM (the home folder's copy).

opencode 2.4 keeps the private Ed25519 key of its home, which every machine it pairs with opencode machine add trusts and which it never replaces, in a file of its own, ~/.local/state/opencode/machine/home-key, not in the database. The database's machine table holds each paired machine's name and the public key it logs in to the home with, so it's the VM's own pairings, and the copy empties it with the login tables (opencodeLogins). The key's folder, the background service's registration (service.json, or service-<channel>.json on a channel other than latest, dev, beta or next, with the service's password, written through <file>.<id>.tmp, and <file>.pty-handoff, a terminal's handoff ticket, written through <file>.pty-handoff.<uuid>.tmp) and the terminals' daemons (pty, their sockets and access tokens) are opencode's HistoryOwn in the agents' registry: the export leaves them out and the import never writes them, while a remake keeps them. The registrations are patterns, service-*.json, service.json.* and service-*.json.*, which the export's GNU tar --exclude and the import's tar --exclude and its clean-up loop, a shell glob, all expand.

Threat check (the security-audit skill, guidance mode, with its data isolation companion):

Lead What holds it Check
A key typed into opencode in the VM reaching this machine's export The export holds only the copy, whose login tables are empty and whose file is written again by VACUUM Unit tests (TestOpencodeClean, TestHistoryExportRuns) plant a credential, an account's tokens, a share's secret and a later table's key, the credential only in the WAL of an open connection, and find none of them in any byte of the copy or the export; e2e's network section plants a key with the VM's sqlite3 and finds neither it nor the login's placeholders in the export
The WAL or journal file carrying the rows They never go into an export, and an import deletes them TestHistoryExportRuns and TestHistoryImportCleansOpencode
An export with the logins in it reaching another VM The import makes the same copy in the VM before anything reaches its home folder, or leaves the database out TestHistoryImportCleansOpencode, with and without sqlite3
A trigger putting a row back as it's deleted Every trigger is dropped first, and the rows are counted after TestOpencodeClean plants one
A hostile VM's export running a command, or allowing one, without asking in the VM that imports it The copy empties automation, permission, job and session_inbox, and every table whose name starts with one of those names, sets time_suspended and commands to NULL, keeps only the deny and ask rules of each permission column, written again, drops views and refuses generated columns; the counts after must be 0. The export leaves out opencode's git repositories (snapshot, repos, worktree), and the import never writes them TestOpencodeCleanSchema plants a row in each from opencode 2.4.1's schema, an allow rule, a suspended session and a project's commands; TestOpencodeCleanSessionRules plants rules that aren't deny or ask, a key written twice, values that aren't rules and a column in upper case; TestOpencodeCleanHidden a view and a generated column; TestHistoryExportRuns and TestHistoryImportRuns the git folders
opencode's home key reaching this machine's export or another VM The export leaves out its machine folder, service.json, service-<channel>.json, their handoff and temporary files, and pty, and the import never writes them, by their paths after it unpacks too; the copy of the database empties its machine table, the paired machines' public keys TestHistoryExportRuns, TestHistoryImportRuns and TestHistoryImportV010 plant them; TestOpencodeCleanSchema empties machine from opencode 2.4.1's schema; TestHomeSkipsEveryLogin keeps them in a remake
A hostile database's schema running code in the VM trusted_schema is off, and it runs as the VM's user on the VM's own files, which the export's code could reach anyway Reviewed

devvm's agent store reaches every VM with the agent: its folders are mounted read-only, its files are copied in at every launch, and the hooks, MCP servers' commands and plugins in it run in each of those VMs. So whatever devvm agent import copies is something every such VM reads and runs. A link in an agent's folder that leads out of it can lead anywhere on this machine, such as to ~/.ssh, to another agent's login, or into a folder that a VM can write, such as a dotfiles repo that is also a devvm project. Following such links unasked would let a mistaken link put a secret into every VM, and let a VM that writes the folder a link leads into change what every other VM's agent runs. That's why the import follows no link out of an agent's folder by default, and reads each folder through itself as an os.Root (how).

Dotfiles repos keep settings as links all the same, and copying them into the store by hand is lost at the next import, so devvm follows them when you allow it, in two ways:

  • config.toml's follow-links names folders, such as ~/dotfiles, whose links devvm follows without asking. You choose a folder once, for every import, so devvm checks the folder as a whole: one that is, holds or is inside a refused place fails the import, because a link inside it can lead anywhere in it.
  • --follow-links, or a yes to the question, follows one run's links after naming each and where it leads, so you see every target before anything is copied. Without a terminal, no link out is followed unless the flag is given, and each is named in a warning, so a script never follows a link it didn't ask for. The folder each is read through is the link's own target, or a linked file's own folder.

Whichever allows it, the same rules hold:

  • Resolved first, read inside. devvm resolves every link on the way to the target, checks that target, then reads it through the allowed folder as a root, which it opens one folder at a time from /, never through a link. A link inside what it copies is read only when it leads to a file inside the same root.
  • Always refused. devvm never follows a link to the home folder or a folder holding it, to devvm's config, data or Lima folders, to ~/.ssh, ~/.gnupg, ~/.aws, ~/Library/Keychains, ~/.config/devvm, ~/.netrc, ~/.config/gh, ~/.docker or ~/.kube, or to any agent's logins or history, nor into one of them or to a folder holding one. The home folder holds all of them, devvm's folders hold its CA keys, binaries and every VM's disk, and the agents' logins and history are what the store exists to keep apart from VMs. The named folders are the places that commonly hold credentials, and the list can't name every one, which is why the question names each target and the setting takes folders you choose.
  • A VM's folder warns. A target in a VM's project folder, or a --clone VM's source folder, is followed with a warning naming the VM, because that VM can change what every VM's agent reads from the next import on. Refusing it would refuse the common case of a dotfiles repo that you also work on in a VM, and the warning leaves the choice with you. A chain that passes through a link in a VM's folder to a place outside it is refused, though, because the VM chose that place, and it could name any file the refused list doesn't.
  • Compared by identity. devvm compares a target with the refused places and the VMs' folders by name and by file identity, because a Mac's file system ignores case, so ~/.SSH names ~/.ssh.
  • Copies only. The store gets a copy of each file and folder, never a link, and the next import replaces or takes out each copy as it does the agent's own files. devvm agent save still refuses a link the VM sends.
  • Bounded. One import copies at most 20,000 files and folders, 128 MiB and a file of 16 MiB through links, the bounds of devvm agent save, so a link to a large tree can't fill the store.

Not covered:

  • The copy is as the target was at the import. A VM that writes a followed folder later changes nothing in the store until the next import, which then copies what it wrote. The warning names that VM.
  • A refused place under another name, such as a credential folder that the list doesn't name, is copied when a link you allowed leads to it.
  • A huge folder is read before the bounds stop it. devvm lists each folder whole before it counts its entries, so a folder of millions of entries costs memory on this machine before the import leaves it out.

Threat check (the security-audit skill, guidance mode, an independent review of the code):

Lead What holds it Check
A VM swapping a link into the path of an allowed folder, or into what's being read The root is opened one folder at a time from /, never through a link, and everything below it is read through it as a root, without blocking and without following a swapped-in link TestOpenPhysical, TestAgentImportNestedLinks
A VM choosing the target through a link in its project folder Every link on the way is kept, and a chain through a VM's folder to a place outside it is refused, whatever allows it TestAgentImportLinkThroughProject; the review found it first, and it's fixed
A refused place spelled another way, such as ~/.SSH on a Mac Targets are compared with the places by identity as well as by name TestAgentImportRefusedOtherCase; the review found it first, and it's fixed
A link to a secret, a login or devvm's own files The refused places, checked on every target and every follow-links folder TestAgentImportRefusedPlaces, TestAgentImportRefusedRoots
A write outside the store Names come from real folder entries under the link's own path, and the store's clean-up goes through the store as a root Reviewed
A FIFO, a device, a huge or growing file, a loop Reads refuse anything but a regular file, the bounds are checked when listing and again when reading, and loops end at the bounds or the system's TestAgentImportLinkBounds, TestLinkSourceGrown, TestLinkHops
A link followed without the user seeing it Without a terminal nothing is followed unless the flag is given, and each link followed is named TestAgentImportFollowsLinks, agent_import_links
What VMs get Copies only, mounted read-only like the rest of the store e2e's project section reads the linked skill's copy in a VM and finds root can't write it

Claude Code's plugins: a seed and a folder of the VM's own

Claude Code writes into its plugins folder whenever it runs: each plugin's data, which a plugin reaches as ${CLAUDE_PLUGIN_DATA}, the plugins it installs, its marketplaces' copies and their updates, its MCP bundles and its records. devvm's agent store holds one plugins folder for every VM with Claude Code, mounted read-only, so if that folder were each VM's ~/.claude/plugins, every one of those writes would fail. A plugin that keeps data would break, and no plugin could be installed in a VM. Making the store's folder writable would fix the writes, but every VM shares it, so a VM could then change the plugins, hooks and MCP servers' commands that Claude Code runs in every other VM, and keep a foothold in each of them after you delete it. That isn't an escape to this machine, but it breaks the line between VMs that the store's read-only mounts hold for every other agent folder.

So each VM's plugins folder is its own, on its own disk, and the store's folder is Claude Code's seed, a plugins folder that Claude Code reads but never writes, which it supports for container images and CI (how). Its two variables, CLAUDE_CODE_PLUGIN_CACHE_DIR and CLAUDE_CODE_PLUGIN_SEED_DIR, are Claude Code's own, so devvm patches nothing in Claude Code and copies nothing into the VM at a launch, and the seed stays one mount that every VM reads. What a VM writes stays in that VM, and what it installed reaches the store, and every VM, only through devvm agent save, whose diff you read before you answer yes. The import and the save copy only the entries a seed has, the marketplaces' records, their copies and the plugins' cache, because the rest of the folder is each machine's own. Each plugin's data can hold its own logins, and this machine's plugins' data in the store would reach every VM.

The save never takes a plugin out of the store, because a VM's folder holds only what that VM installed, not the store's plugins, which it reads from the seed, so a plugin missing from it isn't one the VM removed. Taking out what the VM's folder lacks would empty the store of every plugin the VM didn't install itself. The VM's marketplaces' records join the store's for the same reason, and only a record whose copy is in the store's marketplaces folder joins, so the records that Claude Code made of the seed's own marketplaces stay as the store has them, and a record can't point other VMs elsewhere.

Not covered:

  • A marketplace in a folder on this machine reaches a VM only when that folder is in the VM too, because Claude Code reads such a marketplace where it is, and a seed holds no copy of it.
  • A plugin's data stays in its VM. A new VM, or one made from an export of another's history, starts each plugin's data afresh, and so does every VM after you install a plugin there, as the export leaves the VM's plugins folder out.
  • A plugin installed in a VM runs in that VM with whatever it does, as a plugin does on this machine. devvm keeps it from the other VMs until you save it, and the save's diff shows what it adds.

Threat check (the security-audit skill, a hostile VM writing what other VMs or this machine run):

Lead What holds it Check
A VM writing the store's plugins, which every VM runs The store's folder stays mounted read-only, and the VM's writes go to its own folder TestClaudePluginsSeed, sync's links and own-dirs, e2e's project section
A save that sends more than the seed's entries, such as a plugin's data The VM's script sends only the seed's entries, and devvm saves nothing when the stream has any other entry of the folder TestReadSentClaudePlugins, TestAgentSaveScriptClaudePlugins, agent_save
This machine's plugins' data reaching every VM The import copies only the seed's entries, through links too TestAgentImportClaudePlugins, agent
This machine's plugins' data that devvm 0.1.0's import left in the store Every start takes the store's entries that a seed lacks out before the VM runs, from devvm's config folder as a root, refusing a link anywhere on the path and following none among the entries, and a VM with Claude Code doesn't start while they can't go TestCleanSeeds, TestCleanSeedsFails, fixture_v010_plugins
A VM's paths in the records it saves The records' paths to the VM's plugins folder are renamed to the store's, only a record whose copy is in the store's marketplaces by a clean path joins the store's, and a records file that isn't a JSON object is left out TestAgentSaveClaudePlugins
A name in the VM's plugins folder that the save's script would read as a pattern It's sent rather than excluded, and devvm refuses the save TestAgentSaveScriptClaudePlugins
A plugin's data, or what a VM installed, reaching another VM through an export The export and the import leave out the VM's plugins folder, and the import leaves out the seed's link TestClaudePluginsHistory
An export that names the VM's plugins folder another way, such as .claude/./plugins, past the import's excludes, as the folder is writable The import refuses a name with a ., .. or empty part, and deletes what it leaves out by its path once unpacked. The review found it first, and it's fixed TestHistoryImportRuns

The 9p cache on Linux

On a Linux host, Lima's QEMU shares the project folder over 9p, and Lima mounts a writable 9p share with cache=mmap unless the VM's config says otherwise (read-only ones with fscache). The guest kernel's 9p client has a race in that mode, which Pierre Barre's patch describes and which isn't merged. A stat() that runs while a write() makes a file longer refreshes the inode from the server, which still has the old size, so the client takes that size over its own, and writeback then drops the pages past it. fsync succeeds, yet the file reaches the host empty or cut to 4096 bytes. Claude Code's Edit tool sets it off, and so can any editor or build that stats files as they're written. macOS isn't affected, because Lima's vz VMs mount the folder with virtiofs.

mmap has a second bug on the guest kernel devvm's base boots (Ubuntu 26.04's 7.0), which doesn't depend on timing. After a process writes a file and takes a POSIX lock or an flock on it, its next read of that data returns zeros, though the host has the data and another process reads it. On such a lock, the 9p client writes the file's pages back and drops them, and the next buffered read through netfs returns zeros. SQLite takes a shared lock at the start of each transaction, so its second transaction reads page 1 as zeros and stops with SQLITE_NOTADB ("file is not a database"), in its default journal mode as in WAL mode, and Gradle's daemon, which keeps its lock files in .gradle/ open across builds, fails from its second build with "Unexpected lock protocol found in lock file".

none, the one mode devvm sets. With cache=none, the client caches neither pages nor sizes, so every write goes to the host as it's made, no stat can roll a size back and no lock drops data. It takes away shared writable mmap, which 9p allows only with writeback caching: a shared mapping of a file opened for writing fails with EINVAL, even one that's only read. That fails at once, so nothing is lost, and only programs that keep a database or an index in the folder do it: SQLite's WAL mode, whose -shm index is such a mapping, unless the connection sets locking_mode=EXCLUSIVE first, which keeps the index on the heap; LMDB, which Parcel's .parcel-cache and Gatsby's cache use; numpy's memmap in r+ or w+ mode; Java's read-write MappedByteBuffer; and the mold linker, which maps its output. Each of them works on the VM's own disk, in its home folder or in a --clone VM, faster than under any 9p mode. mmap is faster than none only for large sequential files, about 7 to 12 times for 1 GiB, 1.3 to 1.5 times for cargo, and within 10 to 20% for git, npm, Vite, Go and rg, while the VM's own disk is faster still by far, from about 2 times for npm ci to over 20 for a cold git status (measured on a Fedora 43 host). So devvm doesn't offer mmap, which would trade two ways of losing data for what the VM's own disk does better. It doesn't offer loose or fscache either: they allow the same mappings, share mmap's SQLite failure in a worse form, as the database can't be opened again at all, and cache files' contents and metadata in the guest without asking the host, so the guest misses edits you make on this machine, which devvm's mounted folder exists for.

Existing VMs opt in. A VM made before devvm chose none has no mode in its state, and its starts leave its mount's cache as it is, so an upgrade changes nothing in how such a VM uses its folder. Each launch of such a VM warns of the risk and names devvm mount-cache none, which ends the warning. none is the only value the command takes, so there's no default to choose and no -g or config.toml key: every new VM gets none, and so does the folder devvm clone off mounts.

Build VMs' output folders get none too. The shared tools' build writes its EROFS images into a writable mount with mkfs.erofs, and --from's conversion writes its disk into one with mke2fs, and neither maps its output for shared writing, so none takes nothing from them. The read-only mounts, agents' folders and the shared tools, keep Lima's fscache: the guest can't write them, so the race has no write to drop.

One edit. The mode is a mount's 9p: cache: option, which devvm compares with what limactl list shows and sets only where it differs, in the start's one limactl edit, as any edit gives the VM new ssh host keys. limactl list fills each mount's other 9p and sshfs settings in, at Lima's defaults where lima.yaml sets none. A rewrite of the mounts keeps only the settings devvm knows (9p's security model, protocol version and message size, sshfs's cache, symlinks and SFTP driver) where they differ from Lima's defaults, as the VM's own, and drops the rest, so no default gets written into lima.yaml, where a later Lima's would never reach it. A setting devvm doesn't know, such as one a later Lima adds, is dropped too, for Lima to fill in, as devvm can't tell its default from a value someone gave: it has no YAML parser to read lima.yaml itself. Editing only devvm's own fields with --set instead (.mounts[0]["9p"].cache = "none", which Lima takes) would keep everything else as it is, but a moved folder or other agents' folders would then need edits by index and by selector, which the CLI tests' limactl stub doesn't model, so devvm rewrites the mounts whole. The defaults are the ones in the golden fixture of real Lima's limactl list (Lima 2.2), which TestMountRoundTrip checks, so a later fixture that changes them fails that test; until then, a known setting whose default a later Lima changes keeps the old default through a rewrite.

The remount. Lima's cloud-init writes the new options into the guest's /etc/fstab at the boot after the edit, but systemd has mounted the folder by the old line by then, and a 9p share keeps its tag. So that start unmounts the folder and mounts it again from /etc/fstab once the VM runs, with a minute's limit and its output in the run log, then checks it with mountpoint and the folder's line of /proc/self/mountinfo, which a POSIX awk picks by its mount point, as mountinfo escapes it (a space as \040). The check is portable: it runs with any guest's awk, busybox's too, and depends on no util-linux tool, such as findmnt, but mountpoint, which busybox has as well. devvm reads at most 4 KiB of the answer and only its last line, the mount visible at the folder where mounts are stacked, takes the mount's options and its file system's from it, refuses an answer that isn't a mountinfo line, and names any mode but none and mmap as unknown. The remount's and the check's output pipes close a second after the commands end or time out, as limactl shell's ssh can leave a child that holds them open.

The restart. A folder that isn't mounted, one still mounted with the old mode, or a check that gets no answer gets one restart. The remount fails when something the VM started at boot holds the share, when a degraded start mounted it again by the old line, or on an Alpine guest with OpenRC, whose mount after a successful umount finds the share already mounted or busy. The Lima backend writes why in the run log, stops the VM under one status step, and fails the start with a RemountError, and the start's caller (starter.start) starts the VM again once, all of it: a new proxy that follows the new hostagent, the .git pins applied in QEMU's new namespace, the host keys read again for the new start, and the start recorded. The caller restarts the VM, not the backend, because the proxy follows one start's hostagent and exits when the VM stops. The guest's /etc/fstab has the new mode by then, so the restart's boot mounts the folder with it, and that start's Want.CheckCache asks the backend for the same check without the remount. That check is the last, and nothing it finds restarts the VM again. A folder that isn't mounted stops the VM and fails the start before its setup or shell, as an agent's writes there would land on the VM's disk and vanish under the share at its next mount (mount_cache_unmounted, which names devvm restart), and so does a check that gets no answer (mount_cache_unchecked). A folder still mounted with the old mode is warned of (mount_cache_remount_failed). When the restart's stop fails, a folder still mounted with the old mode is warned of the same way and the VM goes on with its proxy, and any other failure fails the start as a stop that failed (stop_failed, with the run log's end), as the VM may still be running. The retry runs the whole start again, so the UI says each warning once a run, and the first start's warnings aren't repeated. An interrupt during the remount, a check or the restart's stop, on any tier, leaves a cleanup that stops the VM, which stays until that stop returns, and an interrupt gets no restart. A known race, older than the restart, fails closed: another devvm command can start the VM between the restart's stop and its start again, and the two starts then contend as any two starts of one VM do.

A running VM's folder. A launch into a running VM whose folder has a cache mode checks it's a mount point, one mountpoint -q over the VM's ssh, and refuses one that isn't (project_unmounted), or whose check fails to run or gives no answer (project_unchecked). The guest answers in words, as mountpoint's exit codes differ between util-linux (32) and busybox (1).

Tool images built before. A shared tool's build wrote its EROFS image into a writable 9p mount with Lima's mmap before devvm chose none, so an image built then could reach the share empty or cut to 4096 bytes. devvm reads each EROFS image's superblock when it asks whether the image is built: one that ends before its superblock does (1,064 bytes), empty included, or is shorter than the block count its superblock gives, counts as not built, and the next build makes it again. A build whose output is cut short is refused (tool_bad_output). It costs a 40-byte read per image, and a file that isn't EROFS's at all is left to the guest's mount to refuse.

End-to-end checks (tests/e2e, the project section on a Linux host): a new VM's folder mounts with none, as its state says, which /proc/self/mountinfo shows as no cache option at all, as the kernel leaves it out for none, where it shows cache=0x5 for mmap; 40 files written in 4 KiB extending writes with fsync, while a loop stats each, all reach the host whole under none; SQLite's WAL mode fails in the folder under none and its default journal works; a shared writable mmap of a file there is refused with EINVAL, and SQLite's WAL with locking_mode=EXCLUSIVE works and opens again; a VM whose state loses its mode, and whose lima.yaml gets Lima's mmap by hand, keeps mmap with its lima.yaml unedited by devvm, and warns at each launch; and devvm mount-cache none gives it none at its next start, devvm restart, which mounts the folder again, and the warning stops. The tools and from sections build the shared tools and --from bases with their output folders under none, and the from section's Alpine VM, given Lima's mmap with no mode chosen, gets none from devvm mount-cache none at its next start, through the restart its failed remount gets, its folder checked by the portable check. On macOS, the project section checks that the folder is virtiofs and that devvm mount-cache refuses the VM's. Two things under mmap are run and reported, not checked: the same loop, as the race is timing's, which left 1 file of the 40 short in one run on Fedora 43 and none in others, and five new SQLite databases in the default journal mode, for the lock bug. The research behind dropping mmap (every tool above under each mode, on a Fedora 43 host with devvm's Ubuntu 26.04 guest) was run by hand, outside the end-to-end tests. Unit tests: TestProjectCache, TestMountRoundTrip, TestStartSetsProjectCacheOnce (the remount's outcomes, each failure a restart), TestStartRechecksProjectCache (the restart's check, with no second restart), TestRemountInterrupted, TestRemountRestartStop (the cleanup kept through the restart's stop, and a stop that fails), TestOptionsOfMountinfo, TestMountinfoPath and TestLastMount (real mountinfo lines: 9p with and without cache=0x5, stacked mounts, a path with a space) in the Lima backend, TestCutShort and TestBuiltCutShort in the shared tools, TestGuestMountOptions in the stubs, TestUpCacheMode, TestWarnMountCache, TestCacheAtNextStart, TestSwitchCache, TestSetMountCache and TestRemountRestart (one start again, with a proxy of its own), TestRemountRestartConfined (each start's interrupt undo, an interrupt between the starts, a start again whose proxy fails), TestWarnOnce in the UI, and the CLI tests mount_cache (with the stubs' remount-fails, and a policy line warned of once), clone_switch and the 0.1.0 fixture, whose VMs keep mmap and warn.

Linux hosts: overlays instead of copies

Lima on QEMU keeps one qcow2 disk per VM, and a clone copies it (2.0 GB for base). A project VM's disk is a qcow2 overlay of its image's instead (details): 196 KB new, 12 MB after booting, the same speed except fsync writes (1.8–2.5 s vs 1.2–2.1 s per GiB). Flattening one (qemu-img rebase -b "") took 8 s, if it's ever needed.

One binary

devvm's own files (assets/ in the repo: base.yaml, prelude.sh, layers/, features/, shared-tools/, network/, guest/, oci/) are embedded in the binary (assets.FS), so devvm installs, moves and upgrades as one file and can't find a mismatched copy beside it. Code reads them from that file system; scripts reach VMs on their standard input, never by path or file mode. The binary is the only copy: no shared folder on disk holds devvm's files, because a copy there could be edited and still be used. A VM's proxy is devvm itself, so it reads its built-in policies from the binary (its config's builtin_policies, by name), once, and its policies carry only your files. limactl create reads base.yaml on its standard input (-). Only --from's build on Lima needs a path, because its build VM mounts the conversion's scripts from oci/ read-only (root there reads them), and none of the folder's other files, with guest/ca.sh beside it when you have company CAs. It writes them into its own temporary folder, devvm-oci.<random>, beside vm/ and never inside it, files 600 and folders 700, and the build's cleanup deletes the folder however the build ends. Image keys hash the embedded files, so what goes into an image is always what its key describes.

devvm's own Lima home

Lima merges _config/default.yaml and override.yaml of its home into every VM. In ~/.lima, a networks: [{vzNAT: true}] there gave a confined VM a second network card with a default route around its proxy (the self-check caught it), and an extra mount went unnoticed. Hence a Lima home of devvm's own, which refuses those files and any network devvm didn't give a VM (details). The costs: plain limactl list doesn't show devvm's VMs, and VM names are shorter, as the path of Lima's ssh socket has fewer than 104 characters.

The state layout

devvm keeps its state in plain files in two folders, which State files describes. The layout follows a few rules:

  • One folder per VM, keyed by identity. A VM's folder, vms/<hash>/, is named by the hash that ends the VM's name, the hash of its project folder's physical path when devvm made it. The VM's name, its backend and its ssh alias are chosen once, when devvm makes the VM, and recorded in its state, so devvm finds a folder's VM by the state that records the folder, first by the path's hash, then reads the name and the backend from the state. A folder that moves keeps its VM, whose state records the new path while its name and folder stay (a moved folder). A backend's limit on names, or another VM taking the same folder name, never changes which VM a folder finds. Every file devvm keeps for a VM is in its folder, so deleting a VM stops what runs for it, removes what it has outside the folder, and then deletes the folder whole, and devvm space and devvm gc count folders. A list of a VM's files, kept in each place that deletes or counts them, would drift, and one of those places would miss a file. Only sockets stay outside, in run/ and named by hashes, because a socket's path has fewer than 104 characters.
  • The folder says who writes a file. ~/.config/devvm holds what you write, and devvm never rewrites a file of yours there: it changes single lines of policy and keeps the rest, comments included, and it writes the folder's version. Everything devvm writes is in ~/.local/share/devvm. A default comes from a flag, then config.toml, then settings.json, then devvm's own, and a command that would save a default that config.toml sets refuses, naming the file and the key, because the saved value would never apply.
  • Two formats. What you edit is TOML, read strictly, so a typo stops the command and devvm names the file and the line, rather than the key being ignored. What only devvm writes is JSON, through encoding/json, and devvm ignores fields it doesn't know, so a newer devvm's additions don't stop an older one. A change that an older devvm would read wrongly goes through the layout version instead.
  • One section per package. vm.json has the core fields every VM has, and each package that keeps something of a VM's owns one section of it, with its own type, so internal/state imports none of them. Each section keeps what you asked for apart from what devvm made, which sits under made, so a value is never stored twice under two names.
  • The lock rule. Each change to a VM's state holds that VM's lock, reads the file again, and writes it once, so a command's changes land together, and reads take no lock, because each write renames a whole file over the old one. A command holds at most one VM's lock at a time. A change across VMs, such as removing every link to a VM being deleted, lets go of the first VM's lock, then takes each other VM's lock in turn and reads its state again before writing it. The claims lock is taken only after a VM's own lock, never before, so no two devvms can each wait for the lock the other holds. Test builds and the tests check this order as each lock is taken (internal/state's held): a second VM's lock, a VM's lock under the claims lock, or a lock the same goroutine holds already panics, naming both locks, before it waits. The check is per goroutine. It follows the locks each goroutine holds, by the goroutine's number, which it reads from the goroutine's stack, so two goroutines that each hold one VM's lock pass, and a goroutine that a change starts while it holds a lock isn't checked against that lock. A release build checks nothing.
  • A layout version. Each folder records its layout version in version. A newer devvm that changes the layout raises it and adds a migration from the version before, an older layout is migrated before a command runs, and a newer one is refused, because this devvm would read it wrongly. testdata/script/layout.txtar lists every file and folder a confined VM, a port, a link and a secret leaves, so a change to the layout changes a listing and fails the test until someone decides whether it needs a new version (changing the state layout).
  • devvm's own files stay in the binary, as one binary describes, so neither folder holds a copy of assets/.

Why not a database. SQLite or bbolt would give transactions, but either one is a new dependency, and devvm builds without cgo, so SQLite would mean a large pure-Go port. State would also stop being files that you can read with cat or jq, back up, and check by hand. Files written whole and renamed into place, with an OS file lock for each VM, give what devvm needs: one writer to a VM at a time, and readers that never see half a file.

Where secret values live

devvm handles values that let whoever holds them act as you or as a VM: a VM's proxy password, a build proxy's, the company proxy's password, the secrets you save and the keys and tokens in agents' login files. Each one lives in a few places, and only there: the Keychain or the secret's file in ~/.local/share/devvm/secrets/, the proxy's proxy.json, the VM's vm.json for its proxy password, the agent store's login files, the proxy's memory for the values it caches, and the VM's own proxy settings for its password, which the VM must send. In devvm's code, each such value is a redact.Secret from the moment it's read until the place it's used, except for the two that Not covered names (secrets in the code).

  • Printing never shows the value. String, GoString and Format write <redacted> for every verb, so a %v of a struct in an error, a log line in the proxy's own log or a line of devvm's run log can't hold it. fmt can't call Format on a value in an unexported field, and prints such a field as it is, so the value is behind a pointer, and the field shows only its address. The run log's own redaction, redact.String, still takes proxy keys and URL passwords out of the output of the commands devvm runs, which no type can reach.
  • Encoding fails rather than writing a stand-in. MarshalJSON and MarshalText return redact.ErrEncode. A MarshalJSON that wrote <redacted> would look safe, but a struct written to the file that should hold the value, such as proxy.json or vm.json, would then lose it, and a VM would lose its proxy or you your login, with no error. A file that holds a value has a wire type of its own instead, which writes the value as a string, so the two kinds of file can't be confused.
  • There's no LogValue. devvm has no log/slog logging, so a slog.LogValuer would have no caller, and Format already covers the proxy's log.Logger.
  • Reveal is the one way to the value, and forbidigo refuses every call to it outside tests, so each place that uses a value carries a //nolint:forbidigo with its reason: the proxy's password check, the headers it puts values in, the company proxy's credentials, the VM's CA key as it signs, its config file and the broker's frames to its child; the secrets' store, which writes the Keychain and the file; the VM's proxy URL and vm.json; and internal/agentlogin's login files, refreshes and claims. A new use is a choice someone made, with its reason on the line, which the review sees. The structure test refuses a struct that embeds a Secret, which would take on its Reveal, and an interface that declares Reveal() string, through which a value could pass without a call forbidigo sees.

The wire types keep each file's bytes as they were, so a frozen release's proxy.json writes back byte for byte (TestV010ProxyConfigs), its Sum doesn't change and no running VM's proxy starts again for an upgrade. An agent's login file stays the agent's own format, read and written as a map so that fields devvm doesn't know are kept, and a key or token is a redact.Secret once it leaves the map, through a lookup, a refresh or a capture.

Not covered. The company proxy's URLs as your environment gives them, HTTPS_PROXY and HTTP_PROXY, can hold a password, and they stay strings, because devvm passes them on as they are, to proxy.json and to the programs it runs on the host. So do the URLs proxy.Upstream.WithPassword returns, which hold the saved password for devvm's own clients and the programs it runs. The VM's proxy URL, which holds its password, is a string too, because it goes into the VM's Lima config and environment, where the VM needs it. redact.String and redact.In take the passwords in such URLs out of devvm's run log and Lima's logs (your company proxy's password). Two values are strings by design:

  • The Keychain's value, which platform.KeychainGet returns and KeychainSet takes as a string, because internal/platform imports no devvm package. secrets.Store makes it a Secret at once in saved, and reveals it only for KeychainSet in save.
  • devvm desktop's VNC password, 8 characters that you must see to type into a VNC viewer. devvm keeps it in the desktop section of vm.json and shows it in desktop_ready.

The proxy's broker

A VM's proxy reads every byte the VM sends out, and it runs as you, with your Keychain, your files and every socket of yours. A bug in it that a VM could drive, such as a parser that a crafted request takes over or a path that leads out of its folder, would reach all of that. So devvm _proxy is split in two: a broker, which keeps what only the host should do and stays unconfined, and a child, which reads the VM's network and can be confined. The design keeps four things. A child that a VM takes over holds nothing of this machine's beyond what it held for that VM. It can't make the broker act for another VM, another secret or another file. It connects to no address that the VM's rules and the floor refuse, such as this machine's loopback, except for what a company proxy reaches for it. And the VM's connections stay the child's. Of each request, only the host name it looks up and the address it connects to cross to the broker, which opens the connection and hands it to the child, so no byte that the connection carries passes through the broker. Of a request's own bytes, only a login's token exchange reaches the broker, as captures in the broker below describe. Processes describes the two processes as they run, and this note is their design, with its threat check. On macOS the child runs under Seatbelt, and on Linux it confines itself with Landlock and a seccomp filter (the child's sandbox), and on both its sandbox refuses it every connection of its own, so the broker looks up each name and opens each connection that the child asks for, once its own policy and floor allow the address.

Why a broker, and not values handed over at the start: the proxy looks each bound value up when a request needs it, in the Keychain, devvm's secrets folder or an agent's login file, which it refreshes on the host when it's due (how the proxy puts them in). A login's value changes with each refresh, and the proxy keeps it for 30 seconds, and any other value for 5 minutes. The proxy also saves the logins that a VM makes, and writes the VM's bindings again. Values handed over once would be stale within the minute, and the child would need to write the store of logins. So the broker runs beside the child for as long as it does, and answers its questions.

What runs where:

Part Side Why
The VM's proxy port, every request and tunnel, the rules and the floor, the SNI check, interception, putting values into headers, transparent mode, devvm.proxy's endpoints, and the bounds on what a VM makes the proxy hold (maxConns and admit, maxConnects, maxRequests) child they read the VM's bytes, which is what the child is for
The event log, network.jsonl, and the child's own lines in proxy.log child each request logs an event, so a hop to the broker would sit on every request's path
The shared Nix cache, its fetches and its files child its fetches go through the floor and the company proxy as the VM's requests do, and each VM's Nix checks what it gets
The company proxy as the requests' upstream, with its credentials child, with the proxy secret's value from the broker the company proxy takes its password with each plain HTTP request, so whatever sends those requests holds it
Looking up a name, and opening a TCP connection to an address or to the company proxy broker, which hands the connection to the child, and judges each address again with its own policy and floor a sandbox can't tell this machine's loopback, its own addresses and the LAN apart from the internet as a rule changes (below), so the child's sandbox refuses it every connection of its own
Each value's lookup: the Keychain through security, devvm's secrets folder, an agent's login file and its OAuth refresh (IO.Secret) broker they need the Keychain and your files
Capturing logins: the token request to the endpoint, its reply, saving the login and writing the bindings again (IO.Capture) broker the endpoint's reply holds the login's real tokens, its refresh token among them, which never enter the child
The SSH agent's relay, its socket and its connections to the agent broker its filter is the guarantee, and a child with the agent's socket could send the agent anything
Holding the backend's logs to their cap (IO.KeepLogs, Config.VMLogs) broker they're in Lima's folder for the VM, beside its disk and its lima.yaml, which a child must never write
Connecting to a link's socket broker, which hands the connection to the child devvm's run folder holds every VM's link sockets and agents' relays, and the ssh masters' control sockets, each a way into a VM
Finding a request's host in the links' list child, checked again by the broker the child decides for each request whether it's for a link, before any rule
proxy.json, the CAs' files, the lifeline, the status file and the pid file broker the child gets what it needs of them over the socket, so it needs no read of the VM's run folder
The files that change while the proxy runs: the policy files, the bindings file and the links' list the child looks at them, the broker reads them below

The files that change. The proxy reads each of these files again when its modification time, size or inode changes, which it checks with a stat on every request. The child keeps that check, because Landlock leaves stat unrestricted and Seatbelt can allow it alone (file-read-metadata), and asks the broker for the file only when it has changed. The broker reads the file with the proxy's usual checks, its owner, its mode, at most 1 MiB, and a symbolic link followed or refused as each file allows, and returns its bytes with the stamp of the file it read. The child parses them and keeps that stamp, so a change still applies to the next request, and an unchanged file costs no hop. Both write proxy.log, each line saying which side wrote it. A rotation takes the file's lock and checks its size again, as the event log's does, so the two writers rotate it once, and the broker reads, copies and empties the file through the descriptor it was given, never by its path.

The folders the child writes are the VM's. A child that a VM takes over can put anything in the folders it writes, so the unconfined code that later opens them reads them as it reads a file a VM can write. The child may create only regular files there. On Linux it never gets Landlock's rights to make a link, a FIFO, a socket, a device or a folder, and the Nix cache's nar/ folder is made before it confines itself. On macOS its profile refuses creating anything but a regular file, and hard links, which the follow-up checks there. devvm, devvm _links, devvm network log, devvm network lock, the port forwarder, the link session, devvm gc's trim of the Nix cache and the cache's lock open, rename, empty, change and delete files in those folders through internal/safefile, never following a link and taking only a regular file with one link that's yours, or through an os.Root of the folder. The broker makes the cache's nar/ folder and sets both folders' modes the same way (makeNixFolders), deleting anything at nar/ that isn't a folder, a link as itself, and making a folder in its place, which its log warns of, so its chmod never reaches a folder of yours. A confined child can't leave a link there, so this is for one that runs without Landlock or Seatbelt. So a link that a child leaves where proxy.log, network.jsonl, links.log, ports.log or nar/ was never leads devvm to your files, and a FIFO there never hangs a command. A build's child writes events.jsonl and proxy.log in a logs/ folder of its own inside the build proxy's folder, apart from its config, its policy and its status file.

What the child needs, which what confines it holds it to:

  • Its descriptors: standard input from the null device, proxy.log as its output and its error output, the socket to the broker as descriptor 3, and the VM's proxy port's listener, which the broker opened, as descriptor 4.
  • Its environment: TZ, SSL_CERT_FILE and SSL_CERT_DIR when devvm has them, so the roots it trusts on Linux are the proxy's usual ones, and GODEBUG, to which it adds updatemaxprocs=0, so Go's runtime doesn't read its cgroup's CPU limit again as it runs. It gets nothing else, so it never sees a token in the environment of the shell that started devvm, or the status file's name.
  • Files to read and write: the VM's logs folder, vms/<hash>/logs/, where it creates, appends to, reads, empties and renames its two logs and takes the event log's lock, which devvm _links takes too, and for a VM with the nix layer, the shared Nix cache, cache/nix-cache/ and its nar/ folder, where it creates, writes, reads, lists, deletes and renames regular files, from the top folder into nar/ among them, and takes .lock. A build's child writes its own logs/ folder instead.
  • Files to look at only: the policy files, the bindings file and the links' list, with stat.
  • What the system gives it: what a Go program reads to start, the system's roots, its time zone, and the host's own addresses. On Linux, it loads the roots and its time zone before it confines itself. On macOS, crypto/x509 asks trustd through com.apple.trustd.agent, after CoreFoundation looks at the metadata of the program's folder for its bundle. The floor reads the host's addresses every 30 seconds (hostAddrs), through a netlink route socket on Linux and the route sysctl on macOS. It needs no resolver, because the broker looks up its names.
  • The network: no connection of its own. It accepts on its listener, reads and writes the connections it accepted and those that the broker hands it, and on Linux binds its netlink route socket, which reaches the kernel alone. It sends no UDP, and it listens on nothing.
  • Nothing else: no read of your home folder or of devvm's data, config or run folders, no Keychain, no unix socket but its own two descriptors, no Lima folder, no signal to another process, no tracing, and no fork or exec.

The floor fails open if it reads no addresses for the host, because hostAddrs then refuses none of them, so the child's check after it confines itself needs a read of the host's addresses that isn't empty, and a later read that fails keeps the last good one.

The protocol. The broker makes one unix stream socketpair, close-on-exec from the start (SOCK_CLOEXEC on Linux, and syscall.ForkLock held with CloseOnExec on macOS), so no program the broker runs, such as security, holds an end, and the child's end is its descriptor 3. Each message is a frame: a 4-byte big-endian length, then a JSON object of at most 2 MiB with its type, its id and its fields, which the reader decodes refusing unknown fields. Bytes, such as a file, a body or a header's value, cross as []byte, which JSON holds in base64, so encoding/json never changes bytes that aren't UTF-8 and a 1 MiB file takes about 1.4 MiB of a frame. Every read is a recvmsg with room for one descriptor, and a read whose control data was cut short (MSG_CTRUNC) breaks the rules. Each read asks for no more than the bytes left in its frame, and the writer sends each frame whole under one lock, with its descriptor on the frame's first bytes, so a descriptor always arrives with the frame it belongs to. The broker's first frame is start, with the protocol's version, 1, the SHA-256 of the broker's own executable, which the broker reads first thing as it starts, and everything the child runs with, as the start below says. The child answers ready, with the same version, the SHA-256 of its own executable, which it reads before it confines itself on Linux and through its profile on macOS, the address it serves and how it's confined, or failed, with why. After that only the child asks, and the broker answers each request with a frame of the same id, in any order:

Request What the child sends What the broker answers
value a binding's kind, agent and name (valueKey) the value and when the broker looked it up, or an error
file a watched file's number in the start's list the file's bytes and the stamp it read, or that it's missing or refused, and why
link a request's host and port a connection to the link's socket, as the frame's one descriptor (SCM_RIGHTS), or an error
token a captured request's host, its clean path, method and query, its headers, at most 64 KiB, and its body, at most 64 KiB (captureRequestMax) the reply the VM gets, its status and its few headers, and the agent whose login it was, or an error
lookup a host name, absolute, with its one trailing dot its addresses, or an error
dial an address and a port, or which company proxy, https or http a TCP connection to it, as the frame's one descriptor, or an error
cancel the ID of a lookup or a dial it gave up on, as the frame's own nothing of its own: that request ends with an error

Only a lookup and a dial can be cancelled, with a cancel frame of the request's ID, below. A value's lookup and a token exchange run to their 20 seconds whatever happens to the VM's request, so the broker keeps a value it looked up for the next request. The child stops waiting for a reply once its request has ended, drops the reply when it comes, and holds the request's place under its type's cap until then, so it never has more under way than the broker allows, and it closes a link's or a dial's connection that it no longer wants. A reply that wouldn't fit in a frame is sent as an error instead, so no request waits for one that never comes, and the few headers a token's reply keeps are 1 KiB each at most. An error reaches the child as one of a few codes, not_found, refused, busy, too_long or failed, or for a lookup, no_such_host, timeout or temporary, which the child turns back into the resolver's error that its block's reason and its second try need, and the broker's own log keeps its text, which can name a lookup's or an endpoint's details. The broker's start frame has the start's deadline to be written, so a child that never reads can't hold the broker either.

Bounds, and failing closed. The broker serves one value at a time, as the proxy's lookups go one at a time, at most 8 tokens at once, as captureReads allows, 4 files, 256 links, which is the link session's own cap on a client's connections, 256 lookups and 1024 dials, as many as the child's tunnels at once (maxConnects). It answers a request past its cap with an error, which a child that keeps the same caps never gets, because the broker gives a request's place back as its reply starts to go, before the child can send the next. A reply that waits for the socket keeps its place, so a child that stops reading holds no more of the broker's answers than the caps. It keeps each value it looked up for as long as the proxy keeps it, so a child that asks again and again makes the broker look a binding up at most once in 30 seconds or 5 minutes, and on macOS run security that often. It keeps a failed lookup for 5 seconds, so a child can't make it run security or try a refresh back to back. The child keeps a value only until the broker's lookup is that old, so no value is kept longer than the broker keeps it. The broker keeps its own watch on the bindings file, the links' list and the policy files, as the proxy does (watched), looking at the first two on every value, link and token request, and at the policy files on every dial, whatever the child asks, so a binding or a link that devvm takes away is gone for the next request, and a change to the bindings file drops the broker's values and its failed lookups, as it drops the proxy's values, so a secret set right after a failure goes in at the next request. Some frames end the pair: one over 2 MiB, one that isn't JSON or has a type or a field that the version doesn't know, a second start, a reply to no request, a frame that carries a descriptor from the child, and a ready whose version or executable's SHA-256 differs. The child takes a descriptor only with a link or dial reply that says it carries one, and closes any other. For each, the broker stops the child, logs the rule the frame broke but never its bytes, and exits, and the VM has no network until devvm starts its proxy again. A request that the broker refuses, such as one for a binding that isn't in the file, gets an error instead, which the child handles as it handles a failed lookup. No value goes in, a capture gets 502, a link gets link_refused, a name that the broker can't look up gets the block of any name that doesn't resolve, and a connection that the broker refuses or can't open gets connect failed.

Naming nothing but its own VM's. Every request names something in the broker's own config, which is one VM's, so the child can't reach another VM's binding, any other secret or any file:

  • value: the broker finds the key in its own read of the bindings file that its config names, and looks the value up with its own copy of that binding, never the child's, so the binding's id and its methods are checked as for any binding (fits). A key that the file doesn't hold now gets an error, the company proxy's secret's included, which no binding names.
  • file: a number in the broker's list, which is the bindings file, the links' list and the policy files in the config's order, so no path crosses the socket.
  • link: the broker finds the host and port in its own read of the links' list (links.find), and connects to LinkSocket of its run folder, its VM, the entry's address and its port, only for an address in 127.77.0.0/16, trying a few times for a full backlog as the proxy does.
  • token: the broker finds the endpoints in its own captures that the host, the path and the method match, which gives the agents, refuses a request that matches none, and puts in the VM's name itself (Exchange.VM).
  • lookup: the broker takes only a host name in the proxy's own form (NormHost, HostOK), with its trailing dot, and no address, and looks it up as the proxy does, so a child learns no more than it could ask this machine's resolver.
  • dial: the broker connects to an address only once its own read of the VM's policy files and its own read of the host's addresses allow it, as the floor does, and to a company proxy only at the address of its own config.

Captures in the broker. For a captured request, the child does what the proxy does for any request up to the request's body. It judges the host and the request by the VM's rules, intercepts it and reads the body. Then it sends the request in token. The broker runs IO.Capture's Request, and sends the request to the endpoint's host from its own config, on port 443, through the company proxy when there is one, and trusting the system's roots and upstream_cas, as an OAuth refresh does. It reads the reply, runs Response and returns what the VM gets. The broker does what the proxy does with a captured request. It drops a 1xx, refuses an upgrade, leaves gzip to Go's transport, sends the VM's headers on without the hop-by-hop ones and Proxy-Authorization, takes a successful reply of at most 1 MiB and returns only keepHeaders' headers with it. It returns an error reply as it is, up to the same 1 MiB, rather than streaming it through, and gives one that's longer a 502. An error reply to a request whose body Request changed comes back as its OAuth error code alone (errorReply). The child logs the login event, naming the agent that the broker returned, and guard stays in the child, for the host's other replies. So the real tokens in an endpoint's reply, a new login's refresh token among them, and the id_token that Request puts into Codex's API-key exchange, never enter the child, and a child can't save tokens that the endpoint didn't issue.

Connections through the broker. The child judges each request as the proxy does, by the VM's rules, then the floor, which looks the name up and keeps the addresses that aren't internal or that a rule names. It asks the broker for each lookup, and then for a connection to each address it kept, one at a time, as the proxy dials them, or for a connection to the company proxy when one applies. The broker answers a dial for an address only when that address passes its own copy of the floor's check: no deny names it, and it's neither internal nor this machine's own, or a rule names it, by the broker's own read of the VM's built-in policies, its policy files, which it looks at on every dial, and the host's addresses, which it reads every 30 seconds, or the config says the VM is open. Then it connects over TCP, with the proxy's 15-second timeout, and hands the connection to the child as it hands a link's. So a child that a VM takes over connects to this machine's loopback, its own addresses and the private and link-local ranges only where a rule names the address, as the VM does, and it reaches the internet as the VM does. Two ways stay open, as they do for the VM: a company proxy, which the child speaks to with its password and which reaches whatever it reaches, this machine's loopback included when it runs on this machine, and a host on this machine's network whose address is public, such as a neighbour's global IPv6 address, which the floor counts as the internet.

  • A rule applies from the next connection. devvm network allow 127.0.0.1:5432 changes the policy file, the child sees its new stamp at the next request and asks for it, and the broker's own look at the file at the dial that follows sees it too. A rule taken away is gone for the broker's next dial as well, so a connection opened as a rule goes may fail, but never one that no rule allowed. The broker also looks at its own copy of the policy files at each file request for one of them, so its copy is never older than what it gave the child, but in the moment between the two looks. A rule for a name, such as localhost:5432, judges the name, and the floor needs a rule for the address too, such as 127.0.0.1:5432.
  • Which addresses: the broker judges each address as the floor does, unmapped, so an IPv4-mapped ::ffff:127.0.0.1 is 127.0.0.1, a NAT64 or 6to4 address is judged by the IPv4 address in it, ::1 and every address in 127.0.0.0/8 are loopback, and 0.0.0.0 and ::, which reach this machine's own services, are internal. It refuses an address with a zone, such as fe80::1%en0, which no rule can name, and a port outside 1 to 65535.
  • The company proxy: the child asks for https's or http's, and the broker connects to the address in its own config, by name, through the system's resolver, so a company proxy on this machine's loopback, such as a VPN client's, works, and the child can name no other address that way. The child still speaks CONNECT and plain HTTP to it, with its password, so the company proxy, not the broker, decides where those go.
  • The host's addresses: the broker reads them before it starts the child, and a read that fails or finds none fails the start, as the child's own check does, and a later read that fails keeps the last good one.
  • A request given up on: the child sends cancel with a lookup's or a dial's ID once the VM's request has ended, or a lookup's own deadline has passed, and the broker ends that lookup or connection, answers it with an error and frees its place, so slots that a VM's abandoned requests held don't fill the caps. A cancel gets no answer of its own, and one for an ID that isn't under way is dropped.
  • Lookups: the broker looks each name up through this machine's resolver, as the proxy does, so the child sends no DNS, and a resolver on this machine's loopback, such as systemd-resolved's 127.0.0.53 or a dnsmasq on 127.0.0.1, answers the broker. The child sends no UDP at all.
  • What doesn't change: the open tier's broker allows every address, as the floor does there. Transparent mode's connections, the Nix cache's fetches and the connections that put a value in go through the same dial. A link's connection is the broker's already, through its link request, and a capture's token request is the broker's own.
  • The sandboxes: on macOS the child's profile allows no network out at all, neither TCP nor UDP to any address, nor any unix socket, and Seatbelt checks every connect and every send with an address, while writes on a connection it accepted or was handed need no rule. On Linux, Landlock from ABI 4 refuses every TCP connect, and from ABI 10 every UDP bind and send, as the child's ruleset handles those rights and allows no port, and the seccomp filter refuses the child every socket but a netlink route socket, connect and socketpair outright, and MSG_FASTOPEN on sendto, sendmsg and sendmmsg, because TCP Fast Open connects a socket as it sends, and the listener, once a shutdown has closed it, is a TCP socket that could connect again. A filter reads only a call's arguments, never what they point to, and these checks need nothing else, so no other thread of the child can change what the filter checked.
  • Without the sandbox: a child that runs unconfined, or on a Linux kernel without seccomp filters, still asks the broker for every connection, but nothing stops a child that a VM took over from connecting itself, so its confinement says so (partial with no-seccomp, or none), and devvm doctor warns of it.

The Secret type on the socket. The frames are the third kind of file that holds values, after proxy.json and vm.json, so they get wire types of their own, as those files have (where secret values live). The start's password, the company proxy's password, the CAs' keys, and a value or token reply's value each cross as a string in a wire struct. Only the protocol's encoder fills that string, with Reveal and its //nolint:forbidigo on the line, and the decoder makes it a redact.Secret at once. Nothing logs a frame, and an error names only its type and the rule it broke. The company proxy's URLs from the environment cross as strings, as they are in proxy.json.

The start:

  1. devvm starts the broker as it starts the proxy, devvm _proxy -config FILE, detached, with its output in proxy.log, and waits up to 5 seconds for its status file.
  2. The broker reads the config, looks up the company proxy's password when the config names the proxy secret, reads the CAs' files, listens on the VM's proxy port, starts the agent's relay and the keeping of the backend's logs, and makes the socketpair.
  3. It starts the child, devvm's own binary with the arguments _proxy-child -for FILE, through daemon.Spawn, which gains the descriptors to pass (ExtraFiles) and an environment that its caller chooses. On Linux it runs /proc/self/exe, which is its own file even once an upgrade has replaced the file at its path. -for names the config only so the child can be told apart, and the child never opens it. Once the child runs, the broker closes its own copies of the listener and of the child's end of the socketpair.
  4. It sends start, which also says how the broker started the child, under Seatbelt or unconfined and why. The child checks the executable's SHA-256 against its own, makes its server from the start, opens its logs and the Nix cache, loads the system's roots and its time zone, checks that it can read the host's addresses, confines itself where its platform does that in the process, checks that the confinement holds by opening its broker's config, which it must be refused, and answers ready with how it's confined.
  5. Within 4 seconds of its own start, the broker writes the child's pid file, run/proxy-child.pid, and how it's confined, run/proxy.confined, which devvm doctor reads only while the broker runs, and which Proxy.Stop removes with the pid file, and then the status file with its own pid and the address (daemon.Ready), which is what devvm waits for. The status keeps the address alone, which devvm compares with the config's. When the child answers failed, or doesn't answer in time, the broker stops it and exits with the reason in proxy.log, so devvm reports proxy_start_failed.

The end. The two end together, and neither starts the other again:

  • The lifeline is the broker's. When the VM's hostagent ends, the broker closes the socket, and the child closes its listener first, then closes its connections, waits up to 5 seconds for its handlers as the proxy does, and exits. The broker waits for it, and kills it a second past that, then removes the agent's socket and exits.
  • devvm stop's SIGTERM reaches the broker through its pid file. The broker sends the child SIGTERM through its daemon.Handle, which ends it at once, as SIGTERM ends the proxy, and kills it if it hasn't ended within a second, inside the 2 seconds that devvm waits before its own SIGKILL. So a stop ends both, and the next start finds the port free.
  • A broker that ends any other way, SIGKILL included, leaves the socket closed, because nothing else holds its end, and the child reads its end, closes its listener and exits. The child reads the socket for as long as it runs, so this needs no signal. A child that a VM has taken over can ignore the socket's end, so on Linux the broker also starts the child with PR_SET_PDEATHSIG set to SIGKILL, from a goroutine that holds its thread (runtime.LockOSThread) until the child is reaped, because Linux ties that signal to the thread that started the child rather than its process.
  • A child that ends, crashed or killed, ends the broker, which logs how it ended and removes the agent's socket. Neither starts the other again, so a child that fails at once can't loop, and the VM has no network until devvm's next command starts its proxy again, as after a proxy's crash.

Finding them. To devvm, the broker is the proxy. Its pid file, its status file and its arguments, _proxy -config FILE, which daemon.Proc matches, stay as they are. The broker signals the child through the daemon.Handle that Spawn returned, which reaps it. devvm also finds the child as a daemon.Proc, by run/proxy-child.pid and its arguments, _proxy-child -for and the VM's config, so Proxy.Stop and devvm gc --orphans stop a child that outlived its broker, checking its arguments before each signal as they do for every background process. The broker writes that pid file only once the child said it's ready, after sandbox-exec has run it, so the arguments are already the child's own. Its arguments don't contain _proxy -config, so every pattern that finds a VM's proxy finds only the broker. The testscript runner's pkill -f of _proxy -config in the sandbox ends the brokers and so their children, and the runner also ends _proxy-child -for in the sandbox, in case a test killed a broker in a way that kept its child. The end-to-end checks find the child by [_]proxy-child -for and the config, and a check that a proxy is gone checks both.

The build proxy is the same broker and child, which backend.ProxyStarter starts and stops through its daemon.Handle, and which ends the child as devvm stop does. Its broker has no secrets, captures, links, agent or backend logs to keep, so it only looks up the proxy secret when config.toml's company proxy names one, and follows the build VM's lifeline. Its child writes events.jsonl and proxy.log in the build proxy's logs/ folder and reads nothing else, so the end-to-end checks that look for a build's logs look there. One way for both keeps one code path, and a build runs code that devvm trusts no more than a VM's.

Upgrades. The config doesn't change. proxy.json keeps its fields and ConfigVersion stays 1, so every release's frozen configs still read and write back byte for byte (TestV010ProxyConfigs), and the implementation starts a broker and its child on each of them. A proxy that a devvm before the split started runs as one process until the VM's next launch, which starts it again because its config's devvm_sha256 differs, as every upgrade does, so a running VM keeps its network through the upgrade. An older devvm that stops a VM's proxy after a downgrade finds the broker by the same pid file and arguments, and the child ends with it.

Confining the child. Two follow-ups hold the child to what it needs, as listed above, and where a platform can't, the child runs unconfined, says so in ready, the broker logs a warning and writes it to run/proxy.confined, and devvm doctor warns of it for each running VM. The child says how it's confined in one line of words from a fixed set, its level, full, partial or none, then what confines it, and for a child that isn't fully confined, why (proxy.Confinement, in internal/proxy/confine.go), which the broker refuses unless it parses, so devvm never prints what a child wrote (the child's sandbox has the table). Both follow-ups share it, the check that the confinement holds (checkConfined, which opens the broker's config) and the hook where the child confines itself in the process (confineSelf, by platform), which on Linux calls internal/landlock and turns what it got into the line (landlockConfinement), and which confineChild bounds to 2 seconds (confineWait). The child gets the hook through IO's confine, which ChildMain sets, so a test's child in the test's own process confines nothing, and a confinement that fails, rather than one the kernel can't give, fails the start. Each follow-up's start fits in the broker's 4 seconds, so a sandbox that refuses what the child needs fails the start rather than hang it, and on macOS a broker and its child under Seatbelt are ready in about 40 ms, or 350 ms for the first start of a binary that macOS hasn't run before.

  • macOS, with Seatbelt: the broker starts the child through /usr/bin/sandbox-exec -p PROFILE, with a profile that denies everything by default, so the child is confined from its first instruction, and the profile is an argument, never a file on disk. internal/seatbelt owns it (ChildProfile), with the quoting and the real paths that Lima's hostagent's profile uses too, and the broker gets it through proxy.IO.Seatbelt, which only devvm _proxy on macOS sets, because internal/proxy imports the standard library alone. The profile imports the system's dyld-support.sb, the rules that Apple keeps for starting a program, so dyld and the system's libraries in their cryptexes load as Apple changes them. It allows exec and reading of devvm's binary by its real path alone, which sandbox-exec needs to run it and the child needs for its SHA-256, and the metadata of its folder, which CoreFoundation looks at for the program's bundle before Security checks a certificate. It allows reading /usr/lib and /System/Library and the time zone, and the metadata of the links on the way, /etc, /var and /tmp, because a sandboxed lookup through a link needs it. It allows reading and writing in its folders, making only regular files there (vnode-type REGULAR-FILE), no hard link anywhere (file-link), no folder removed, and no change to a file's flags, ACL, owner, set-id bits or extended attributes, so the broker makes the Nix cache's folders before the child starts. It allows file-read-metadata alone on the watched files, on their targets when they're links, and on every link on the way to any of its files and folders (seatbelt.Links), the mach services com.apple.trustd and com.apple.trustd.agent, reading sysctl but its kern.proc names, and signals to itself. It allows no network out at all, to any address or unix socket, and accepting on its listener, and reading and writing the connections it accepted and those that the broker handed it, need no rule. It allows no bind, no fork, no look at another process (process-info, the process list), and none of the Keychain's services. The list of what the child needs came from the sandbox's own log of what it refused (log show --predicate 'eventMessage CONTAINS "devvm("'), and the profile leaves refused what the child does without: com.apple.logd, com.apple.system.notification_center, com.apple.system.opendirectoryd.libinfo, /Library/Preferences/com.apple.networkd.plist, /etc/passwd, /dev/fd, the interfaces' link addresses (net.link.addr), AF_SYSTEM sockets and the binds that the system's network code tries. crypto/x509's checks don't need com.apple.SecurityServer, which the profile never allows. A watched file whose link points elsewhere after the start gets its stat refused, which the child takes as a file to ask the broker for at every request (watched.get), so a change still applies to the next request. The broker starts the child again unconfined, within the same 4 seconds, only when sandbox-exec failed before devvm's code ran, which the child's end shows: it ended before it answered, with sandbox-exec's own exit status, 65 for a profile it refused or 71 for a program it couldn't run, or killed by SIGABRT or SIGKILL, as dyld aborts a program that the profile refuses what it needs to load, which the broker decides before its own stop of the child. A ready that names a sandbox the broker didn't start the child under breaks the protocol's rules (Confinement.fits). ChildProfile refuses a path that isn't absolute or that is the root, as resolved. A missing sandbox-exec starts it unconfined too. Anything else fails the start, so nothing a VM left in the child's folders can turn a confined start into an unconfined one.
  • Linux, with Landlock: the child sets no_new_privs on every thread and restricts itself (landlock_restrict_self, through syscall.AllThreadsSyscall, or with ABI 8's TSYNC where the kernel has it) before it reads a byte of the VM's, and the files it opened before then are its logs and the Nix cache. It keeps the rights above on its folders, to make regular files alone, binds and connects no TCP port (ABI 4), binds and sends no UDP (ABI 10), scopes abstract unix sockets and signals to itself (ABI 6), and connects to no named unix socket (ABI 9). Landlock's network rules match only ports, so they can refuse the child an address only by refusing it every connection, which is what the child needs, and the seccomp filter refuses the same on every kernel, TCP Fast Open included, which Landlock's check of connect doesn't see. It reads no file outside its folders, because it needs no resolver. The Nix cache renames a NAR's temporary file from its top folder into nar/, which Landlock allows only from ABI 2 (REFER), so the floor is ABI 2, unless the cache makes each temporary file in the folder that its file goes to. A child on a kernel below ABI 4 or 6 is partly confined, which it says in ready and devvm doctor reports. A kernel at ABI 6 or 7 without Landlock's erratum 2, which lets a process's threads signal each other across the domains each made in turn, would refuse the signals that syscall.AllThreadsSyscall sends each thread and hang the start, so there the child leaves signals unscoped and says so (landlock-signals). A kernel without Landlock, or at ABI 1, confines no files, and the child runs with the seccomp filter alone and says so (partial seccomp no-landlock), which devvm doctor warns of: the VM keeps its network rather than lose it on such a kernel. internal/landlock (Self) does all of it, with the standard library alone, behind its own build tags, as the proxy can't import internal/platform, and checks after confining that the child lists its folders and fails to list / and to read /etc/hosts.
  • Linux, with seccomp: no Landlock ABI can refuse the child an address, a kernel before ABI 9 can't refuse it a named unix socket, and one before ABI 4 can't refuse it a port, so the child also installs a seccomp filter on every thread (SECCOMP_FILTER_FLAG_TSYNC) that refuses socket for every family but a netlink route socket (AF_NETLINK with NETLINK_ROUTE), socketpair, connect, listen, MSG_FASTOPEN on sendto, sendmsg and sendmmsg, socketcall, and io_uring_setup, io_uring_enter and io_uring_register, whose operations would pass a filter of system calls. It kills the child for a system call of any architecture but its own, and on amd64 for the x32 numbers, so the 32-bit calls can't get around it. socketcall is a 32-bit call alone, so the check of the architecture is what refuses it. The filter also refuses ptrace, process_vm_readv, process_vm_writev and pidfd_getfd, which Landlock restricts to the child's own domain but nothing does on a kernel without it, and which would let the child read the memory, or take the descriptors, of another process of yours, such as an ssh master. Changed in review, it refuses what Landlock doesn't restrict at any ABI: a file's mode, owner, extended attributes and times changed by its path (chmod, fchmodat, fchmodat2, chown, lchown, fchownat, the six xattr calls, utime, utimes, futimesat, and utimensat with a path), truncate, which Landlock restricts only from ABI 3, the kernel's keyrings (add_key, request_key, keyctl), another process's limits and scheduling (prlimit64 on another pid, setpriority, ioprio_set and the four sched_set calls), watches that would tell it of files outside its folders (inotify_init, inotify_init1, inotify_add_watch, fanotify_init, fanotify_mark), and what the child never does: execve and execveat, fork, vfork and a clone that isn't a thread, a namespace (unshare, setns, a clone with a namespace's flag), bpf, userfaultfd and perf_event_open, with clone3 refused as ENOSYS, as its flags are behind a pointer. The calls on a descriptor the child opened stay (fchmod, fchown, ftruncate, utimensat without a path), and the Nix cache marks a file used through its descriptor. The review's own check: the filter's interpreter, and TestSelf on Fedora 43 (ABI 11), Ubuntu 26.04 (ABI 8) and Debian 13 (ABI 6), where Go's runtime still starts new threads under it. The child needs none of these, as the broker looks up its names and opens its connections. Once confined, the child checks that it can't make a unix or an IPv4 socket, nor connect or send with MSG_FASTOPEN on any socket, which the filter refuses before the kernel looks at the descriptor. The filter is classic BPF written out by hand (internal/landlock's filter), a unit test runs its bytes in an interpreter of its own for amd64 and arm64, and a test's child confines itself under it on the Linux test hosts and in CI's nocgo job (TestSelf). A kernel without seccomp leaves the filter out, and the child says so (no-seccomp).

Performance. The path of the VM's requests is the child's alone: no request, tunnel or byte in them crosses the socket. The child asks the broker only for a value that its cache doesn't hold, at most once for each binding in 30 seconds or 5 minutes, for a watched file after it changed, for each connection to a link, which is a new connection for each plain HTTP request to a link, for each token request, and for each lookup and each connection that a request opens upstream. Those last two add a round trip on the socketpair to each lookup and each connection, a JSON frame each way and a descriptor, which is small beside a lookup's or a TCP handshake's own time, and a kept-alive connection or a tunnel costs it once. A start costs one more process and its exec, and each VM's proxy takes a second Go process's memory: on an Apple silicon Mac, an idle broker and its child each take about 19 MB resident.

Options weighed:

  • Values handed to the child at the start: ruled out, above.
  • The child reading the changing files itself: it would need to read the VM's run folder and devvm's config folder. Landlock keeps a rule for a file on that file itself, so a file that devvm replaces whole would lose it, and only a rule on the folder would hold. Asking the broker after a change keeps the check on each request without a hop.
  • The broker sending changes to the child as they happen: the broker would have to watch each file, and the standard library can only poll, so a change would wait for the next poll, while with the stamp's check it applies to the next request.
  • The broker speaking to the company proxy and handing over the tunnel: that would keep the company proxy's password out of the child for tunnels, but the company proxy takes it with each plain HTTP request, which would put the broker on that path, parsing what the child sends. So the broker opens the TCP connection to the company proxy alone, and the child speaks to it.
  • Seatbelt refusing localhost:* alone, with the broker connecting to loopback only: Seatbelt's network filter names a host only as * or localhost, so the child would still reach this machine's own LAN addresses, where a server that listens on every address answers, such as Docker's published ports, and the LAN, and whether localhost covers all of 127.0.0.0/8, 0.0.0.0 and the mapped forms is Apple's to say. A profile that allows nothing out, with the broker judging every address, holds for all of them, and keeps one way for both systems.
  • seccomp's user notification on Linux, with the broker as the supervisor of connect, sendto and sendmsg: the broker would read the address from the child's memory, which another thread of the child can change after the read, so it could never let the call go on, and would make every connection itself and put it in the child (SECCOMP_IOCTL_NOTIF_ADDFD), which costs what the dial request does. Reading the child's memory needs ptrace's access, which Yama's ptrace_scope 2 or 3 refuses, the broker couldn't tell a TCP socket from a UDP one without taking it (pidfd_getfd, the same access), the listener's descriptor would have to come from the child, which the protocol refuses, and ADDFD needs Linux 5.9. The filter on arguments works on every kernel with seccomp filters, with no access to the child's memory.
  • A network namespace for the child with nothing but its own loopback, with the broker dialing every connection: it costs what the dial request does, it needs an unprivileged user namespace, which Ubuntu's AppArmor restricts from 24.04 and other systems turn off, and which the child's filter refuses (unshare), so the broker would have to make it. The filter refuses the same connections without a namespace.
  • The broker signing the interception's certificates: the child already sees every byte of its VM's traffic, so the VM's CA key gives it nothing more, and no other VM trusts that CA.
  • The agent's relay in the child, through a connection from the broker: that connection would carry whatever the child sends, so the broker would have to filter it, which is the relay's whole job.
  • A process each for the relay, the logs and the lookups: each would be unconfined, as the broker is, so more processes would add lifecycles but no boundary.

Threat check (the security-audit skill, guidance mode, with its local IPC, protocols, data isolation and resource exhaustion companions, on this design, and an independent review of it against today's code, whose findings are folded in). Leads, each ruled out by the design, changed in review, or listed:

  • The child naming another VM's binding, another secret or a file: ruled out. Each request is a key, a number, a host and port, or an endpoint that the broker resolves in its own config and its own reads of its VM's files, and no path, VM name or binding crosses the socket.
  • The values bound to its VM: listed. A child that a VM takes over can ask for every value that its VM's bindings file names, such as a secret of yours, a GitHub token or an agent's access token, and use it anywhere the child reaches, while the VM itself holds only placeholders. It gets no other VM's value, no value that isn't bound to its VM, and no login's refresh token.
  • The company proxy's password: listed. The child holds it, as the proxy does, because the company proxy takes it with each plain HTTP request, so a child that a VM takes over can send it anywhere it reaches.
  • Its VM's password and CAs: listed. The child holds its VM's password and both CAs' keys, which only that VM trusts, and it already sees all of that VM's traffic.
  • A forged token reply: ruled out. The broker gets the endpoint's reply itself, over TLS that it checks, from the host in its own config, so a child can't save tokens that the endpoint didn't issue. Listed: a real exchange of a code that the VM got for an account of its own saves that account's login for every VM with the agent, as a VM can do without the proxy taken over (logins made in a VM).
  • A binding or link that devvm took away: changed in review. The broker read the bindings file and the links' list only when the child asked for them, which a child that a VM takes over never does, so a secret unbound or deleted, or a link removed, stayed within its reach. The broker now looks at both on every request that uses them, and drops its values when the bindings file changes.
  • Flooding the broker: listed. Frames have a cap, each request type has a cap on how many run at once, the broker's cache holds a lookup to once a binding in 30 seconds or 5 minutes, a failed lookup is kept for 5 seconds (changed in review, as a failure wasn't kept, so a child could make the broker run security or try a refresh back to back), and a frame that breaks a rule ends the pair. A child can still run up to 8 token exchanges at once with your login, one after another, as a VM can, and make the broker write a line in proxy.log for each connection it refuses or can't open, which pushes older lines out of the log's rotation, as the child's own lines can.
  • The broker's own parsing: listed. The broker still reads bytes that a VM chooses, in four bounded places: the child's frames, at most 2 MiB each, which encoding/json decodes, the agent's relay's messages, at most 256 KiB each, read by their length and type alone, the backend's logs, which it scans for passwords, and a token request and its reply, at most 64 KiB and 1 MiB, which internal/agentlogin parses as the proxy's process does.
  • The network: changed, and listed. The rules and the floor were the child's own code, and the sandboxes allowed it TCP and UDP to any address, so a child that a VM took over reached this machine's loopback, its own LAN addresses and the LAN, such as your dev servers, Docker's published ports and other VMs' proxies, whatever the rules said. A profile can't follow a rule that applies from the next connection, and Landlock and a seccomp filter can't refuse an address, so the sandboxes now refuse the child every connection of its own, and the broker, which judges each address with its own read of the policy files and the host's addresses, opens each one for it. Listed: the child still reaches any public address on the internet, as an open VM's proxy does, over TCP alone, and an address that a rule names. Changed in review, the note no longer says the LAN is out of reach: the floor counts a host on this machine's network whose address is public as the internet, such as a printer's or a NAS's global IPv6 address on most networks with IPv6, or any host on a network of public IPv4 addresses, so the child, as the VM, reaches those, and the floor counting this machine's own networks as internal is a change of its own, for the VM as much as the child. The child reaches no unix socket, so neither the ssh masters' control sockets, nor docker.sock, nor an SSH agent.
  • The dial and lookup requests: ruled out, and listed. A dial names an address and a port, which the broker judges as the floor does before it connects, or a company proxy of its own config, and nothing else, so a child can't make the broker connect where the floor refuses, nor reach a unix socket, nor send UDP through it. A lookup takes a host name alone, and the broker returns its addresses, which the child could ask this machine's resolver for, split DNS, /etc/hosts and .local names included. Listed: a child can make the broker look up any name, which carries data out in the name as a VM's own lookups through the proxy can, and hold 256 lookups and 1024 connections under way at once, each for at most its timeout, as it could hold them itself before. Changed in review: a lookup or a connection that the child gave up on held its place until its timeout, so a VM whose requests went away while DNS or IPv6 hung could fill the caps, and now the child cancels it. The broker logged a line for each failed lookup and connection, which a VM that asks for one refused address after another drives, and now it logs at most 20 a minute, then one that says it stops, as the child does for the lookups it gives up on.
  • The connections the child holds: changed in review, and listed. The caps count a connection only while it opens, and Go raises a process's limit on open files to its hard limit, so a child could keep every connection the broker handed it and use up this machine's ports for outgoing connections. The child now lowers its own limit, soft and hard, to 8448 files before it confines itself, four times maxConns and room for its logs and the Nix cache, so it holds at most that many, which a process can't raise again. Listed: that lowers the risk but doesn't remove it, as macOS gives out its outgoing ports from one range of 16,384 for every process, so a few children that VMs took over, or one on a busy machine, could still use them up.
  • A connection connected again: ruled out. A child holds connected TCP sockets, those it accepted and those the broker handed it, and its listener. On Linux, the filter refuses connect, which could otherwise disconnect a TCP socket (AF_UNSPEC) and connect it elsewhere, and MSG_FASTOPEN, which would connect the listener once a shutdown has closed it. On macOS, Seatbelt checks every connect and every sendto with an address against the profile, which allows none.
  • A rule as it changes: ruled out, and listed. The child and the broker each read the policy files when their stamp changes, and the broker looks at them at each dial, after the child's own look, so a rule that the child saw is one the broker sees. A rule taken away as a connection opens makes that connection fail, which fails closed. Changed in review: the broker's copy and what it gave the child were two reads, and a file that keeps its last rules when it can't be read, as a policy file does, could leave the broker's copy older than the child's, with a rule the child no longer had, so the broker now looks at its copy at each file request for a policy file too. Listed: a file that changes and can't be read between those two looks, which only you can make happen, still leaves the broker's copy a version behind until the file reads again.
  • The company proxy: listed. A child that a VM takes over can connect to the company proxy of its config, wherever it is, loopback included, and send it what it likes with the password it holds, as the proxy does: CONNECT and plain HTTP to any host and port, which the company proxy, not the floor, decides on, so it reaches whatever the company proxy reaches, this machine's loopback included when the company proxy runs here. The broker speaking CONNECT itself would keep tunnels to the floor, but plain HTTP takes the password with each request, so the child would still hold it and reach the same through http's company proxy.
  • Other processes' details: changed in review. The first profile allowed every sysctl and process-info, so a child could list your processes and read their paths and arguments, a token on a command line among them. The profile now denies process-info for any process but the child, the process list, and sysctl's kern.proc names. macOS answers kern.procargs2, a process's arguments, to a sandboxed process only for the processes of its own process group, and the child is alone in a session of its own (daemon.Spawn's Setsid), so it's refused every other process's, its broker's included, which TestChildProfileConfines checks.
  • Changing the shared folders' files: changed in review. The first profile allowed every write in the child's folders, so a child could set a flag such as uchg on a file in the shared Nix cache, or remove its nar/ folder, and stop every VM's cache and devvm gc's trim from changing it. The profile now refuses changing a file's flags, ACL, owner, set-id bits and extended attributes, and removing a folder, and leaves the mode and times, which the child changes. A child can still delete or rewrite the cache's files, as the disk's row says.
  • The seccomp filter's way around: changed in review. A filter of socket alone lets a child reach a unix socket through the 32-bit system calls (socketcall, or the x32 numbers) or through io_uring, which doesn't pass the filter, and before ABI 9 that filter is all that keeps the ssh masters' control sockets from it. The filter now kills any other architecture's calls and refuses socketcall and io_uring, on every thread.
  • The folders the child writes: changed in review. A child that a VM takes over could leave a link or a FIFO in its logs folder or the Nix cache, and devvm opened proxy.log again by its path at the next start, copied and emptied it by its path at each rotation, opened links.log and ports.log, read the event log, and trimmed the cache through nar/, each following the link. That would have written the VM's bytes into a file of yours, copied one into the log the child reads, emptied or deleted yours, or hung a command on a FIFO. The child now makes regular files alone, and devvm opens everything in those folders through internal/safefile or an os.Root, never following a link, and rotates proxy.log through its descriptor.
  • The disk: listed. Only the child's own code bounds its logs and the shared Nix cache, so a child that a VM takes over can fill the disk, write what it likes into its VM's logs, which devvm network log and devvm network lock read, replace links.log and ports.log with files of its own, so the link session's report after a start can show warnings it forged or miss real ones, and write what it likes into the cache. Each VM's Nix checks a cached NAR against cache.nixos.org's signature and its NarHash, so the other VMs fetch such a NAR again rather than trust it.
  • The Nix cache's lock and its names: changed in review, and listed. A child that held .lock forever would have hung every other VM's /nix/ requests and devvm gc's trim, so each takes the lock with a deadline of a few seconds, trying it without blocking, and past it answers 404 or skips the trim and says so. A child can still slow the cache down by holding the lock, and list the store paths that other VMs fetched.
  • The logs' locks: changed in review, and listed. The broker and its child share proxy.log's lock, and the child and devvm _links the event log's, so a child that held one for ever would have stopped the broker at its next line, and the broker logged before it closed the socket when the hostagent ended, so the pair would have outlived the VM. Now the broker closes the socket and starts its kill's timer before it logs anything, and every writer tries each log's lock without blocking for at most 200 ms, then writes its line without the lock or skips the rotation. A child can still make each of the broker's lines wait that long, and make a rotation lose the lines written as it copies.
  • A log made huge: changed in review, and listed. A rotation of proxy.log read the whole file into memory, so a child that made it huge, or sparse at a terabyte, could have made the broker run out of memory and write as much. Now a rotation copies at most the last twice its limit, 20 MiB, from a line's start, streamed into its copy. A child can still fill the disk, as the disk's row says.
  • What stat shows: listed. Landlock doesn't restrict stat, so a child that a VM takes over on Linux learns whether any file of yours exists, its size and when it changed, though not what it holds. Changed: it read every file below /etc that you can, which its resolver needed, and now that the broker looks up its names, it reads none. On macOS the profile refuses stat outside the child's files, but a refused path answers EPERM and a missing one ENOENT, so a child there learns whether a path exists, though nothing else of it.
  • The services the profile allows on macOS: listed, and changed. A child that a VM takes over can ask trustd to check certificates, which reads your trust settings, and that holds no secret of yours and isn't the Keychain. trustd can fetch a missing issuer's certificate or an OCSP answer from the URL in a certificate, from its own unconfined process, which a review raised as a way to send a request to loopback or the LAN. Checked: a leaf whose issuer was missing and whose issuer, OCSP and CRL URLs named a server on this machine's loopback or its LAN address made trustd fetch nothing, through Go's verifier under the profile and without it, and through security verify-cert, which allows network fetches, with revocation required or not, on macOS 27. Listed: when it fetches is Apple's to change, and the worst it could do is a request, whose answer the child never sees, to loopback or the LAN. The profile allowed mDNSResponder's socket for the resolver, so a child could browse the local network's Bonjour services, announce services of its own there, and register any .local record it liked (DNSServiceRegisterRecord), and now that the broker looks up its names, the profile allows no unix socket. com.apple.trustd.agent also takes changes to your trust settings, which macOS asks your password for through its authorization services (com.apple.authd), and the profile allows neither those nor com.apple.SecurityServer, so a child can't trust a CA of its own. devvm's tests didn't try such a change.
  • A confined start made unconfined: ruled out, and changed in review. The broker starts the child again unconfined only for a failure of sandbox-exec itself, an exit status of its own or SIGABRT or SIGKILL before the child answered, which comes before devvm's code runs and reads nothing of a VM's, so a child that a VM took over, or what it left in its folders, can't make the next start unconfined. The broker counted any signal, after its own stop of a child that hadn't answered in time, so a child that hung, which its stop then ended with SIGTERM, counted as the sandbox's failure. It now decides before its stop, only for a child that had already ended, and only for those two signals. Listed: a program of yours that kills the child in that moment makes the start unconfined, which the proxy's log and devvm doctor say. A child that fails after that, such as on a planted file, or that hangs, fails the start, which leaves the VM without a network until its next start, as before.
  • A child that claims more: changed in review. The broker took any confinement the child's ready named, so a child could say full seatbelt when the broker had started it unconfined. The broker now refuses a ready that names a sandbox it didn't start the child under, or another than the one it did (Confinement.fits), which ends the pair.
  • Other processes: ruled out where the child is confined. Landlock scopes signals to the child (ABI 6) and lets it trace only processes in its own domain, and the profile allows signals only to itself. Listed: on a Linux kernel before ABI 6, or at ABI 6 or 7 without erratum 2, a child that a VM takes over can signal any process of yours, which devvm doctor warns of. Changed in review: Landlock's scope of signals doesn't cover a process's limits or scheduling, and a review killed another process from a fully confined child on ABI 8 by setting its RLIMIT_CPU to 1 with prlimit64, so the seccomp filter refuses prlimit64 on any pid but the child's own (0), and setpriority, ioprio_set, sched_setaffinity, sched_setscheduler, sched_setparam and sched_setattr outright. The seccomp filter refuses ptrace, process_vm_readv, process_vm_writev and pidfd_getfd on every kernel, but on a kernel without Landlock the child can still open /proc/<pid>/mem and /proc/<pid>/fd/ of another process of yours, unless the kernel's Yama restricts tracing (ptrace_scope 1 or more, Ubuntu's default), and so read its memory and its files. Changed in review: the broker sets itself undumpable (PR_SET_DUMPABLE 0), so its own memory and descriptors, which hold the VM's secrets, are root's alone there.
  • A port of another VM's: changed in review, and ruled out where the seccomp filter or Seatbelt holds. Before ABI 4, Landlock can't refuse the child a port, so a child could bind another VM's proxy port while that proxy starts again, and take that VM's password from its requests. The seccomp filter refuses listen, and now every new socket but a netlink route socket, so the child has no socket to bind, as the ones it holds are bound already, and the profile refuses a bind on macOS. Listed: without either, the child can still bind such a port, so that VM's proxy fails to start until it's free again.
  • No confinement, or part of it: listed. Where Landlock or Seatbelt isn't there, the child runs with the broker's access, and the split then only keeps the lookups, the captures, the relay and the logs' keeping out of the code that reads the VM's network. Without the seccomp filter, or on macOS without Seatbelt, a child that a VM took over can also connect anywhere itself, loopback included. A kernel below ABI 4 or 6 confines the child in part, which ready, run/proxy.confined and devvm doctor say. Changed in review: ABI 6, 7 and 8 with the seccomp filter and scoped signals count as full, as the filter refuses every unix socket that ABI 9 would refuse by path, and every connection and datagram of the child's own, which ABI 10 would refuse only for UDP, so doctor warns of nothing that a user could close. On macOS, sandbox-exec is deprecated, and if macOS drops it, or it fails to start the child, the child runs unconfined, and the proxy's log and devvm doctor say so, so the VM keeps its network.
  • The floor without the host's addresses: changed in review. A confinement that refused the read of the host's addresses would have left the floor with none, and so let the VM reach this machine's own public addresses. The child's check after it confines itself needs a read that isn't empty, and a later read that fails keeps the last good one.
  • Descriptors and the environment: ruled out. The child inherits only its four descriptors, the socketpair is close-on-exec so no other program holds an end, the child closes any descriptor that a frame brings that it didn't ask for, and it gets only TZ, SSL_CERT_FILE, SSL_CERT_DIR and GODEBUG from the environment.
  • The pid and status files: ruled out. The child can't write the run folder, the status file's name isn't in its environment, and the status names the broker's pid, which daemon.Proc checks, so a child that a VM takes over can't make devvm signal another process. The broker writes the child's pid file, and devvm checks the child's arguments before it signals it.
  • A child that outlives its broker, or starts again: ruled out, changed in review. The child ends when it reads the socket's end, which a killed broker leaves because no other process holds it, and the broker ends with its child, and neither starts the other. A stop gave the broker 2 seconds and the child's close took up to 6, so a child could have kept the port and its old config as the next start began. Now SIGTERM ends the child within a second, and devvm finds a child that outlived its broker by its pid file and stops it. Listed: a child that a VM has taken over can ignore the socket's end and change its own arguments, which daemon.Proc then doesn't match, so devvm leaves it alone. On Linux PR_SET_PDEATHSIG kills it with its broker, but on macOS such a child outlives a broker that was killed, confined, with its VM's values and port, and the VM's next start reports its proxy's port as taken.
  • A binary that changed under the broker: changed in review. The protocol's version alone can't tell two builds apart, so the start and the answer carry each side's executable's SHA-256, and a child from another build fails the start, and the VM's next launch starts the pair again. On Linux the child is the broker's own file anyway.
  • A file that changes between its stamp and its read: ruled out. The child keeps the stamp of the file that the broker read, so a write after that read changes the stamp, and the child asks again.
  • Memory and CPU: listed. A child that a VM takes over can use memory and CPU without a bound, as the proxy can.

End-to-end checks that the implementation adds, in network, link, nix, images, tools and from: a VM's proxy runs as a broker and a child, with the child's arguments and descriptors above and no environment but the four variables. A bound secret goes in, a login is captured from the fake token endpoint, a link connects and the Nix cache fills, each through the child. devvm stop leaves neither process, and the next launch starts on the same port at once. A symbolic link, a FIFO and a hard link planted in the VM's logs folder and the Nix cache lead no command of devvm's, the next start or a rotation to their targets, and hang none. A broker killed with SIGKILL takes its child with it within a second, a child killed takes its broker and the agent's socket with it, and nothing starts again until the next launch. A build behind a company proxy goes through a broker and a child, and both are gone after the build. The two follow-ups add the checks that the confined child can't read a file in the home folder, reach the Keychain or connect to a unix socket, on each platform. On Linux, network checks that the VM's proxy says Landlock in run/proxy.confined, and that the child's /proc entry shows no_new_privs and a seccomp filter, and TestSelf, in internal/landlock, runs its test binary again as a child that confines itself, which writes, renames and lists in its folder, reads the host's addresses and writes to a TCP connection it held before, and is refused a file outside its folder, /etc/hosts, listing /, its own executable, a folder, a link and a FIFO in its folder, a unix socket that stands in for an ssh master's, a socketpair, a listen, an IPv4 and an IPv6 socket, a netlink socket of another family than routes, connecting a TCP socket it held before to a loopback server, MSG_FASTOPEN from its listener once a shutdown has closed it, from ABI 4 a bind and from ABI 6 a signal to its parent. By hand, devvm's release build ran a broker whose child was confined on Ubuntu 26.04 (AppArmor, ABI 8), Fedora 43 (SELinux, ABI 11), Debian 13 (ABI 6) and Ubuntu 26.04 on arm64, served a request, refused a blocked host and reached the Nix cache's endpoint. On macOS, network checks that the VM's proxy says full seatbelt in run/proxy.confined, which means the child started under sandbox-exec and its own check held, and TestChildProfileConfines, in internal/seatbelt, runs its test binary again under the child's profile, which writes a regular file in its folder, renames it, changes its mode, removes it, looks at its policy file, and writes to a TCP connection it was handed and to one it accepted on a listener it was handed, and is refused a link, a folder, a FIFO and a hard link there, changing a file's flags, removing a folder, reading its policy file, reading or looking at a file outside, opening the broker's config, connecting to a unix socket, connecting over TCP to a loopback server on 127.0.0.1 and ::1 or to any other address, sending UDP, running a program, listening on a port, signalling its parent and listing the processes. The broker's judgment is unit tests: a dial to a loopback port that no rule names is refused, 127.0.0.1 and ::1 alike, and so is one to this machine's own address, while one that a rule names connects, from the dial after the rule is written, and not after it's gone, and the open tier's broker connects to any. FuzzBrokerFrames sends the broker any lookup and dial, and checks that it looks up only a host name and connects only where its own floor allows, and the in-process tests run the whole proxy with every lookup and connection through the broker. By hand, devvm's release build ran a broker whose child was confined, and a helper under the child's profile was refused ~/.zshrc, ~/.ssh, ~/Library/Keychains and the login keychain's file, ~/.local/share/devvm and ~/.config/devvm, running security, and an ssh master's control socket, and reached example.com. The fallback and its limits are unit tests (TestStartChildSandbox), as a broken sandbox-exec can't be made on a real Mac.

Failed attempts

  • Claude's host login in VMs: on macOS it's in the Keychain, which can't be shared. VMs get a login made in a VM instead, which the VM's proxy captures. The first token saved by hand was the code the browser shows, so devvm secret set claude refuses one without the sk-ant-oat01- prefix.
  • krunkit (Lima on libkrun) to return freed memory: it didn't visibly return any.
  • Debian's cloud kernel for --from: on arm64 it has no gpio_keys, so it ignored Lima's stop request; Lima hard-killed the VM after 30 s, and node, bun and dockerd in the image came out corrupted. On x86_64 it has no 9p, so on a Linux host every mount of the VM's was an empty folder: Lima mounts them with nofail, and the shared tools' build failed at its first cd. --from uses the generic kernel on both. With it, a Debian VM on QEMU first booted with its network card named enp0s4, which cloud-init couldn't rename to Lima's eth0 once the card was up, so the VM got no ssh host keys. Debian's kernel command line has net.ifnames=0, which keeps the name eth0 from the start.
  • Every layer as a Docker build stage, flattened: it worked, but each image became its own full disk (3.7 GB for node).
  • Shared read-only layers: each Docker layer as an EROFS file, stacked as / with overlayfs over each VM's own disk by an initramfs of devvm's own. It worked (node took 1.0 GB of layers instead of a 1.8 GB disk), but devvm owned the boot path (the initramfs, an exit initramfs for clean shutdowns, kernel extraction), and cold program starts were 10–50 ms slower. Shared tools, and overlays on Linux, give the same savings without it.
  • A read-only mount for .git/hooks in the VM: root in the VM can unmount it and write hooks through the project mount underneath. Locking .git itself (uappnd) breaks git, and a locked placeholder .git/commondir makes git fail. Hence chflags uchg on hooks and config on macOS, plus detection, and on Linux read-only binds in QEMU's own namespace, which the VM can't reach (details, read-only paths on Linux).
  • Keeping git on this machine out of submodules the VM adds (strict): diff.ignoreSubmodules = all in the locked .git/config, which devvm git-protect strict sets in devvm 0.1.0 and 0.1.1-rc.1, can't hold. The VM writes .gitmodules, whose ignore line beats it, and git reads the index's or HEAD's copy when the working tree has none. git add -A, -u and . enter a submodule whatever the settings say, git diff-index, git diff-files and git describe --dirty enter one that .gitmodules doesn't name, git fetch and git pull recurse into one that fetched commits move, and --ignore-submodules on the command line beats config. A per-name submodule.<name>.ignore holds only for the name the VM picks, and locking .gitmodules would put a file in the working tree and leave checkouts across it stale on macOS. The submodule's own config runs either way, because the git that the host's git starts in it reads that config, and no setting refuses it. Only --clone keeps the VM's code away from git on this machine, so devvm git-protect strict is a usage error that names devvm clone on, and a VM left strict is on from its next check that finds it stopped (VMs that were strict).
  • A root helper for Linux's immutable attribute: a helper with CAP_LINUX_IMMUTABLE, installed with sudo, could lock .git as macOS's flag does, but it would put a privileged program on every host that the VM's repo could aim at. QEMU's own namespace needs no privilege.
  • Kernel extraction trying gzip first: Ubuntu's arm64 kernel is an EFI executable with a zstd payload.
  • mke2fs -d from a tarball: it needed libarchive and a UTF-8 locale. A directory works.

Things learned

  • Lima vz never returns freed guest memory to the Mac. sbx returns it with a VM monitor of its own; libkrun has MADV_FREE, with a stronger fix still an open PR.
  • APFS clones cost nothing until written, and du overcounts them: real use was 5.5 GB where du said 12.7 GB.
  • Lima locks each additional disk to one running VM, so images shared across VMs go through a shared folder (virtiofs on macOS, 9p on Linux) and are loop-mounted from it.
  • Read-only mounts are enforced by the host: even root in the VM can't write to them, but root can unmount a nested one and reach what's underneath.
  • Codex and opencode refreshing their OAuth logins in a VM can rotate the token and sign the host out. On every tier the VM holds only placeholders, and devvm refreshes the logins on the host when the proxy asks it for their values (internal/agentlogin). Codex decodes id_token's claims and the access token's exp without checking signatures, so placeholders are unsigned JWTs with the real account claims and a far-off exp.
  • On macOS, a socket in transit over SCM_RIGHTS can lose the data it held and read as ended when the same process closes, at that moment, a unix socket that still holds descriptors no one received. It fails closed, as an ended connection. The broker and its child close such a socket only as the pair ends, and the test that reads a handed-over link's data asks for the link once more when it reads empty.
  • A process passes the files it was given on to the processes it starts, unless they're marked close-on-exec. Go marks only the files it opens itself, so a terminal, an editor or a test harness that gives devvm another one (a pty on descriptor 3, the end of a pipe) would have it held by devvm's proxy, its port forwarder and Lima's processes, which keep that terminal or pipe open for as long as they run. So devvm marks every file it was given past standard input, output and error close-on-exec as it starts, and keeps them open itself.
  • No existing tool gives Lima Dockerfile-style layers with sharing at run time; nerdbox and Kata do it on VM runtimes of their own.
  • Where devvm fits, next to sbx and Colima: sbx puts agents first; devvm gives a full Linux VM per project, with agents optional.

Open work and risks

User-facing limits are in Known limits, and what devvm leaves open is in Attack vectors.

  • --from: a moved tag is noticed only at the next build, not when listing images; devvm doesn't log in to registries, so private images work only through Docker; registries over plain HTTP (localhost:5000) aren't supported.
  • Alpine: rc-status as a normal user shows acpid and syslog as crashed, as their pid files are root's (sudo rc-status is clean).
  • Free-space floors: the free space devvm wants before each build and new VM (free space) is set by Lima's own package, and for shared tool images in internal/backend/disk.go, where the comments give what each number was measured from. The measurements are free space, read with statfs before, during and after each step, in e2e runs on macOS with Lima vz, and for shared tool images also with devvm's data folder on a tmpfs of its own on Linux. On Linux hosts, Lima's numbers add a copy of base's disk to an image's and a tools build's, but they haven't been measured there yet. A --from base converts its image in the host's temporary folder, which devvm doesn't check, because on Linux that's often a small tmpfs.
  • Workspace clones: each repo's seed is copied one after another, so a folder of many big repos takes a copy per repo; copies in parallel, bounded, aren't built. A repo made in the VM stays there until the user clones it out by hand, and nothing of the folder's own files comes back (workspace clones).
  • x86_64 hosts are untested on real hardware; on Intel Macs, --from's kernel is untested with vz.
  • Linux hosts: the QEMU wrapper depends on the shape of Lima's -netdev user,id=net0,… argument. If Lima changes it, the wrapper refuses to start QEMU rather than run it unrestricted.
  • Network tiers, not built:
    • approving blocked hosts as they're hit.
  • Claude Code's login is captured on a path Anthropic doesn't document. devvm reads Claude Code's token endpoint, its client ID, its requests and replies and the .credentials.json format from Claude Code 2.1's bundle, and refreshes the login on the host as Claude Code would (logins made in a VM). A release that changes any of them can break the login in VMs, or the host's refresh, without warning. The network end-to-end section drives the real Claude Code's claude auth login against a fake endpoint, so a change to its requests fails that section, and a Claude Code token from claude setup-token, which Anthropic documents, stays the fallback.
  • Network tiers, risks of the mechanism:
    • sandbox-exec is deprecated. If Apple removes it, macOS needs another way to confine the hostagent: an egress filter upstream (gvisor-tap-vsock#609 and #631; Lima's hostLoopback: false, lima#5581), a user-v2 daemon of devvm's own (lima#5464), or QEMU with the Linux mechanism on macOS too (it works there, slower than vz). The self-check catches it breaking silently.
    • VMs started outside devvm (limactl start, limactl shell starting a stopped VM, Lima's start at login) aren't confined: devvm reports them unenforced. An override.yaml setting a dead HTTPS_PROXY might harden this (untested).
    • A Lima upgrade that adds a hostagent connection fails closed: the start hangs until Lima gives up (10 minutes in the experiment). devvm should time-box the start and say it's the sandbox. That includes unix sockets: the profile allows only those in the VM's Lima folder and the forwarded agent's. Allowing every unix socket would let a compromised hostagent reach docker.sock or another ssh agent.
    • Tunnels the proxy doesn't read are decided by the CONNECT host and checked against the TLS server name, so domain fronting through a shared CDN may still reach other hosts (attack vectors).