A parent folder's VM mounts a nested project folder read-write, so code in
it can move the nested folder aside and put a link (to the home folder, or
anywhere) in its place after devvm found the nested VM. Lima passes the
mount's location as it is, and QEMU's 9p and Virtualization.framework's
virtiofs follow the link when they open the share at the VM's start, so
the nested VM mounted the link's target read-write. The e2e check below
showed it on macOS (vz, virtiofs) and Fedora (QEMU, 9p) before this
change: devvm restart, and a start
whose limactl start found the link, both ran the nested VM with the decoy
folder's files at the project path.
devvm now checks the folder a start mounts (folderChanged: its path's
links resolved give the same path, and its FolderID is the state's) before
bringUp's host checks of a stopped VM, which would act on the link's
target, just before the backend's start, and once it returns. Before the
start it refuses (project_folder_changed); after, it stops the VM and its
proxy and refuses (project_folder_changed_stopped). Both link to the new
"A nested project replaced" section of using/vms.md; attack-vectors.md
and internals/overview.md say what's checked and what stays open (a swap
put back between the mount and the last check, and the boot it ran for).
Tests: TestFolderChanged (a link in its place, a link above it, another
folder, gone); nested_replaced.txtar, with the limactl stub's new
start-links and stop-links switches (fails without the fix); the project
section's "a nested project folder replaced by a link" (tests/e2e/
nested_test.go): replaced while the VM runs (9p keeps its folder, vz's
virtiofs answers Operation not permitted, neither shows the link's), once
devvm restart's stop ends, and as Lima starts it, through a limactl
stand-in that has the parent's VM make the swap.
Co-Authored-By: Claude Opus 5.5 <[email protected]>