Security model
devvm treats everything in a VM as untrusted, including a coding agent with root, because the VM’s user has passwordless sudo. This page explains how devvm keeps that code away from the rest of your machine. Staying safe lists what a VM can reach and the habits that keep you safe, and Attack vectors goes through common attacks one by one and lists what devvm leaves open.
All of it rests on the VM’s boundary. Processes goes through each process on this machine that a VM’s bytes reach, what it holds and how it’s confined, and lists the listeners a VM reaches.
What devvm protects, and how
Only the project folder
A VM mounts its project folder read-write at the same path. The only other things it mounts from the host are the shared tools and its agents’ config folders, both read-only, so it never mounts your home folder, which Lima’s own templates do. A --clone VM doesn’t mount the project folder either. It has its own clone, and its work reaches the repo only when you fetch it. When you run devvm in a subfolder and it uses the project folder’s VM, that VM mounts nothing more than it already did (a subfolder’s VM).
devvm refuses a project folder that would hand the VM more than the project:
- A folder that is or holds your home folder, devvm’s settings (
~/.config/devvm), its state (~/.local/share/devvm, which holds its binaries and other VMs’ disks) or its Lima home (unsafe_folder). - A folder inside devvm’s own folders (
unsafe_folder_inside). A VM in~/.config/devvm/layerscould rewrite the scripts that every image build runs, and a VM in devvm’s data folder could rewrite the files devvm runs on the host.
devvm compares each of these folders with the project folder both by path and by the folder itself, so it also catches a project folder, or a folder above it, that is the same folder as one of devvm’s by device and inode, or the other way round. So on a volume that ignores case, as a Mac’s does by default, a project at ~/.Config/devvm/layers is inside ~/.config/devvm, although the two paths differ. --unsafe-folder mounts such a folder anyway, and devvm says so. A --clone VM mounts nothing, so devvm doesn’t refuse its folder.
A project folder inside a coding agent’s folder in your home folder, such as ~/.claude/skills/mine, or one that holds an agent’s folder, such as ~/.pi for pi’s ~/.pi/agent, gives its VM read-write access to that agent’s settings on this machine, such as Claude Code’s hooks, which run on the host. devvm doesn’t refuse such a folder, because working on a skill in place is common, but each launch of a VM that mounts it warns once, naming every agent’s folder it overlaps (project_agent_folder). devvm finds them by the same comparison and also by the agent folder’s name, so a folder that the VM could make later counts. A --clone VM gets no warning.
One VM per folder
A VM belongs to the folder it was made for, which devvm knows by its path and by the folder itself: its device and inode, and its birth time where the file system keeps one. macOS numbers its disks’ devices in the order they appear at boot, so after a restart an unchanged folder can be on a device with another number. devvm still takes it as the same folder when it’s at the same path, with no link on that path, and has the same inode and birth time on a file system that never gives a new folder a deleted one’s inode number. That’s safe because nothing in a VM can give a folder an inode and a birth time, and a copy that keeps both, such as a snapshot, is at another path unless you mount it at the folder’s own. devvm reads the folder’s identity from the folder opened at its path with no link followed, so a link that a VM puts there for a moment can’t pass such a copy off as the folder. For a VM whose state records the folder’s volume (below), the folder on the renumbered disk must also be on that volume when devvm can tell it, so a copy of the disk that has a volume ID of its own but keeps the folder’s inode and birth time, mounted at the folder’s own path, is another folder. A copy that keeps the volume ID too, as dd makes, still matches, as below. The VM’s next start records the folder on its device as it is now, before the start mounts it, and never when the folder is on another volume (an existing VM). When you delete a folder and make it again at the same path, or clone another repo where an old one was, devvm refuses to give the new folder the old folder’s VM, so the new folder never quietly gets what’s in the old VM’s disk. devvm rm deletes the old VM and devvm adopt gives it to the new folder, and each does so only after you confirm (a folder made again). When you move or rename the folder, the folder at its new path is the same folder, so devvm offers it the VM, and moves the VM only after you confirm (a moved or renamed folder). It never offers a VM to a copy, to a folder another user owns, or on a file system that may give a new folder the inode number of a deleted one, so a VM never moves to a folder that only looks like its own. The folders that get the offer are those whose file system records a birth time: on macOS, folders on APFS and HFS+, and on Linux, folders on ext4, XFS, Btrfs, tmpfs, ZFS, F2FS and bcachefs. Folders on network shares, FUSE file systems and USB drives formatted with FAT or exFAT never get the offer.
A folder that moved, and whose disk was numbered anew since, is on another device at another path, so its device, inode and birth time alone don’t name it. So the VM’s state also records the folder’s volume, which no renumbering changes. On macOS that’s its volume UUID, as diskutil info gives it for the folder’s mount point, and on Linux it’s the file system’s own ID (f_fsid) on ext4, Btrfs, where each subvolume has its own, and ZFS. XFS, F2FS and tmpfs derive that ID from the device or the mount, so a folder on them, or on any other file system, records no volume and keeps the rule above. devvm reads the folder’s mount point, its device and its file system’s ID from the folder opened with no link on its path, and on macOS it takes diskutil’s answer only when it names that mount point and that device, so a volume mounted there meanwhile isn’t taken for it. A folder on a volume mounted read-only, or a snapshot, records no volume and matches none. The state records the volume bound to the folder’s inode and birth time, so a record that an older devvm left beside a folder it moved, whose inode is another, names no volume and is recorded again. devvm offers a moved folder the VM when its volume, inode and birth time are the recorded ones and the conditions above hold. When the record’s volume is marked unchecked, devvm offers the VM only once it has read the volume and found the one recorded. It looks the volume up only once the inode and birth time match. A command looks each mount’s volume up once, and looks up none after one lookup fails. A lookup has 1 second when a launch records it or when devvm ls and devvm space check whether a folder is gone, and 5 seconds when devvm makes, adopts or moves a VM, offers a move, or checks a renumbered folder at its own path. A lookup that fails or takes longer records nothing, and a later launch tries again. When devvm can’t tell a renumbered folder’s volume, it judges the folder by the rule above, as one whose state records no volume. The launch then records the folder’s new device with the volume it had, marked unchecked (folder_unchecked in vm.json), so each later launch looks the volume up again and takes the folder for another one when it’s on another volume, until a lookup finds the volume recorded and clears the mark. On Linux, where the folder’s volume is read in the process at no cost, every launch compares it with the volume recorded, so a copy with a volume ID of its own, such as a Btrfs snapshot or a ZFS clone, mounted at the folder’s path is another folder even on the device the original had. A copy made with dd or an LVM snapshot of ext4 keeps the volume’s UUID, and so its ID, as above. A Btrfs snapshot rolled back at the folder’s path is another subvolume, with an ID of its own, so its folder is another folder, which devvm adopt gives the VM, and so is the folder after you give its volume a new UUID, as tune2fs -U does. devvm reads the folder’s owner, which the offer of a move needs, from the same open folder as its identity, so the folder that’s checked as yours is the one whose identity devvm matches and records. It reads the owner as the system reports it, so on a macOS volume that ignores ownership, as disk images and external disks often do, every folder is yours, and that check tells nothing there. A clone of a disk, by asr or dd, or an LVM snapshot mounted for writing, keeps the volume, inode and birth time, so its copy of the folder at another path matches too, when nothing is left at the old path, as at the same path it already did. A volume ID can also be forged by anyone who can write a volume’s metadata, which takes root, or a disk or disk image that someone crafted and you attach. Such a forgery gets no more than a copy that keeps all three does, which is an offer of the VM that you confirm at another path, and the VM itself at the folder’s own path, where it has to be mounted. Nothing in a VM can make one (a folder’s volume). A folder whose state records its volume is also on its disk when the first folder above its old path is on that volume, so a renumbered disk isn’t taken for an unmounted one (“not connected”). The state records the volume when the VM is made, adopted or moved, and, for a VM whose state doesn’t record one yet, at its first launch that finds its folder.
A project’s devcontainer.json
A project’s devcontainer.json belongs to the project, and so to the VM, which can rewrite it for the folder’s next VM, or for the VM itself when you run devvm update. devvm reads it only when it makes a VM, new or again, and uses only what it can do inside the VM. Nothing in it runs on this machine, so initializeCommand never runs. Nothing in it reaches this machine’s files, because devvm doesn’t follow a link out of the folder, or this machine’s environment, because devvm refuses ${localEnv:…} before it makes anything. It can’t add a mount or change the VM’s network tier or other confinement.
Its commands run in the VM as the VM’s user, confined like anything else in it. Its features can only be devvm’s own layers, so devvm never fetches or runs a feature’s script, and it refuses docker-outside-of-docker. devvm uses its image only when the image’s registry gives it to anyone who asks anonymously, so it never uses a container image that only your Docker has or that only your registry login reaches. It refuses a registry named localhost or by an address that isn’t the internet’s, and its lookup connects only to the internet’s addresses, so it never uses an image on this machine or its network, except through a company proxy, which resolves the registry’s name itself (attack vectors).
An existing VM never changes when the file does, until you run devvm update, which says it reads the file again and asks before it makes the VM again. The file read again is held to the same refusals as a new VM’s, and it can’t replace a base you chose with --from, bring back a port you took out with devvm ports rm, or change its network tier, size, SSH agent or .git protection, which devvm keeps.
Its forwardPorts are added to the VM’s ports, as devvm ports add adds them, even beyond a list you narrowed, both when devvm makes the VM and when devvm update reads the file again. They go through the one port forwarder, so they listen on this machine’s loopback alone (127.0.0.1 and ::1), never take a port that a program on this machine has, and never take a port another VM forwards (port forwarding). What a cloned repo’s file opens is so only what devvm ports add could open, but it reaches whatever on this machine connects to those ports, a browser’s pages included (attack vectors).
Read-only and confined builds
devvm builds images with nothing from the host mounted, and it confines their builds (details). Every build reaches the internet. On macOS it can’t reach the host’s loopback, but it reaches your LAN, the host’s own address on it included, and on Linux it reaches the host’s loopback too. Credentials never go into images.
A tool build writes into a folder of its own and never into the shared tools, and devvm checks each tool image, moves it in and writes its record, with its hash (details). Tool images for glibc, which any VM may mount, build only in devvm’s own Ubuntu base, never in a --from image, and musl ones are keyed by the digest of the --from base they build in, so a container image’s code never reaches another VM’s tools. devvm’s VMs live in a Lima home of their own, so Lima settings you made for other VMs never reach them. devvm also refuses a VM with a network it didn’t give the VM, because that network would reach around the proxy (details).
.git protection
The VM can’t change the parts of .git that run code on the host, because devvm locks hooks and config. On macOS it sets a flag the VM can’t clear, and on Linux it makes them read-only in the user namespace that QEMU runs in. A Linux host whose kernel doesn’t let devvm use a user namespace has no locks, and devvm only watches .git there (details).
Network tiers
A VM on a confined tier, internet, allowlist or none, reaches nothing but its own proxy on the host and the links you added to it. On macOS its Lima process runs under a macOS sandbox, and on Linux QEMU’s network is restricted (details). Even root in the VM can’t get around that. A link’s connections don’t use the VM’s network, because this machine carries them over ssh, and only to a port that another VM on the same tier or a stricter one publishes. An open VM runs on its backend’s own network, and its proxy applies no rules.
The proxy applies the tier’s rules, and it refuses the host’s own addresses and internal addresses unless a rule names them (the proxy). The one thing that VMs share through their proxies is the shared Nix cache, for those with the nix layer. Only the host writes it, with packages from cache.nixos.org whose signature it checked, and nothing a VM sends is stored, so a VM can make the host fetch but can’t change what another VM gets. After each start, devvm checks that the VM still runs confined and can’t connect out directly, and it stops a VM that fails the check instead of opening it (the self-check).
ssh into VMs
ssh and editors reach a running VM by name through the entries that devvm writes (ssh access by name). Each entry is built so that ssh connects only to that VM and the connection gives the VM nothing else of this machine’s:
- Each entry checks the VM’s own host keys, which devvm keeps in the VM’s folder,
~/.local/share/devvm/vms/<hash>/run/known_hosts, as a record of the VM’s current start. devvm reads them from the VM through its backend, instead of over the network, once each start, after the VM runs, whatever ports the VM forwards, and the record names the start it was read for, so the keys of an earlier start are read again rather than trusted, whoever started the VM. devvm also removes the record before each start of its own. A VM whose Lima config changed gets new host keys when it boots. A VM whose keys devvm can’t read gets no entry, and ssh refuses a host key that doesn’t match. devvm’s port forwarder, the sessions of links between VMs and a--cloneVM’s git all check the VM against the same record. - Only host keys go into the record. devvm keeps a line the VM shows only when its key decodes and names its own type, which works for every key type ssh has, and it drops certificates, markers such as
@cert-authority, patterns and anything else. So the VM can’t add a line that would make ssh trust another host, or trust a key for another name. - Each connection is its own. The entries set
ControlMaster no, so a session never rides on a connection that another program opened. Of Lima’s own ssh settings for the VM, devvm copies only the address, port, user and login key, because Lima’s settings turn host key checks off. - The entries turn off everything else your ssh could share with the VM. They set
ForwardX11 no,ForwardX11Trusted no,Tunnel no,PermitRemoteOpen none,AddKeysToAgent no,ProxyJump none,ProxyCommand none,UpdateHostKeys noandHashKnownHosts no, whatever your ownHost *says. That turns off X11, tunnels, remote SOCKS forwards and adding keys to an agent.PermitRemoteOpenneeds OpenSSH 8.7 or newer (ssh -V), and an older ssh refuses the entries. - Of your environment, the entries send only
COLORTERM(SendEnv COLORTERM), which says whether your terminal shows 24-bit color. The VM gets it only where its sshd accepts it, as Ubuntu’s does in devvm’s base. devvm doesn’t set that up itself, so a VM made--froma container image whose sshd doesn’t accept it, such as Alpine’s, gets none. ssh sends it as your terminal has it, and it adds to the variables your ownHost *sends, such as macOS’sLANGandLC_*, rather than replacing them. - Your agent is forwarded only as the VM’s SSH agent choice says. devvm’s own connections to a VM follow the same choice, the one the VM’s current start was made with, and each carries that VM’s agent alone. devvm finds the VM’s agent, which is yours, devvm’s own or none, and the VM’s proxy relays it on a socket of the VM’s own, passing on only listing keys, signing and binding a session to a host, so the VM can’t remove the agent’s keys, lock it or add keys to it (the SSH agents). devvm gives that socket to the backend’s start of the VM, to its shell and to the commands that set it up, such as the setup devvm sends and the
devcontainer.jsoncommands. The backend’s other commands get no agent, and neither do the reads of a VM’s host keys, the self-check’s probe, the checks of a--cloneVM’s clone ordevvm paste’s writes and counts. devvm never changes its own environment, so when one run reaches several VMs, such as a group’s links, no VM gets another VM’s agent. devvm’s background processes, such as the proxy and the port forwarder, start without an agent in their environment, and the proxy reaches only the one its config names. devvm’s own ssh to a VM uses the VM’s login key alone.devvm limactlruns without your agent too, because Lima’s ssh shares one connection per VM, kept open after the command ends, and an agent forwarded over it is the agent of whichever command opened it. With your agent, adevvm limactl shellcould open that connection and pass your agent to devvm’s later sessions of a VM whose choice is devvm’s agent or none.
A session carries the VM’s connections through your machine only where your ssh asks for it. The entries can’t turn off a RemoteForward of yours without also refusing an ssh -R you type, so a RemoteForward still applies. The VM’s sshd allows local forwarding (-L and -D, which VS Code uses), and it allows remote forwards only on addresses in 127.77.0.0/16, which devvm keeps for links between VMs, so a remote forward on the VM’s localhost, as ssh -R asks by default, is refused. It allows no tunnels or X11. Root in the VM can change all of that, so it’s your ssh that decides, and remote forwards you add says what’s left open.
Secrets stay on the host
devvm saves secrets in the macOS Keychain, or elsewhere in files only you can read, and it never puts a secret in a process’s arguments (where secrets are saved). A VM uses only the Claude Code token, when its image has claude, and the secrets you bind to it. On every tier, a VM’s secrets and its agents’ logins stay on your machine, and its proxy puts them only into requests for their own hosts.
The secrets work only for that VM. Its proxy needs the VM’s own password, and the VM’s placeholders end in a random value of the VM’s own, which isn’t the password, so a placeholder that the VM sends elsewhere gives nothing away. Another VM, or a program on the host that reaches the proxy’s port, gets no secret. The password is in files only you can read, and never in a process’s arguments or in devvm’s run logs, and only you can read the proxy’s logs.
Each VM’s proxy reads traffic to the hosts it puts secrets in for with the VM’s own CA, which devvm keeps in the VM’s run folder, ~/.local/share/devvm/vms/<hash>/run/ca/ (the VM’s CA). Your machine never trusts it, but inside its VM it vouches for any site, and no other VM trusts it. Only you can read the keys, they never leave this machine, and devvm keeps them out of Time Machine. Each CA lasts 30 days, and the next one, which the VM already trusts, takes over a week before the current one ends. The certificates that the proxy makes never outlast their CA. What a copy of a key could do, and for how long, is under the proxy’s CA keys.
Set-id files on Linux hosts
Root in a VM can set the set-user-id and set-group-id bits on files in the project folder. On macOS these bits don’t reach the host, because virtiofs drops them, but on Linux they do. A file that a Lima VM writes is yours, so a set-user-id file runs as you for anyone else on the machine who runs it. A set-user-id file that your machine’s root owns runs as root for anyone who runs it, you included, and since the VM’s writes are yours, such a file came from something else on this machine.
devvm names such files when it makes a VM and once a VM is stopped, by devvm stop or found stopped at a launch, but not at a launch into a running VM, because the search reads every file’s metadata and takes about a second for 200,000 files. It skips .git folders, which hold most of a big project’s files and whose files nothing runs by their path. It lists root’s files apart with setid_root_files, and you shouldn’t run them but delete them with sudo rm. It lists the rest with setid_files, and chmod u-s,g-s FILE clears their bits.
What it doesn’t protect
Each defense on this page leaves something open, such as what allowed hosts and secrets permit, open VMs, files the VM writes into the project folder, links between VMs, and escapes from the VM itself through bugs in Lima, Apple’s Virtualization framework or QEMU. Attack vectors keeps the one list of them, under Narrowed, not closed and Left to you, and each entry there links back to its mechanism.
Found a way out of a VM? See SECURITY.md.