mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 21:36:40 -10:00
bc00ebc088ae0aa9c05be3eb6b8dbb64373bd00a
763
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bc00ebc088 |
test(vm): housekeeping never deletes 0.1.0 state
fixture_v010_housekeeping.txtar runs today's housekeeping on 0.1.0's frozen state: a launch whose daily retention is due (0.1.0's retention.run made older than a day, and touched by the launch), then devvm gc --force, devvm gc --orphans --tool-images --retention --force, devvm space --json and devvm doctor. Every VM's vm.json and run folder stays, every shared tool image a state's tools.made.files names stays (the list read from the states before anything runs), no limactl delete names a project VM, devvm ls, devvm space and Lima still list all four, and nothing says unreadable or corrupt. A copy of a tool image under a name no state has goes, the control that gc could delete one. On Linux, 0.1.0's VMs' disks are modelled as it made them, qcow2 overlays of the image's disk (the fixture keeps no disks; the stub's qemu-img info reads the backing file), and gc keeps 0.1.0's base image with image_in_use; on macOS it deletes it, an older base than today's. Nothing found to fix. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
93322e9154 |
fix(vm): running 0.1.0 VMs are warned of and tested
A VM that devvm 0.1.0 started and that runs as you upgrade keeps what 0.1.0 gave it until its next start. Two of those went unsaid: - A launch into a running VM whose start forwarded an SSH agent itself (an older devvm's recorded start, without made.relayed) keeps that agent, which can add, remove or lock keys, and now warns, naming devvm restart, which gives it the relay (agent_raw_old). - devvm doctor said nothing of a running proxy without run/proxy.confined. One that another devvm binary started (its config's devvm_sha256) is an older devvm's single process without a sandbox, which it now names (proxy_old); one this binary started that hasn't written the file yet is still starting and gets none. doctor now passes devvm's own binary to the check. Tests, on 0.1.0's frozen state made running in the sandbox copy (hostagent pid file at 0.1.0's start's time from its known_hosts, run/ started, known_hosts and agent.made.started for that start, Lima listing it running, its ssh port listened on, and 0.1.0's one-process proxy): fixture_v010_running.txtar (doctor's proxy_old; a launch with no stop, start or edit, ports_ssh_old, the proxy started again as broker and child with proxy.confined, secrets.json and known_hosts unchanged, no relayed; then stop and launch: one .ssh.localPort edit, the new start's keys pinned) and fixture_v010_running_agent.txtar (devvm's agent forwarded raw: kept and warned, then devvm restart gives the relay and relayed, with only the ssh port's edit). The modelled hostagent is a live process of the test's, not 0.1.0's pid 54798, because a start counts as devvm's only while its hostagent runs. TestUnconfined: a proxy that hasn't said, by this binary, another, or an unreadable config. - msg: agent_raw_old, proxy_old. - Docs: ssh (agent forwarding), troubleshooting (the proxy runs without a sandbox), internals/install; CHANGELOG After you upgrade. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7cc0dd76ed |
fix(agents): a 0.1.0 store's plugin data stays out of the seed
devvm 0.1.0's agent import copied the whole of ~/.claude/plugins into the agent store, each plugin's data and installed_plugins.json included, and every VM with Claude Code mounts the store's plugins folder whole as its seed, so that data kept reaching every VM until agent import ran again. Every start (starter.bringUp) now takes out of each seed's folder in the store the entries a seed doesn't have (agents.MachineOwn), before the VM runs, and warns once, naming them (agent_seed_cleaned). The folder itself stays, so no VM's mounts or Lima config change. A running VM stops seeing them through its mount at once on macOS; on Linux, 9p's cache can keep what it read until its next start. The folder is reached from devvm's config folder as a root, each part of the path below it a folder: a link there (only a hand-made store has one, and the VM's mount would follow it, perhaps to the user's own ~/.claude/plugins) is refused (agent_seed_link), a link among the entries is removed, never followed, and the opened folder is checked to be the one checked. The temporary files a concurrent agent import or save writes known_marketplaces.json through, regular files, stay. A folder that can't be cleaned fails the start of a VM with that agent and warns for any other (agent_seed_clean_failed, naming what the folder should hold). - vm: Env.cleanSeeds, cleanSeed and seedTemp (agents.go), called first in bringUp with the VM's agents. - msg: agent_seed_cleaned, agent_seed_clean_failed, agent_seed_link. - Tests: TestCleanSeeds (0.1.0-style store, a link entry, a concurrent import's temporary file, no store, once only), TestCleanSeedsFails (a link at the store, .claude or plugins, for a VM with and without Claude Code; an entry that can't go); fixture_v010_plugins.txtar (0.1.0's app with the store's plugins as 0.1.0's import left them and their mount: the warning, no edit but the ssh port's, the seed's link to a folder without data/, nothing said again; then the store's plugins folder a link, and an entry that can't go, each refusing app's start with agent_seed_link or agent_seed_clean_failed). - Docs: coding-agents, internals/agents, the design note's threat check; CHANGELOG Breaking, After you upgrade (running VMs, Linux's cache, plugin logins) and #56's Fixed entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c9005ae4be |
build(deps): bump pins: mise 2026.11.10, Docker 29.10.0, Hugo 0.170.1 and e2e's pins
scripts/bump.sh's safe bumps (patches and minors; no majors or held pins): images (assets/): - mise 2026.11.8 -> 2026.11.10 (base's, and the host's resolving mise) - docker 29.9.3 -> 29.10.0, compose 5.7.1 -> 5.8.0 e2e: - claude 2.1.322 -> 2.1.326, codex 0.167.2 -> 0.169.1, opencode 2.2.7 -> 2.3.0 - pnpm 12.18.0 -> 12.21.0, uv 0.13.7 -> 0.13.9, rust 1.99.1 -> 1.100.0 - ubuntu:26.04 digest 065aa8626841 -> d66b366dac61 - Ubuntu's cloud image release-20261016 -> release-20261108 go: deadcode v0.52.0 -> v0.53.0 dev-tools: govulncheck 1.9.0 -> 1.10.0, vale 3.26.0 -> 3.27.0, hugo-extended 0.169.0 -> hugo 0.170.1 ci: jdx/mise-action v5.2.8 -> v5.2.10, the workflows' mise 2026.11.8 -> 2026.11.10 Hugo 0.170 has no extended edition (one binary, without LibSass, which the site doesn't use): mise.toml's hugo-extended becomes hugo, the docs workflow installs hugo, its release job installs the tag's own tools (an older tag names hugo-extended), and docs/hugo.yaml drops the deprecated hugoVersion.extended. The e2e runner deletes its sandbox's Ubuntu pin when it names a release other than e2eUbuntuRelease (not in a --newest-base run), as devvm keeps a pin it has: without it, moving e2eUbuntuRelease left a cached sandbox on the old release. pinned and ubuntuPin are e2e's one reader of the pin, and TestHarnessRepin covers repin. Image keys change: base and every image above it, the docker layer's included, and the shared tools' images build again. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
6965efcc0a |
fix(vm): devvm agent login claude --setup-token shows Claude Code's address (#57)
An agent's login in the VM ran with devvm's own writers as its output, so os/exec gave limactl shell pipes, Lima added no ssh -t, and claude setup-token, which draws full-screen, showed nothing and waited. When devvm's stdin and stdout are terminals and both output streams are files, the login now gets stdout and stderr as the files they are (ui.Terminal, set by cli as vm.Env.Terminal), so Lima gives it a terminal in the VM, as devvm's shell has. Without a terminal it keeps pipes, and --setup-token warns first (setup_token_no_terminal). Its output reaches devvm's output alone, never the run log, as before. On a terminal, Ctrl-C goes to the login in the VM, which ends, and devvm says the login ended or saved nothing. - internal/ui: Terminal, over Files, never a half pair; TestTerminal. - internal/vm: Env.Terminal; AgentLogin.loginOpts; the warning; why an interrupted login's cleanup stays as endLogin's backstop; endLogin's comment for a login on a terminal; TestAgentLoginTerminal (fails without the fix). - internal/backend: ExecOpts says a terminal's files pass on as they are; Lima's TestExecStreamsAsGiven. - internal/cli: vmEnv sets Terminal; agent_login.txtar checks the warning. - locales/en.toml, internal/msg: setup_token_no_terminal. - tests/e2e: OnTTY, out of TTYRun; network's check that devvm agent login claude --setup-token on a terminal shows the address, waiting for its devvm to end before the next login. - Docs: internals/network.md, using/coding-agents.md, contributing/extending.md and tests.md; CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ea3037bc15 |
fix(vm): MCP servers' logins in a VM finish and survive launches (#62)
Each launch and each devvm agent login claude copied the store's VM copy of Claude Code's OAuth login (claudeAiOauth only) over the VM's ~/.claude/.credentials.json, where Claude Code also keeps its logins to MCP servers (mcpOAuth: their tokens and, mid-login, the PKCE verifier). So an MCP login failed when the VM was set up again before it finished, and a finished one was gone at the next launch. The setup now gets the copy as claude-credentials.json (claudeSyncName), and sync.sh's merge_claude_credentials merges it in the VM: the copy's claudeAiOauth replaces the VM's (or takes it out when the copy has none), every other key of the VM's file stays. It reads the VM's file with one jq call (--slurpfile, so two JSON values or a non-object are caught) and writes it whole, mode 600, through a mktemp file in ~/.cache, which no history export or remake carries, then mv; a failed cat or mv removes the temp file and fails the setup. A link, or a file that's empty, not JSON or not one object, is replaced by the copy and said (a link removed first, so mv never writes through it into a folder); a folder is left and said. With a Claude Code token (setup-token), devvm sends no copy, as before, so the VM's file stays as it is: Claude Code prefers the token in its environment, and a leftover login's placeholder gets the token at api.anthropic.com and nothing at the connectors' host. mcpOAuth stays in the VM: devvm agent save reads only settings and the .claude.json allowlist, history export excludes .credentials.json (HistoryExcludes) and import skips it, and a remake leaves login files out (homeSkips), all unchanged. Tests: TestStageClaudeOAuthMerged (the copy is staged to merge, never at home/.claude/.credentials.json); TestClaudeSyncNamesMerged (sync.sh merges each claudeSyncName name into its place); guest.txtar runs merge_claude_credentials (mcpOAuth and other keys kept, claudeAiOauth replaced or removed, a key with a \u escape, empty, not JSON, two values, an array, a link to a file or folder, a folder, a failed move, the warnings, mode 600, no temp left); agent_login.txtar reads the new name. Docs: Coding agents' MCP servers' logins (real tokens the VM's code can read, never leaving it) and its Copies, How it works' Claude Code's login and the network page's sentences, what a VM made again keeps, the sync.sh header, and the safety pages' claim that a VM never holds a refresh token, narrowed to the logins devvm keeps. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c1db911d1b |
fix(agentlogin): the Claude login reaches claude.ai's connectors (#61)
Claude Code lists a claude.ai account's connectors at api.anthropic.com/v1/mcp_servers and reaches each at mcp-proxy.anthropic.com/v1/mcp/<id>, with the login's access token. The OAuth login's binding named api.anthropic.com alone, so the connectors' requests carried the placeholder and were refused. ClaudeOAuthBindings gives the OAuth login a second binding, claude-connectors: the same placeholder, into Authorization for mcp-proxy.anthropic.com below /v1/mcp/ alone. It has a name of its own because the proxy looks a value up by its binding's name, and secrets.Store.Get gives claude-oauth a Claude Code token in the login's place but never gives one to claude-connectors, so a token, saved or in devvm's environment (whose scope isn't checked), still goes only to api.anthropic.com. The bindings file stays version 1. Tests: TestClaudeCapture and the claude-oauth golden check both bindings; TestClaudeBindings checks the connectors' binding gets the OAuth login and never a saved or environment token (with the claude-oauth control); network.txtar checks the VM's secrets.json and secrets.policy. e2e's network section adds the connectors' host to its fake upstream: with the claude secret, neither its placeholder nor the OAuth login's gets the token there (the API, the control, does), and after the host's refresh the connectors' host gets the refreshed access token. Docs: the Claude Code login, the attack vectors' new entry for connectors (deny mcp-proxy.anthropic.com to keep them from a VM), How it works' bindings and threat lines, the agents' table, and Contributing's e2e network section, whose refresh sentence was stale (the refresh succeeds). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
8afdec7de4 |
fix(proxy): a NO_PROXY address with an IPv6 zone names nothing (#59)
parseNoProxy read an entry with netip.ParseAddr, which accepts a zone, and PrefixFrom then dropped it, so fe80::1%eth0 sent fe80::1 direct. Go's httpproxy, HostOK, dial and the policy all treat a zoned address as naming nothing; the NO_PROXY reader now does too. Tests: FuzzNoProxy's crash input (::%0 against [::]), and fe80::1%eth0 and [fe80::1%eth0]:443 in TestNoProxy's names-nothing cases. FuzzHostSites' noProxySite lists the zoned address as a divergence from the legacy reader. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
e97db057fd |
fix(agents): Claude Code's plugins get a folder of each VM's own, the store's a read-only seed (#56)
A VM's ~/.claude/plugins was the agent store's plugins folder, mounted
read-only, so everything Claude Code writes there failed with EROFS: a
plugin's data (${CLAUDE_PLUGIN_DATA}), installs, marketplace refreshes,
mcpb/ and the rest. Making the store writable would let one VM change
what Claude Code runs in every other VM, so each VM's ~/.claude/plugins
is now its own folder on its disk (CLAUDE_CODE_PLUGIN_CACHE_DIR), and the
store's folder is linked at ~/.claude/plugins-seed and read as Claude
Code's own read-only seed (CLAUDE_CODE_PLUGIN_SEED_DIR). Checked on a
devvm VM first: a seed-cached plugin from a GitHub-style marketplace
loads with only enabledPlugins, its hook writes ${CLAUDE_PLUGIN_DATA} in
the VM's own folder, installs in the VM work, and seed marketplaces
refuse updates.
- agents: Def.Seeds (Rel, Link, Entries), Seeds, SeedOf, MachineOwn;
Env gains Home; Claude's Env sets both variables below $HOME.
- vm: the setup links a seed at its Link and stages own-dirs, which
sync.sh makes a folder in place of a link; agentEnv writes Home values
through homeValue (shared with toolchainEnv); a remake keeps the VM's
own folder and skips the seed's link.
- devvm agent import copies only a seed's entries (known_marketplaces.json,
marketplaces, cache), directly and through followed links, so the
host's plugins' data, mcpb, synced, .trash, store and
installed_plugins.json never reach the store.
- devvm agent save: the VM's script excludes a seed folder's other
entries by name, and readSent refuses any (listedPath); a seed folder
adds and changes, never removes or prunes; claudeRecords renames the
VM's plugins path to the store's and joins known_marketplaces.json by
key, leaving records Claude Code registered from the seed as the
store's, and the store's file as it is when nothing changed.
- History: an export leaves the VM's plugins folder out and an import
skips it and the seed's link: it's settings and plugin data (which can
hold a plugin's own logins), not history, and reaches other VMs only
through devvm agent save's reviewed diff.
- Review fixes (security-audit): historyImport refuses a name with a
., .. or empty part (GNU tar's anchored excludes missed
.claude/./plugins and .claude//plugins, which now reach a writable
folder) and deletes importSkips by path after the link sweep; the save
script never excludes a name with a wildcard's character (it's sent
and refused); only a marketplace record whose exact installLocation is
clean and in the store's marketplaces joins the store's.
- Tests: claude_test.go (TestClaudePluginsSeed, TestClaudePluginsHistory,
TestAgentImportClaudePlugins, TestAgentSaveScriptClaudePlugins,
TestReadSentClaudePlugins, TestAgentSaveClaudePlugins), TestSeeds,
TestListedPath cases, the agent, agent_save and sync CLI tests, goldens,
and e2e project checks of the seed, the VM's folder and a plugin's data.
- Docs: coding-agents (store table, Claude Code's plugins under Mounts,
the save's plugin example), internals/agents, a design note with its
threat check, extending.md, CHANGELOG Fixed and After you upgrade.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
f3848294d8 |
fix(agentlogin): names you choose in agents' settings are no longer taken for secrets
Redact judged every key by redactName's substring rule, so a plugin, a marketplace or an MCP server named tokeneconomizer, token-saver or secret-scanner had all its settings replaced with devvm-redacted, and Claude Code refused the VM's settings.json whole (#55). Each agents.Def now lists the tables of its settings files whose keys are names you choose (Names: a table under a name isn't judged by its name) and the tables of settings keyed by names (NamedValues: neither a table nor a setting's word, lower-case letters and dashes such as off, is), read from each agent's docs; agents.NameTables is their one union, which Redact applies to every agent's files. Fields under a name are judged as before: the substring rule, wholeTable, secretShape and the URL and text scrubbing. Any other value right under a names table is still judged by its key, a name that's env or headers still makes a table of secrets, and a * in a table's path never stands for a list's element. The trade-off: a table with a secret-looking key right under a name, such as {"mcp": {"tokens": {...}}}, is no longer replaced whole; no agent's schema has one there, and the fields inside it are still judged. Tests: TestRedactNames (Claude Code's, Codex's, opencode's and pi's names, kebab and camel, secret fields under names, misplaced values in names and settings tables, a list under a settings table's path, a server named env), FuzzRedact's seeds under names and settings tables, and TestRestoreOlderNamesCopy for a VM copy an older devvm blanked, which devvm agent save leaves out with a warning (an After you upgrade line). Thanks to dhruv1220 for the tests' idea in #58. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2c0a894a1c |
fix(vm): a project folder's VM works after a boot renumbers its disk
macOS numbers its disks' devices in the order they appear at boot, so after a restart an unchanged project folder's identity (dev:ino:btime) can have another device. The finder then refused its VM as made for an earlier folder (vm_other_folder), a stopped VM's start refused it as replaced (project_folder_changed), and the next .git check called it replaced (git_replaced). platform.SameFolder is now the one comparison of two folder identities: the same ID, or at the same path the same inode and birth time on another device. On another device the ID must also be the one read from the folder opened at the path with no link followed (OpenNoLinks, then fstat and fstatfs on it: openFolderID), on a file system whose IDs are their folder's alone, so a link swapped in while the caller read the ID can't pass a copy's (a snapshot's, a cloned disk's) off as the folder's. A folder at another path (moved) matches only exactly. platform.Renumbered says when the record needs the folder's ID as it is now. The finder's sameFolder, here.movedFrom, gitprotect's protectRepo and the strict conversion's checks use it. A start records the project folder's identity as it is now under the VM's state lock (renumbered, in bringUp) before the backend mounts it by Want.ProjectID, so vz's /.vol/<dev>/<ino> mount names the current boot's device, in the one limactl edit; folderChanged's checks after it then compare exactly. A .git check that accepts a renumbered .git records its current identity. The move's check stays exact, as both its IDs are read in one run. The structure test's folder-ids rule fails on == or != on a field named Folder or GitID, or a call of FolderID or folderID, outside internal/platform and tests, unless exactFolderIDs lists the function with why: the agents' and exports' Folder paths, recordMove's unchanged-state check and folderChanged. Tests: TestSameFolder (platform), TestRenumberedFolder (vm), TestReportsRenumbered (gitprotect), a renumbered vz case in TestProjectMountByInode (lima), existing.txtar's renumbered folder, and fixture_v010_renumbered.txtar on the frozen v0.1.0 state, through the new renumber script command and stubtest.Renumbered. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ba5613e1ed |
fix(project): a folder name's run of separators becomes one dash in its VM's name
A folder named x--y, "foo (copy)" or "C++ stuff" failed to get a VM (#52): project.Slug turned each character other than a-z and 0-9 into its own dash, and Lima's instance-name grammar refuses separators in a row. Slug now writes one dash per run. - vmname: the project-VM grammar refuses dashes in a row ([a-z0-9]+(-[a-z0-9]+)*); HasRuns recognises the names releases up to 0.1.1-rc.3 made for such folders. - state: a vm.json whose name HasRuns and that has no created time is read as no state. Only a create that Lima refused leaves one (vm.json is written before limactl clone), so the folder's next VM, in the same hash folder, replaces it, rather than every read failing as corrupt. One with created set is still corrupt. - The limactl stub refuses names Lima refuses on create and clone; TestLimactlStubContract gains a refused clone, checked against real Lima. - Tests: TestNamesLimaTakes (Lima's regex as the oracle), TestHasRuns, TestVMWithRuns, TestLimactlRefusesNames, name_runs.txtar (a new VM for x--y, and an older release's leftover state replaced). - Docs: internals/backends.md's VM names; CHANGELOG Unreleased Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
70ed1db7ef |
build(nilaway): nilaway:linux checks Linux's build and must pass before a push to main
CI's nilaway job only warns, so a new finding hides in a green run, and a finding's key is its code path, so code that only moved can read as new. mise run nilaway:linux runs scripts/nilaway.sh with GOOS=linux, so nilaway checks the code as built for Linux, as CI's job does, from a Mac too (a nil planted in a Linux-only file fails it there, where the plain task passes); it exits 3 on a new finding and 1 on a stale line. Contributing's Tools and tasks and Nil checks, AGENTS.md's tasks and codebase-standards' rules.md say it must pass before a push to main. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
069f646e80 |
test(structure): an io.ReadAll outside tests reads through an io.LimitReader
The structure test's read-limits rule fails, outside tests, on an io.ReadAll whose reader isn't an io.LimitReader made in the call, unless unboundedReads lists its function with why; a listed function that has none fails. Four are listed: the status line's tail of the run's own log, which only that run writes, and the three test stubs' reads of the standard input devvm under test writes and closes. readCases breaks it on a renamed io import, a reader limited before the call and a read in a function literal. It shares dropped-errors' walk and table check (siteRule, sitesWhere). Named as the guard in codebase-standards' Bound what you don't control and rules.md, and in Contributing's structure test. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f9c02c1c5c |
build(lint): a file a VM can write is changed through what opened it
forbidigo refuses os.Chmod, os.Chtimes, os.Chown, os.Lchown and os.Truncate in internal/proxy, internal/vmlog and internal/vmssh, outside tests: a change by path follows a link a VM swapped in after the open. The two sites today, the proxy's SSH agent relay socket and the link session's sockets, chmod a unix socket devvm has just made in its own folder, which only its path can set; each says so in a nolint. The safefile rule widens to internal/vmlog, which has no open of its own, and to the proxy's rotate.go and nixcache.go, whose three opens to write or lock say why in their nolints. testdata/lint breaks the rule once for each function and keeps the descriptor's own methods. Named as the guard in codebase-standards' Treat what a VM can write as hostile and rules.md, and in the checks on owners. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
bd09e883d5 |
test(structure): a Wait's or a strconv parse's error assigned to _ fails
The structure test's dropped-errors rule fails, outside tests, on a function that assigns a Wait's error, or a strconv parse's (Atoi, the Parse functions, Unquote, UnquoteChar, QuotedPrefix), to _, unless droppedErrors lists it with why; a listed function that drops none fails. None is listed today. errorCases breaks it on each shape: an assignment, both of a process's Wait results in a goroutine, a renamed strconv import, a var and an if's init. Named as the guard in codebase-standards' Never fail silently and rules.md, and in Contributing's structure test. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2208931253 |
test(proxy): the broker's too_long reply to a reply past a frame
The broker's answer refuses a reply too long for a frame with too_long, so the child's request never waits on it, but no test reached that path. TestServeChildTooLong, in a synctest bubble on memnet, asks for a value past wireMax and checks that the child gets too_long for it at once, and that its next request is answered. Without the too_long send the bubble deadlocks on the child's wait. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
59126858c4 |
fix(proxy): the Nix cache's folders are made and chmodded through descriptors
makeNixFolders ran os.MkdirAll and os.Chmod on nar/ by its path, which follows a link there. A confined proxy child makes regular files alone in the shared Nix cache (Landlock has no MAKE_SYM for it, and Seatbelt refuses anything but a regular file), so it can't plant one; a child that runs without Landlock or Seatbelt could, and each proxy's next start would chmod the folder the link led to. This is hardening for that case, not a fix a user could see, so it has no CHANGELOG entry. The cache's folder is now opened as a safefile.Root, and its mode set through its descriptor (Root.Chmod: fchmodat on "."). Anything at nar/ that isn't a folder is deleted as itself (a link never followed), and nar/ made and opened from the root as a folder, never a link (Root.MakeDir, which tries mkdir only when nothing is there, as a sandbox that refuses making folders may refuse it even where one is), its mode set through its descriptor. makeNixFolders reports a replacement, which the broker's log warns of, so the cache, which is devvm's alone, never stops a proxy's start. Test: TestMakeNixFoldersPlanted plants a link to a folder outside the cache, a relative one to a folder in it, and a file; each fails without the fix (the targets went to 700, or the start failed). Docs: How it works' shared Nix cache and the design note on the folders the child writes. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0b85f5f557 |
fix(size): a size that isn't a number is refused, never read as 0
Size.Backend dropped strconv's errors, so a VM's size in vm.json that isn't a number, such as "cpus": "four" after an edit by hand, read as 0, the image's, and the VM started with the image's size without a word. Backend now reads each part with the check that took it (settings.CPUCount, settings.GiB, which ParseCPUs and ParseGiB now use), and returns an error naming the key and value. storedSize turns a stored one into size_stored_invalid, naming the VM. Every start (bringUp, before anything runs), a restart's stop (stopToStart, so a running VM keeps running, as a refused proxy start leaves it), devvm size and a remake's check refuse with it; devvm size --KEY sets it again. ParseCPUs and ParseGiB also refuse a number too big for an int or a float64, which for --disk reached Lima as +Inf. Lima's originOf read base's disk with ParseFloat and dropped its error: "NaN", "Inf" and "1e400" passed its check of a size above 0. Only devvm's own Origin writes that step (gibString of BaseDiskGiB), so no user, VM or limactl output reaches it; it now reads it with settings.GiB and fails naming the value. Every other discarded strconv error outside tests goes too: - hostgit.Bool reads a boolean as git does (yes, on, whole numbers) and says when a value isn't one; GIT_CONFIG_NOSYSTEM, which strconv.ParseBool read as false for "yes", uses it, as does the clone's copy of a repo's config (gitBool, which had its own copy). - image.GlibcOlder checks both versions itself and reports ok, so one that isn't a version is never read as 0. - leaktest and state's lock order panic on a goroutine number runtime.Stack doesn't print today, rather than reading it as 0. - cli's test-build overrides fail on a number that isn't one (a test build's panic), the stub limactl refuses a size it can't read, and opencodeMajor's fallback to 0 is explicit. Tests: TestSizeBackend, TestStoredSizeInvalid (a stopped VM and a running one's restart), TestSizeNumbers, new TestParseSizes and TestOriginOfRefuses cases, TestParseUnknownFormat, TestBool, TestUserFilesOf's git booleans, TestGlibc's invalid versions; each fails with its fix reverted. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
c8505e326a |
fix(daemon,desktop): a process's Wait error is kept, not dropped
daemon.Spawn dropped its Wait's error and kept only the ProcessState. When Wait can't reap the process (wait4 fails, as when something else reaped it), there is no state: Exit then said "<nil>" and ExitSignal dereferenced a nil state, which would have panicked the proxy's broker in sandboxFailed. Handle.reaped now keeps Wait's error when there's no state, Exit names it, and ExitCode and ExitSignal answer -1 and 0. devvm desktop's sshChannel.Close dropped ssh's Wait error. An ssh that ends on its own with a failure, such as 255 when the VM drops the connection, now goes in the run log once and is Close's error; one that Close killed after channelClose, or that the dial's context killed as devvm desktop ends, isn't, as its end is the kill. startChannel, split from dial, starts any command as a channel, for the test. Tests: TestHandleReaped (fails without the nil-state handling: "<nil>" and a nil-pointer panic), TestDesktopChannelClose (fails without Close keeping Wait's error). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
ddb06b1ea7 |
docs(skills): the codebase-standards skill, a short checklist from what reviews kept finding, and how new code matches the codebase
A new project skill, .agents/skills/codebase-standards/, curated from
what reviews of devvm's whole history kept finding. A standard stays
only when it recurred or was costly, and a contributor can apply it
while writing or reviewing; what the linters and the structure test
enforce is only in rules.md's guard tables.
- SKILL.md: the checklist of 13 standards in four groups (safety,
failures and processes, changes, tests), a Match the codebase
section (names and files, comments, errors, dependencies as fields,
table tests, scripts in the VM, prose), how to review a change, and
the bar for adding a standard.
- standards.md: one section per standard, with its rule, what the
reviews found and its guard:
- Fail closed, on every path (a weaker mode only when visible,
documented and chosen, as the proxy's warn-and-run without a
sandbox)
- Bound what you don't control (listeners, locks, overflow, a capping
writer that doesn't embed its buffer)
- Treat what a VM can write as hostile (descriptors, signed sources
and re-hashing, escaping, host tools by absolute path)
- Keep secrets and host data on the host (no argv or shared
environment, allowlists into the VM, logs redacted)
- Parse once, with a real parser (IPv6 and its IPv4-carrying forms)
- Never fail silently, and name the real cause
- Give every process an owner that ends it (accept loops included)
- Survive a kill and a second devvm (one good copy, OS file locks)
- Extend the owner, and wait for a third copy (an existing owner is
always extended; a copy of a judge gets one owner at once)
- Mind what's already running and released
- Claim only what the code does, where precision belongs (headline
pages keep their short claims)
- Prove each fix with a test that fails without it (outside oracles,
controls for absence checks, sandboxes proven by attack)
- Write tests that pass on any host, at any load
- rules.md: the rules whose home is AGENTS.md or Contributing, by area,
each with its guard or review only.
- AGENTS.md: a rule line for the skill and its row in the layout, and
the owner rule's wait-for-a-third clause, which Contributing's
structure page explains.
- Contributing's first paragraph links the skill.
- The docs-voice skill's scope, .vale.ini, mise run lint:docs
(markdownlint and Vale) and TestCommandLines cover the new skill.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
1a16b1bb73 |
build(nilaway): the baseline follows three triaged findings the harden stack reshaped
The agent relay's finder calls the VM state's Name directly, the links report is read through safefile.Read rather than os.ReadFile, and the rotation's Stat finding is gone with the broker's descriptor-based copy. The two that remain are the same false positives in new shapes: fst is set together with found, and from is reset when the data is shorter. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
df1d76bbd9 |
fix(desktop): devvm desktop's relay goes on after an accept error
devvm desktop's relay returned at any error from its listener's Accept, so running out of open files in a burst (EMFILE) ended devvm desktop. It now waits and tries again, as devvm's other accept loops do, with their one owner, daemon.AcceptRetry: 5 ms, doubling up to a second, logging only the first error of a run, and it still ends with its context or its listener's close. - internal/desktop/relay.go: Serve uses daemon.AcceptRetry. - Tests: TestRelayAcceptRetries (a listener that fails three Accepts with EMFILE, then carries a viewer; the run logged once). - Docs: processes' desktop relay, structure's internal/daemon row; CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3da38436a7 |
feat(proxy): the broker opens the child's connections; its sandbox refuses it every one of its own
A sandbox fixed at the child's start can't tell this machine's loopback, its own addresses and the LAN apart from the internet as a rule changes, so the child's sandbox now refuses it every connection of its own, and the broker looks up each name and opens each connection for it, once its own read of the VM's policy and of the host's addresses allows the address, as the floor does. A child that a VM takes over reaches 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; a company proxy, which the child still speaks to with its password, reaches whatever it reaches. - wire.go: lookup (a host name, absolute, with its trailing dot), dial (an address and a port, or the https or http company proxy of the broker's config, never both), the connection as the reply's one descriptor, and cancel, for a lookup or a dial the child gave up on, which frees its slot. - dial.go: the broker's own egress (newBrokerNet: the VM's built-in policies, its policy files, looked at on every dial, and the host's addresses), lookupable, broker.lookup, dial and dialProxy, within 20 s and 15 s; the child's side (brokerClient.lookup, dial, dialProxy) wired into its egress by throughHost; the resolver's errors as codes the child makes into net.DNSError again. - broker.go: the caps (256 lookups, 1024 connections at once); its line for each failed lookup and connection, which the VM drives, at most 20 a minute and then one that says it stops (logFailed, perMinute in limits.go, which egress.abandoned now shares). - child.go and confine.go: every lookup and connection through the broker; the child lowers its open files, soft and hard, before it's confined (limitFiles). - seatbelt: the child's profile allows no network out, TCP, UDP or a unix socket, nor mDNSResponder. - landlock: the seccomp filter refuses every socket but a netlink route socket, connect, socketpair, listen and MSG_FASTOPEN on sendto, sendmsg and sendmmsg; Landlock no longer opens the resolver's files below /etc. - Tests: the broker's dial and its rules (TestBrokerDial, TestBrokerDialFollowsRules, TestBrokerDialProxy), lookups and their errors, cancel, the client over a real socketpair, TestBrokerFailedLogCapped, TestPerMinute, the filter's programs, the child's own connections refused under Seatbelt and under Landlock and seccomp. - Docs: the design note's broker (what crosses to the broker: the names and addresses, never a connection's bytes), its threat check, network's The child's sandbox and proxy.log, processes, attack vectors, troubleshooting, testing, tests, the proxy's README; CHANGELOG, with the company proxy's reach. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
7bc886133d |
fix(proxy): the broker frees a request's slot as its reply goes; start tests wait out a loaded host
The proxy's start and broker tests failed on loaded hosts, most on the linux host under the race detector. The causes: - Start timeouts (TestAgentRelay, TestMainRuns, TestMainRefuses, TestStartChildSandbox, TestV010ProxyConfigsStart, TestHandshakeChildGone): a broker's start, timed from its own, hashes its executable (selfSum), and the in-process child's spawn hashed it again. Under -race with the package's other tests, each hash took 2-3.5 s on the linux host, so starts passed startWait's 4 s (a start frame's write timing out, a relay or a proxy not listening within the test's 2 s of retries). IO gets a startWait field, a test seam; inProcess sets it to testStartWait (30 s) and hashes the test binary once per inProcess, and the tests wait as long for the proxy (retryFor). devvm's own proxy still waits 4 s. - TestBrokerClientGivesUp's "busy": a real bug. The broker gave a request's slot back only after its reply was written, and the child gives its own back as the reply arrives, so a child that kept the caps and sent its next value at once could get busy. answer now frees the slot once the reply holds the socket's write lock, just before it's written (frameConn.sendThen), so a reply that waits for a child that doesn't read still holds its slot and the bound stays. TestServeChildFreesSlotsAsRepliesGo checks both, in a synctest bubble, and fails without the fix. The broker isn't released yet, so no CHANGELOG entry. - TestSpliceKeepsAnEarlyAnswer (1 in 20 on linux under -race): splice could put the whole 4 MiB answer into loopback's buffers and close before the test's delayed upload arrived, which then reset the connection and dropped the unread answer. The test's server now answers once the upload's first bytes reach it, as a 413 does. Coverage: internal/seatbelt has 53 statements, and the mini's unit and CLI runs cover 51 (96.2%) every time; 97.4% isn't k/53 for any k, so the baseline was measured on an earlier version of the package (37/38). The two misses were ProxyChild's branch for a profile that can't be made, now tested, and ChildProfile's template panic, which can't happen. darwin's baseline rises to 98.1. Docs: the design note says how the broker's caps never refuse a child that keeps them; Contributing's tests page covers testStartWait. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1793353dd9 |
feat(proxy): Linux confines the proxy's child with Landlock and seccomp
Before it reads a byte of the VM's, devvm _proxy-child confines every thread of itself through proxy.confineSelf on Linux: no_new_privs (syscall.AllThreadsSyscall), Landlock from ABI 2 (TSYNC from ABI 8) to its logs folder, the Nix cache and the resolver's files (never /, the home folder or one that holds it), binding no TCP port (ABI 4), scoping signals and abstract sockets (ABI 6, or ABI 6/7 with erratum 2), refusing named unix sockets (ABI 9) and UDP but to port 53 (ABI 10); then a hand-written classic BPF seccomp filter, installed with TSYNC, that refuses with EPERM AF_UNIX socket/socketpair, listen, io_uring, ptrace, process_vm_readv/writev, pidfd_getfd, a file's mode, owner, xattrs and times by its path (chmod, fchmodat, fchmodat2, chown, lchown, fchownat, the six xattr calls, utime, utimes, futimesat, utimensat with a path), truncate, the keyrings (add_key, request_key, keyctl), prlimit64 on any pid but 0, setpriority, ioprio_set, sched_setaffinity, sched_setscheduler, sched_setparam, sched_setattr, inotify_init, inotify_init1, inotify_add_watch, fanotify_init, fanotify_mark, execve, execveat, fork, vfork, unshare, setns, bpf, userfaultfd, perf_event_open, clone for anything but a thread or with a namespace's flag, and clone3 with ENOSYS; it kills a foreign architecture's call or an x32 number. fchmod, fchown, ftruncate and utimensat on a descriptor stay. It checks the confinement holds, then proxy.checkConfined, and that it still reads the host's addresses, within 2 seconds, or fails the start. A kernel without Landlock or seccomp leaves that part out; the child runs and says so. The broker sets itself undumpable (PR_SET_DUMPABLE 0). The Nix cache marks a file used through its descriptor. The broker's start, and its life with the child, take a reset of the socket (ECONNRESET, Linux's end of a socket closed with frames unread) as the child's end, as EOF is (socketEnded, TestHandshakeChildGone). Built on the Seatbelt item's shared owner, proxy.Confinement: - internal/landlock (new, stdlib only, Linux build tags): Self, Result, Floor, ABIPorts/ABISignals/ABIUnix, ErrUnsupported; landlock_linux.go (resolverFolders, refusedFolder, homeFolder), filter_linux.go (filter, asm, encode, archOf), seccomp_linux.go, self_linux.go (Self, check, refused). - internal/proxy: confineSelf on Linux calls landlock.Self; landlockConfinement words it (By landlock, seccomp; Why no-landlock-or-seccomp, no-landlock, no-seccomp, landlock-below-abi4, landlock-signals; full from ABI 6 with seccomp and scoped signals); confineChild takes the child's needs and returns an error, bounded by confineWait (within, confineWith); checkConfined only where Landlock or Seatbelt confines files; confineStarted; IO.confine required, set by ChildMain alone; hostAddrs.check; touch_linux.go and touch_other.go (touchFile, undumpable); IO.dumpable for tests. - devvm doctor: netpolicy.Unconfined's Linux warnings (proxy_unconfined_no_kernel, _no_landlock, _no_seccomp, _old_ports, _old_signals). - Tests: TestFilter and TestFilterBytes (an interpreter of the program's bytes, amd64 and arm64, and the assembler's refusals), TestSelf (a real confined child: outside file, ssh-like unix socket, listen, bind, signal, chmod, chown, setxattr, utimes, truncate, a keyring, unshare, exec, clone3, and new threads, fchmod, ftruncate and futimens kept), TestKernel, TestCheck, TestRights (refusedFolder), TestArchNumbers, TestLandlockConfinement, TestConfineWithin, TestCheckConfined, TestConfineStarted, TestRunChildOn, TestUnconfined; network.txtar; e2e network's Landlock, NoNewPrivs and Seccomp check. - CI: a nocgo job (CGO_ENABLED=0) for internal/landlock and internal/proxy. - Structure test, depguard, goroutineSites; docs: the child's sandbox, processes (and its why-Go note on unsafe), design (the network row's loopback follow-up on Linux, other processes and /proc without Landlock), doctor's checks, troubleshooting, attack vectors, Contributing, the proxy's README, AGENTS.md, CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
941c63c696 |
feat(proxy): the proxy's child runs under Seatbelt on macOS
On macOS the broker starts devvm _proxy-child through /usr/bin/sandbox-exec -p PROFILE, by devvm's real path, with a deny-default profile, so the child is confined from its first instruction: devvm's binary to run and read, its folder's metadata, dyld-support.sb, /usr/lib and /System/Library, the time zone and resolver files, its logs folder and the shared Nix cache (regular files only, no hard links, no folder removed, no flags, ACL, owner, set-id or xattr changes), stat alone on the watched files and every link on the way, trustd and trustd.agent, mDNSResponder's socket, TCP and UDP out (loopback left to the floor: a rule for a loopback port applies at once, which a profile fixed at the start can't follow), sysctl but kern.proc, signals to itself. No home folder, no devvm folder but its own, no Keychain, no other unix socket, no bind, fork, exec, signal to or look at another process (process-info, the process list). - internal/seatbelt: the shared owner of Seatbelt (Exec, String, Path, Links, ChildProfile, Sandbox.ProxyChild); sbString, sbPath and sandboxExec move here from the Lima backend, which uses them. ChildProfile refuses a relative path and the root. - internal/proxy/confine.go: the confinement report every platform shares (Confinement, ParseConfinement, ReadConfined: one line of fixed words in run/proxy.confined, refused unless it parses, and unless it fits what the broker started the child with), the child's self-check (checkConfined: its broker's config must be refused), and the in-process hook (confineSelf, confineself_linux.go and confineself_other.go) for the Landlock follow-up. - internal/proxy/childstart.go: startChild, childSandbox, childNeeds; IO.Seatbelt, set by devvm _proxy on macOS. A missing sandbox-exec, or one that failed before devvm's code ran (exit 65 or 71, or SIGABRT or SIGKILL, before the child answered, decided before the broker's own stop), starts the child again unconfined within the broker's 4 seconds, with a warning in proxy.log; any other failure fails the start. The broker makes the Nix cache's folders first. start carries how the broker started the child (Spawned). - watched.get: a stat refused for want of permission reads through the broker each time (a watched link pointed elsewhere after the start). - daemon.Handle.ExitCode and ExitSignal. - devvm doctor warns for each running VM whose proxy's child isn't fully confined (netpolicy.Unconfined; proxy_unconfined, proxy_unconfined_unsupported, _no_sandbox, _sandbox_failed, _check_failed). - Tests: TestParseConfinement, TestCheckConfined, TestReadConfined, TestStartChildSandbox (an over-claiming ready, SIGTERM), TestSandboxFailed, TestChildNeeds, TestWatchedStatRefused, TestUnconfined, TestString, TestLinks, TestChildProfile, TestProxyChild, TestChildProfileConfines (the test binary run again under the profile on macOS: flags, rmdir, the process list), doctor's report, ExitCode and ExitSignal; e2e network checks run/proxy.confined is full seatbelt on macOS. - Docs: How it works' The child's sandbox, Processes, the design note's confinement and threat check (loopback as open work, other processes' details and kern.procargs2, the shared folders' flags, mDNSResponder's records, trustd.agent's trust settings, the fallback's signals, a ready that claims more), Troubleshooting's The proxy runs without a sandbox, Staying safe's escaping the VM, doctor's checks, Contributing's packages, the proxy's README, AGENTS.md, CHANGELOG. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
63bb1ff9a8 |
fix(network): a confined VM's programs ask 127.0.0.1 directly, so names fail at once
With transparent mode off or stopped, a confined VM's only name server, 127.0.0.1 (Lima's DNS setting), has nothing listening. glibc asked it through systemd-resolved's stub, which could keep retrying it over UDP and TCP without answering, so a lookup such as getent's waited out its timeout instead of failing at once (seen on a Linux host: e2e network's checks of DNS with transparent mode stopped and off). Each launch's setup now replaces /etc/resolv.conf, the stub's link, with devvm's own file on a confined VM: nameserver 127.0.0.1 alone, the stub's search line, timeout:1 attempts:2. glibc gets a refusal at once with nothing listening, and dnsmasq's answer through transparent mode's nftables rule when it runs, as musl on Alpine does. An open VM gets the stub's link back. Only systemd guests that have the stub's file and whose /etc/resolv.conf is its link or devvm's own are touched. Root cause, as far as it could be pinned down: with resolved's stub in the path, a lookup depended on resolved's retry loop over a server that refuses everything (24 attempts, flipping UDP and TCP feature levels), and on the linux host that loop sometimes never answered the stub within getent's 3 s. It didn't reproduce on demand (a base run on the linux host passed both checks, and bursts of 200 parallel lookups and stops mid-lookup all failed in under 2 s), so the fix takes resolved out of glibc's path rather than tuning it. Going back to open restarts systemd-resolved: it reads a /etc/resolv.conf that isn't its own link as global servers and search domains, so it had taken 127.0.0.1 and "~." from devvm's file, and kept them once the link was back, which left an open VM unable to resolve names (caught by e2e network's open checks on the linux host and ubuntu). Review folded in: no change of a foreign or dangling link when the stub's file is missing; two attempts; Docker's user-defined networks in the docs. Second review: devvm's file alone is enough to go back on an open VM (a warning when the stub's file is missing); a failed write says so in one line and the launch goes on; troubleshooting's "An open VM resolves no names after a downgrade"; tests for resolved's own resolv.conf link, an open VM without the stub, a non-systemd guest with devvm's file and a failed write. workerd under wrangler dev, checked by hand on fedora with transparent mode off: its fetch fails at once (Temporary failure in name resolution), so the "about 40 seconds for each lookup" sentence is gone from lima.md, safety/network.md and troubleshooting.md, and testing.md's manual check covers it. testdata/coverage/darwin.txt: internal/sshagent's baseline rose with mise run coverage (unrelated to this change). - backend.Confinement.Resolver: the one owner of a confined guest's name server; Lima's start sets .dns from it, sync.go sends it to the setup as DEVVM_RESOLVER; sync.go's setupInputs as mise run fmt writes it. - assets/guest/sync.sh: resolver_conf; its unit test runs the function (internal/vm/resolver_test.go). sync.sh runs at each launch and goes in no image, so no image key changes. - CLI tests: DEVVM_RESOLVER on confined (transparent on and off) and open VMs. e2e network: the stopped-transparent check also checks the file. - Docs: network.md's The VM's resolver, lima.md, design.md, tests.md; CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
aeea3135b2 |
feat(proxy): the proxy's broker and its child
A VM's proxy runs as two processes, as design.md's "The proxy's broker"
says: devvm _proxy, the broker, which keeps what only the host should
do, and devvm _proxy-child, which reads the VM's network and can be
confined by the follow-ups.
- wire.go: the protocol over one socketpair (close-on-exec from the
start: SOCK_CLOEXEC on Linux, ForkLock elsewhere), length-prefixed JSON
frames of at most 2 MiB, unknown fields refused, bytes as base64, one
descriptor on a frame's first bytes (SCM_RIGHTS, MSG_CTRUNC breaks the
rules), wire types for every secret (redact.Secret at once).
- broker.go: newBroker, the start (handshake: version 1 and each side's
executable's SHA-256, within 4 s), the answers (value through lookups,
kept 30 s or 5 min, a failure 5 s, dropped when the bindings change;
file by number; link connected by the broker and passed as a
descriptor; token exchanged by the broker), each by something in its
own config, with caps 1/8/4/256; live: the lifeline closes the socket
and kills the child 6 s later, SIGTERM stops it within a second, a
child that ends ends the broker, a rule broken stops the child.
- child.go: the start (startOf), the child's server (newChildServer),
the broker as hostSide over the socket (brokerClient), runChildOn;
ready only after it reads the host's addresses (kept: the last good
read), roots and time zone loaded first.
- process.go: Main(ctx, ...) and ChildMain; the child spawned with
/proc/self/exe on Linux, PR_SET_PDEATHSIG from a locked thread
(daemon.Cmd.DieWithThread), descriptors 3 and 4, and TZ, SSL_CERT_*
and GODEBUG with updatemaxprocs=0 alone; run/proxy-child.pid and
run/proxy.confined ("none" until the follow-ups); KeepLogs in the
broker. ChildMain refuses to start unless descriptors 3 and 4 are a
unix socket and an IP one (checkInherited): run by hand, without
them, those numbers can be the Go runtime's own, which closing
crashed it (signal_recv: inconsistent state).
- capture.go: a captured token request goes to the broker
(captureToken, exchanger), so a login's real tokens never enter the
child; an error reply passes up to 1 MiB, longer gets 502.
- watched.go: the child stats each changing file and asks the broker
for it once it changed, keeping the stamp of what the broker read.
- rotate.go: proxy.log rotated by both through its descriptor, under a
lock of a description of its own; OpenLog opens a log never through a
link, one link, yours, replacing what a child left in its place.
- nixcache.go: the trim and its count through a safefile.Root, nar/
only as a folder, links deleted as themselves; reads never through a
link; the lock tried for 5 s (ErrNixLocked, nix_cache_locked).
- daemon: Cmd.Err, Files, Env, DieWithThread; Handle.Kill, Exit;
WritePID.
- netpolicy: Proxy.Stop also stops a child that outlived its broker
(run/proxy-child.pid, _proxy-child -for); proxy.log opened with
OpenLog; a refused launch keeps a running VM only while both run.
devvm network log and lock read the event log through safefile.
- vm, vmssh, vmlog: links.log and ports.log opened with OpenLog, read
through safefile, trimmed only as a regular file with one link.
- backend: the build proxy's logs in a logs/ folder of their own.
- cli: _proxy-child; _proxy waits for its child on a signal
(StopsItsOwn); the child reads none of devvm's folders (no
makePrivate); ui.Files.
- Tests: FuzzBrokerFrames, the frames' rules, the handshake and the
pair's end in synctest bubbles, the caps, the broker naming its own
alone, the client over a real socketpair with a passed descriptor,
ChildMain, TestInheritedSocket and proxy.txtar's child run by hand,
the frozen 0.1.0 configs starting a broker and child,
two writers rotating once, planted links, FIFOs and hard links; the
testscript runner stops _proxy-child too; e2e: broker and child, their
arguments, descriptors and environment, stop, SIGKILL either, planted
files in the logs folder and the Nix cache, build proxies gone.
- Review fixes: the lifeline closes the socket and starts the kill's
timer before logging; every log lock (proxy.log's, the event log's
rotation) is tried without blocking for 200 ms (flockWithin, which the
Nix lock shares), then written without or the rotation skipped; a
copied log's rotation streams at most twice its limit from a line's
start (copyFrom, copyAtomic); a reply too long to send goes as
too_long; kept token headers capped at 1 KiB; the child gives up on a
request whose context ended, dropping its late reply and holding its
slot until then; a write deadline on the start frame; errors reach the
child as codes (not_found, refused, busy, too_long, failed), their
text in the broker's log; FuzzFrameStreams, and FuzzBrokerFrames
writes from a goroutine; nix_cache_locked links to How it works.
- Docs: processes, network, overview, design (with threat rows for the
logs' locks and a log made huge), troubleshooting, the proxy's
README, structure, testing; CHANGELOG.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
9c74dac11e |
fix(logs): a VM's logs are held to their caps while it runs
internal/vmlog owns every log a VM can drive but the proxy's own: Limit (moved from vmssh's logLimit, with Allow for the link session's warnings), Capped and Trim for ports.log and links.log while they run, and KeepVM, which the VM's proxy (proxy.IO.KeepLogs, Config.VMLogs from backend.Run.Logs) and a Lima build run on the serial consoles' and the hostagent's logs: redacted as they grow (redact.FileFrom), so a reboot in place can't leave the proxy password there, and rotated past 10 MiB, counting what a log holds past the hole its writer left (platform.DataStart). The proxy's http.Server logs through its own limited log, and its copied log counts what reached it as stderr; the build proxy's log is held as a VM's proxy's is. git-pins.jsonl has a cap. Run logs take at most 256 MiB together, never the newest or a live run's. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4a4aabe9a8 |
fix(netpolicy): a refused launch leaves a running VM and its proxy as they were
With config.toml's proxy naming a user and no proxy secret saved, devvm in a running VM's folder refused (proxy_password_missing) but stopped the VM (net_proxy_down_stopped), and devvm restart stopped it before refusing. Every check that can refuse a proxy start already ran before Prepare stopped the old proxy; runningConfinement stopped the VM on any error. - netpolicy.Proxy.PrepareRunning: Prepare for a running VM. A refusal before its proxy is touched keeps the VM and proxy (net_proxy_kept, a new message) only while that proxy enforces the state's tier now (enforcesNow: built-in, files, denies, open, devvm binary); otherwise, or once its proxy was stopped or started, or with none running, the VM is stopped (unproxied, was Unproxied, which now stops a proxy left running too). - netpolicy.Proxy.Refusal (shared): the user's CAs and the company proxy, checked first in prepare, before a VM is made (up), before a running VM is stopped to start again (target.stopToStart: devvm restart, restartForNextStart), and before a running VM's tier changes between confined tiers (checkTier: devvm network, lock), so its state never names a tier its proxy doesn't enforce. - devvm network's change to a running VM's rules goes through PrepareRunning, so a proxy that can't start again stops the VM rather than leaving it running without one. - Proxy.Upstream removed (no callers); shared, prepare, unproxied and tierNow are functions of the proxy, keeping Proxy within 24 methods. Tests: company_proxy.txtar (launch and restart refused, VM and proxy untouched; devvm network allowlist refused, tier unchanged), TestPrepareRunningRefused (eight rows), e2e corpConfig checks the VM's status after the refused launch. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
90a64a44d1 |
fix(races): lock order checked, sandboxes' own ports, pins that meet a rename, daemons' groups stopped
- state: test builds and tests check the state locks' order (state.held, CheckLockOrder): a second VM's lock, a VM's lock under the claims lock, or a lock taken again panics before waiting. - platform: PinBeneath opens the path again when a rename takes the file away before move_mount (ENOENT), so the keeper no longer reports a false lost pin (TestPinsInNamespace's 'f lost / f pinned-again'); TestPinWhileRenamed. - daemon: Proc.Stop signals the process group (SignalGroup), so forwarders' and link sessions' ssh masters and relays end with them; ui.UI.StopsItsOwn makes _ports and _links wait for their ssh on an outside SIGTERM. - vm: gc --orphans and devvm space count forwarders' leftover control sockets (vmssh.ControlGlob). - CLI tests: each sandbox claims a block of ports below devvm's range and the ephemeral range (claimPortBlock, /tmp/devvm-test-ports); free_port, the fixtures' ports and DEVVM_SSH_PORTS come from it, and the sandbox's devvm chooses from its own range (DEVVM_PORT_RANGE override). Fixtures' forwarded ports and settings ports are rewritten too (FIXTURE_PORT_<port>). - netpolicy and vm tests: the fake proxy's stop waits for its reap, and fake daemons run until the test ends, not 30 s. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
11ccecca15 |
docs(design): the proxy's broker, a design note for splitting devvm _proxy
The design note for splitting the VM's proxy into an unconfined broker and a network-facing child that can be confined: what runs where and why, the files and sockets each side needs, the protocol (a socketpair, framed JSON with caps, versioned, failing closed, naming nothing but the broker's own VM's), the token exchange in the broker, the Secret type on the socket, the start, the end and how tests find each process, the build proxy, upgrades and the frozen configs, what Landlock and Seatbelt will confine in the child, performance, the options weighed and the threat check. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
a7cc12521e |
test(fuzz): fuzz targets with properties, fuzzed nightly
Twenty-three new fuzz targets, built-in Go fuzzing, each checking a property rather than only that nothing panics: parsers of what a VM or the network sends fail closed and keep to their caps, a secret goes only where it's bound, and no planted secret survives a redaction. - internal/proxy: FuzzCursorFrames (passes only what came; no message over frameMax or holding a JWT's start, decompressed and unescaped), FuzzInject (a binding's value only to a host it names, judged apart from the matcher in NormHost's form, for its path and methods, in its own header, which held the exact placeholder once; other headers untouched), FuzzParseBindings, FuzzLinkList, FuzzParseUpstream (errors hold no more of the URL than its scheme), FuzzNoProxy, FuzzParseNarinfo (only cache.nixos.org-1's signed narinfo is taken). - internal/agentlogin: FuzzParseTokenRequest, FuzzRedact (secrets planted eight ways in JSON and TOML settings), FuzzCapture (the VM's reply holds none of the endpoint's tokens). - internal/redact: FuzzSplit (a password written in parts through Split, as the run log writes it, never survives). - internal/jsonc: FuzzStrip, differential against encoding/json. - internal/upgrade: FuzzParsePublicKey, FuzzVerify, FuzzEntryName, FuzzUnpack. - internal/vmssh: FuzzParseHostKeys, FuzzParsePorts. - internal/vm: FuzzParseCloneState, FuzzParseInit, FuzzParseKept, FuzzParseLFSPointer. - internal/desktop: FuzzHandshakeVM. What they found, each fixed with a regression test: - NO_PROXY: an entry with port 0 (git.test:0) was read as the host on every port, and git.test:080 or :+80 as port 80, which Go's clients match against nothing; an entry whose port no request has, or that isn't plain decimal, now matches nothing (TestNoProxy, testdata/fuzz/FuzzNoProxy). FuzzHostSites' NO_PROXY site allows this difference from its frozen copy, and the design note lists it. - A JSON token request with more after its object was judged by its first object; it's refused now (TestCaptureRefuses). The Fuzz workflow runs nightly rather than two minutes weekly: five minutes a target, eight at a time, each target's corpus restored from and saved to a cache of its own (a failing input added to it, so it fails nightly until fixed), new inputs minimized in at most 1,000 runs, and one issue, "Fuzzing found failing inputs", opened, commented on when the failing targets change and closed on a clean night, by a separate job with issues: write that runs no repo code, on main alone. Target names must be unique across packages. bump.sh moves an action in a folder of its repo (actions/cache/restore, /save) with its repo's releases. Docs: Contributing's Fuzzing (running a target, the nightly run, every target's property), Maintaining's Fuzzing failures and its actions bump, the proxy README, the NO_PROXY and token request facts in How it works' network page and the design note. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
19f9900b86 |
fix(sshagent): a VM reaches its SSH agent only through its proxy's relay
OpenSSH's ssh-agent answers every request a forwarded connection sends, so a VM that forwarded your agent or devvm's own (shared by every VM that uses it) could remove all its keys (ssh-add -D), lock it with a password of its own (ssh-add -x) or add keys without bound, denying the agent to you and to the other VMs. Checked with a throwaway sshd and ssh-agent: all three succeed over ssh -A. Each VM's proxy now relays the agent its start chose on a socket of the VM's own (paths.Dirs.AgentRelay, run/agent-<hash>.sock, mode 600), and the VM's backend, devvm's own connections and the ssh entries for editors name that socket. The relay passes on only SSH_AGENTC_REQUEST_IDENTITIES, SSH_AGENTC_SIGN_REQUEST and the [email protected] extension (so destination-constrained keys keep their constraints), answers everything else with SSH_AGENT_FAILURE, reads messages whole up to OpenSSH's 256 KiB, carries at most 16 connections and closes one idle for 2 minutes. A filtering relay rather than an agent per VM: it covers your own agent too, needs no copy of a key or a passphrase per VM, and fronts hardware and app-held keys. - proxy: Config.Agent/AgentSocket (checked together, absolute), the relay in agent.go, listened before the proxy says it's ready; its accept loop backs off after an error that leaves the listener open (EMFILE), 5 ms doubling to 1 s, logging the first. - daemon: AcceptRetry, vmssh's acceptRetry moved to the stdlib-only package the proxy already imports, so the relay, the port forwarder, the link session and a login's forward share one owner. - netpolicy: Prepare takes a start's agent; a running VM's proxy keeps its start's agent from proxy.json (relayedAgent); Stop deletes the relay's socket. - structure: paths.Dirs may have 62 methods (AgentRelay); the relay's goroutines in goroutineSites. - sshagent: Made.Relayed, which RecordStart sets on every start of this devvm's whose choice forwards an agent, one without SSH_AUTH_SOCK included, and ReachOf(st, start): a relayed start gets the relay (or none while it's down), a start devvm didn't record (one outside devvm) gets none, or its proxy's relay, and only an older devvm's recorded start keeps the raw agent until its next start (runningConfinement, finder.inspect, sshconfig). - vm: LeftoverSockets also finds a killed proxy's relay socket for devvm gc --orphans and devvm space. - Tests: relay filter, wiring through Main, bounds and idle close, real ssh-agent/ssh-add/ssh-keygen through the relay, Prepare's relay, RecordStart/Relayed, sshconfig entries, vm agent tests, ssh_agent.txtar, an outside start in ssh_agent.txtar, and e2e checks that the VM can't remove, lock or add to your agent, nor the VM or an editor's connection remove devvm's agent's keys. - Docs: processes (the SSH agents, listeners), ssh, attack-vectors, security, design, lima, overview, space, structure, proxy README, AGENTS.md, CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
f37c70a5cd |
fix(bounds): bound what a VM can make the host hold
Five bounds, each with a test that failed first. Long downloads,
WebSockets, slow streams and SSE are never cut: every bound is on what a
connection holds, never on how long it lasts.
- _qemu connect (Linux): each guest connection to the proxy was a host
process with no cap. Connect now takes one of connectMax (256) slots,
lock files in the VM's run/proxy.slots (paths.VM.Proxy(".slots")),
each process about 7.7 MB, so about 2 GB per hostile VM. A connection
past them gets an HTTP 503 (connectsFullReply) and closes before it
dials; QEMU's stderr says qemu_connects_full at most once a minute,
decided under full.lock so refusals at once say it once. A VM started
before keeps the two-argument form, unbounded until its next start.
No idle timeout or byte bound: the proxy bounds what each carries.
TestConnectSlots.
- The VM proxy (limits.go):
- maxConns (2048, twice maxConnects so a CONNECT still gets its 503
first) counts a connection from its first request with the VM's
password (conns.admit, via httpServer's ConnContext); a request past
it gets 503 and the connection closes. Connections without the
password wait in a pool of maxWaiting (128) where a new one closes
the oldest, so holding connections can't take a VM's room (a host-speed flood still slows it
through the accept queue: listed in design.md).
- maxRequests (2048) requests upstream at once, plain HTTP's and
intercepted tunnels' (requests.take), 503 past it: per-tunnel
HTTP/2 streams alone allowed ~100,000 upstream connections.
- each limit logs once a minute at most (everyMinute).
- httpServer adds IdleTimeout (10 min); a 407 closes its connection;
handleHTTP's WithoutCancel is replaced by whileHeard, which ends a
plain HTTP request once its client has stopped sending and goneWait
(1 min) passes with nothing written, so half-closing clients still
get answers that keep coming; quiet WebSockets aren't cut.
- heardWriter.Unwrap: plain ws:// upgrades got 502 (pre-existing) and
get 101.
- No ResponseHeaderTimeout: non-streaming LLM requests wait minutes
for headers, and a waiting client is counted.
Tests: TestProxyLimitsSet, TestProxyConnectionBounds,
TestProxyConnectionLimit, TestProxyWaitingConnections,
TestUpstreamRequestLimit, TestUpstreamRequestLimitIntercepted,
TestPlainWebSocket,
TestPlainHTTPEndsWithClient.
- serveOne (intercepted tunnels, transparent HTTP, the 403 page) takes
maxHeaderBytes (64 KiB) always, not 1 MiB, and HTTP/2
MaxConcurrentStreams streamsMax (100, not 250). TestServeOneHeaderLimit,
TestServeOneStreamsLimit.
- Accept loops (forwarder, link session, login forward) retried nothing
or at a fixed 100 ms: vmssh.acceptRetry backs off from 5 ms to 1 s and
logs the first error of a run, ending only when the listener closes or
ctx ends. TestAcceptRetry, TestForwarderAcceptRetries,
TestLinksAcceptRetries.
- The login callback (LoopbackForward) carries at most
loopbackConnsMax (16) connections, an ssh each.
TestForwardLoopbackLimit.
Docs: processes, network, ports, lima, design (threat rows),
attack-vectors, the proxy README, CHANGELOG Fixed.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
c872cfe66c |
fix(proxy): look names up absolute, so the host's DNS search domain never applies
The proxy looked up the checked name without a trailing dot, so the host's resolver added its search domain: with api.corp.example denied and ** allowing the rest, CONNECT api:443 (or api.eu, once api.eu itself had no address) reached api.corp.example. Validated on macOS (a CGO_ENABLED=0 darwin build resolves through libSystem's getaddrinfo, which applies scutil's search domain) and on Linux (Go's resolver applies resolv.conf's search, single- and multi-label names, at ndots 1 and 5). egress.lookupName now asks for host+".", for direct connections and the company proxy's floor alike. A block because an allowed name didn't resolve is now Refused: a rule allows the name already, so its 403, /blocked/new and devvm network log --blocked suggest no devvm network allow command. A name without a dot that has no address gets reasonShortName, which says to use the full name. Tests: TestLookupIgnoresSearchDomain, with a resolver that has a search domain; TestShortNameBlock; TestUnresolvedReason checks Refused and the short name. Docs: safety/network (inside the VM, the refused field), internals/network (the proxy, the reasons), internals/design (a company proxy and its own search domain, links' short names), using/troubleshooting (a name that doesn't resolve); CHANGELOG Fixed. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
3168eb04ad |
test(e2e): a company proxy in config.toml, its password the proxy secret
The network section's company proxy came only from the shell's HTTPS_PROXY. Now config.toml's [proxy] names it with its user alone and the shell sets none: the launch is refused (proxy_password_missing) until devvm secret set proxy --stdin saves the password, in the run's own secret store; then the VM's proxy config names the secret and holds no password, and the company proxy, which refuses requests without it, carries github.com. Its password is in no process's arguments, log, proxy config or guest after. netNoLeaks looks for every company proxy's password the section used, netCorp's and netOpen's, as it is, as user:password, as Basic's base64 and as the whole Proxy-Authorization value, and for each VM's proxy password as it is and in Basic's base64, in devvm's logs, the VMs' proxies' logs and Lima's. corpThrough matches only the events after its launch, so an earlier launch's tunnel can't pass it (eventsFrom), and corpNoLeak is shared by both launches. netSetup deletes the section's secrets at its start as well as its end, so a proxy secret a killed run left can't let the refused launch go ahead, and it links the section's HOME to the Keychains folder on macOS from the start, as devvm secret set proxy is now its first Keychain write (netClaudeLogins made the link before). Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1b8fd8a639 |
test(lifecycles): synctest bubbles for the relays, the forwarder, the links, the proxy and the daemon's stop
Timeouts, graces and closes are tested in testing/synctest bubbles on the
bubble's fake clock, to the moment, instead of sleeping and polling on the
real one, with stand-ins in memory behind seams that are fields. Each kind
keeps one real-process test. No behaviour change: each seam's production
value is what the code did before.
Seams:
- vmssh: sshRelay{grace, start} carries a relay (pipeSSH's body, as
pipeSSHFor was); start is execSSH in production.
- vmssh: Links.Listen (listenSocket unless set), for the links' sockets.
- proxy: egress.connect, the dialer for allowed far ends (a net.Dialer
with its 15 s timeout, set in newServer).
- daemon: Proc.Alive (Alive unless set).
- proxy: httpServer, the proxy's http.Server as run serves it, which the
tests' memServe shares.
New test-only package internal/memnet (standard library only): Pipe, whose
connections half-close, buffer 64 KiB and have deadlines, and Network,
listeners by address with Listen, Dial, DialContext and SetDeadline. The
structure test keeps it for tests and a leaf, depguard keeps it standard
library only, and its AfterFuncs are in goroutineSites.
Bubble tests:
- relay: TestRelayGrace (silent and talking, closed and half closed),
TestRelayGraceSlowClient, TestRelayGraceWriteError,
TestRelayCancelEndsBlockedWrite, TestGraceTimer (exact grace).
- forwarder: TestForwarder, TestForwarderAliveOnEnd, TestForwarderOnly,
TestForwarderGap (reports exactly Gap apart), TestForwarderGivesUpSilently,
TestForwarderClosesConnections (now also its stuck relay's ssh and slot).
- links: TestLinks, TestLinksSessionLost, TestLinksCap,
TestLinksEndStuckRelays (memSSH; relays end at the next sync on removal,
master replacement and target change), TestLinksList.
- proxy: TestTunnelHelloDeadline (EOF at exactly helloTimeout),
TestTunnelHelloStall (and a hello whole a moment before the deadline),
TestTunnelAddressSplitHello, TestConnectLimit, TestCloseConns,
TestCloseConnsWaitsBounded (close gives up at exactly closeWait),
TestSpliceEnds, TestSpliceEndsWhenItsClientCloses.
- secrets: TestSecretLookupFailuresNeverCached (hung lookups cut at
lookupTimeout, cancelled, failed and empty ones never cached; a request's
end doesn't cancel a lookup; the TTL to the moment).
- daemon: TestProcStopWaitsForTheEnd, TestProcStopKillsOnlyItsOwn,
TestProcStopKillsAfterWait (fakeProc), TestFollowLifeline.
- TestCursorReplyScans uses httptest.NewTestServer.
Kept on real processes and the real clock: TestPipeSSHGrace,
TestPipeSSHGraceSlowClient, TestPipeSSHGraceWriteError,
TestForwarderEndsStuckRelay, TestLinksBurst, TestSpliceKeepsAnEarlyAnswer,
TestProcStop.
Docs: Contributing's Tests has Time and lifecycles; structure.md, _index.md
and AGENTS.md name memnet.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
4d409589bb |
refactor(redact): every secret's value is a redact.Secret, revealed only where it's used
redact.Secret holds a value that lets whoever has it act as the user or
a VM, behind a pointer, so fmt's raw printing of an unexported field
shows only an address. String, GoString and Format print <redacted> for
every verb; MarshalJSON, UnmarshalJSON and MarshalText return
redact.ErrEncode, so a secret is never silently written as a stand-in
(which would lose a login); there's no LogValue. NewSecret ("" is the
zero Secret), Reveal, Empty and TrimSpace are the rest. internal/redact
joins the proxy's standard-library-only depguard group.
Reveal is refused by forbidigo outside tests; each of the 23 call sites
carries a //nolint:forbidigo saying why, and testdata/lint/forbidigo.go
keeps a call the rule must report. The structure test (checkSecrets)
refuses a struct that embeds redact.Secret outside internal/redact and
an interface that declares Reveal() string.
Typed now: proxy.Config.Password (configFile is the wire type, in
Config's order, held to it by TestConfigFile), the server's password,
proxy.Lookup and the cached values, upstream.auth, upstreamPassword,
Upstream.WithPassword's password; backend.NewProxyPassword, ProxyURL,
Confinement.ProxyPassword, BuildProxy.Password; netpolicy.Key and
NetMade.ProxyKey (netMade wire type); settings.CompanyProxy.Password;
secrets.Store.Value, saved, ProxyPassword, Token, Save, save, Get,
SaveKey, Yours.Save, Claude.Env, saveToken, oauthToken; agentlogin
File.Get, SetKey, ClaudeToken, every format's get, setKey and chatGPT,
refresh's refresh token, capture's access, refresh and id tokens, and
the JWT helpers (a login's map stays the wire, through token and
setToken; piKey is piBound); vm.Net.SecretSave, AgentLoginOptions.Key;
ui.UI.Secret. Strings by design: platform.KeychainGet/Set and the
desktop's VNC password.
Tests: TestSecret (unexported and nested fields too), TestConfigFile,
TestV010ProxyConfigs (0.1.0's proxy.json round-trips byte for byte),
TestFixtureStoreGet saves the Linux secret file back byte for byte,
checkV010Logins (login files read, copied and bound without a change),
secretCases, and e2e netNoLeaks, twice in the network section: every
VM's proxy password and the section's values, also as Basic
credentials, in no run log or proxy log, and the passwords in no
ha.stderr.log or serial log. Docs: Contributing's Secrets in the code,
the owners table, the secrets How it works page, design.md's Where
secret values live.
Fixed, found by netNoLeaks: Lima's boot script 07-etc-environment.sh
runs under set -x, so the console logs (serial*.log) kept the VM's
proxy password; redactLog now stars passwords in them as it does in
ha.stderr.log (CHANGELOG, overview, processes and attack-vectors pages).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
e4ea123927 |
feat(ports): VMs' ssh on ports browsers refuse
Lima listens on a VM's 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 reached a server the VM controls with the cookies of every app on localhost, even in a VM that forwards no ports. - Every VM's ssh port, and every build VM's, is one of the 17 ports every browser engine refuses (ports.SSHPorts): the Fetch standard's bad ports from 1024 up that Chromium's kRestrictedPorts blocks too, which leaves out 4190 and 6679 (headless Chrome 157 loads both). The one allocator chooses it (Allocator.SSH and Build, through freeSSH). A stopped VM keeps its port while it's on the list, free, not listed to forward and not held by another start or build; else it gets one no state records, or else a stopped VM's, which that VM gives up at its own next start. Another VM's listed ports are avoided only while that VM runs or starts. - The proxy and desktop ports never take one (free); one an older devvm chose moves at the VM's next start (Choose's keep path, proxyPort, the desktop's listener; Allocator.SSHOnly). - A forwarder never takes one unless its VM lists it (ports.Reserved), so a guest forwarding every port can't fill them; devvm ports and each launch warn when a VM's list names one, whatever set it (--ports, a devcontainer.json, config.toml's ports) (ports_ssh_listed, ports.SSHListed). - A start holds its port, kept or new, for a minute in the VM's own run/ports.ssh-hold (paths.VM.Forwarder; hold, held, projectHold), which other starts and builds avoid, so none takes it before Lima binds it; it goes with the VM's folder. - A build takes its clone's own port (was) only when no other is free. - Past 17: ports_ssh_limit names the VMs whose recorded ports are in use ("a or b" for a port two states record) with how many are taken otherwise, ports_ssh_limit_all when they have them all, and ports_ssh_limit_others when none of your VMs has one. - Older devvm's ports move at the VM's next start, in startSets' one limactl edit, and the start pins the new host keys (pinHostKeys); a running VM keeps its port until then, and each launch warns of running VMs still on an off-list port (ports_ssh_old, Allocator.OffList, confirmed with the backend's Running). - A test build's own list (DEVVM_SSH_PORTS, registry.Overrides.SSHPorts, the Allocator's and the Proxy's SSHList field), read only by readOverrides in a test build: each CLI test sandbox gets as many ports of its own from below the ephemeral range (sandboxPorts). Frozen 0.1.0 fixture: each launch now makes exactly one limactl edit, of .ssh.localPort alone, onto the sandbox's list, and vm.json changes only in .ports.host.ssh (and the start it records); the fixture's data is untouched. Messages: ports_ssh_limit, ports_ssh_limit_all, ports_ssh_limit_others, ports_ssh_listed, ports_ssh_old. Tests: TestSSHPorts (Fetch's list less Chromium's gaps, SSHListed, SSHOnly), TestSSH, TestSSHHolds, TestSSHListed, TestOffList, TestBuild, TestReserved, TestForwardsHeld's reserved counts, TestStartBuildSSHPort, TestPrepareRestartsTheProxy, TestDesktopListener, TestOverrides (DEVVM_SSH_PORTS), ssh_ports.txtar, fixture_v010.txtar, layout.txtar; e2e project: the ssh port, first and after a move, is one browsers refuse. Docs: internals/lima (the ssh bullet, the hold's limit), processes (listener table), design (threat check), ports, overview, contributing/structure and testing (DEVVM_SSH_PORTS), using/ports-size, troubleshooting (Too many VMs at once), safety/attack-vectors (allowed ports, port squatting), CHANGELOG Breaking (17 VMs; forwarding every port leaves the 17 out) and After you upgrade. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
cc94465400 |
test(leaktest): goroutine leak checks, and the leaks they found
A new internal/leaktest, standard library only, so the proxy's and the daemon's tests use it too (depguard's proxy rule allows it, and the structure test holds it to tests and to importing nothing of devvm's): - leaktest.Main(m), in TestMain: once the tests pass, every goroutine's stack (runtime.Stack), a settle of 5 s, then a failure naming those still running, but the standard library's own that outlive every test (allowed: signal.Notify's loop, an HTTP client's idle connections); then Go 1.27's goroutineleak profile, which fails on any goroutine blocked for good. - leaktest.Check(t), first in a test: its own goroutines, followed by parent through those still running, and by which ran before it, never by ID (each thread takes a batch of IDs). Main runs in proxy, vmssh, daemon, desktop, ui, vm, backend/lima, platform, cli and gitprotect (main_test.go, or the TestMain they had). Check runs in TestLinksEndStuckRelays (replacing its NumGoroutine count), TestForwarder, the desktop relay's serve helper, TestRunChild, TestPinWaits, and the proxy's new close tests. The structure test's goroutines rule (internal/structure/goroutines_test.go): goroutineSites lists every function outside tests that starts a goroutine, with a go statement, a wait group's Go, or time's or context's AfterFunc, function literals in package-level vars included, as "file: Func", with its waiter, or "detached: " and why nothing waits. A new one fails until listed, a listed one that starts none fails, and a package that starts one fails until its tests call leaktest.Main. Leaks it found, each fixed with a test: - The proxy's close left its connections running: http.Server's Close neither closes a connection a handler took (a CONNECT's tunnel, a WebSocket upgrade ReverseProxy takes) nor waits for a handler. conns (conns.go) holds every connection the listener accepted (track) and counts every handler (handle); serve calls closeConns once Serve returns, which closes them, closes any accepted after, and waits up to 5 s for the handlers. splice also ends when its client's connection can't be read (closed, reset), rather than half-closing the far end and waiting on it; a failed write to the server (one that answered early and closed) still lets its answer through. Tests: TestCloseConns (a tunnel and an upgrade), TestConnectAfterClose, TestSpliceEndsWhenItsClientCloses, TestSpliceKeepsAnEarlyAnswer; the tests' listen closes as the proxy does, and the fake upstream closes its target once its client's end comes. - platform's runChild left its signal-passing goroutine blocked on a channel signal.Stop never closes; it now closes it and waits (TestRunChild). - platform's WaitExit and WatchFolders blocked in poll(2) and read(2), which closing their fd from the stop doesn't wake on every kernel (Debian's didn't), and a retried call could land on a reused fd. They now wait in Go's poller (pollable), which the stop wakes (TestPinWaits, with a wait stopped before its process ends). Docs: Contributing's tests page (Goroutine leaks), the structure page (the goroutines rule, goroutineSites, the layers, the packages), the Go lint rules' depguard line, the proxy's shutdown in How it works' processes page and the proxy's README, and AGENTS.md. Coverage baselines: internal/leaktest's line on both systems, netpolicy's raise on macOS. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
4e925492ca |
fix(proxy): every host is read in one form, proxy.NormHost, guarded by the structure test
Every check that judges or compares a host now reads it through proxy.NormHost (internal/proxy/host.go), which also holds HostOK, splitHostPort, hostASCII and asciiEqualFold: a host of printable ASCII is lowercased in ASCII alone and loses its one trailing dot; any other host stays as it is, so HostOK refuses it and no Unicode fold makes another name match. A host with two trailing dots or more, or a dot after a closing bracket, keeps them, so NormHost is idempotent and reading a host twice can't turn evil.test.. into evil.test. A proxy.Host is what the matchers take (rule.matchHost, noProxyRule.matches, local, sniMatches). Brackets are strict (hostAddr): HostOK, Host.Addr and splitHostPort take an address bare or an IPv6 address in one pair of brackets, never a stray bracket ([[::1]], 1.2.3.4]) or brackets around a name or an IPv4 address ([evil.com]:443, [1.2.3.4]:443), which get 400. Migrated: splitHostPort, sniMatches, sniHost, parseHostRule, the policy's rulesFor, quiet, byName and coversOn, secrets.forHost, parseNoProxy, route and local in internal/proxy; netpolicy.RiskOf, Tickable and sameRule (devvm network rm and the duplicate check, so a Kelvin sign never names the rule with a k); secrets.CheckHost; from.publicHost (a name HostOK refuses isn't public); agentlogin.claudeHost; vm.urlHostPort and privateHost. vm.urlHost (cloneseed.go) keeps its own reading: it's a remote's ssh host, which ssh lowercases and keeps the trailing dot of, to find a VM's alias. Differential fuzz targets keep a frozen copy of each reader as it was and allow only the decided differences: FuzzHostSites (proxy), FuzzRiskSites, FuzzCheckHostSite, FuzzPublicHostSite, FuzzClaudeHostSite and FuzzPromisorHostSite. A rule line is the same rule or no rule exactly as before, so a broken deny stays a broken deny. TestFixtureHosts reads the frozen v0.1.0 state's secrets.policy, secrets.json and links.json hosts and finds them unchanged. The structure test's new hosts check refuses, outside host.go and tests: Trim, TrimLeft or TrimRight with a cutset holding ".", TrimSuffix or CutSuffix with "."; ToLower, ToUpper, EqualFold and the TrimFunc family on an argument named for a host; and a conversion to proxy.Host of anything but a literal. Exceptions are by file and function, each with why (request.go:trimDots, cloneseed.go:urlHost, cloneworktree.go:safeIndexPath, cloneconfig.go:transportHelper, lima/start.go:machines.fillPassword). It doesn't see slicing, strings.Map or variables not named for a host. The owners doc, the proxy README, structure.md, design.md (One form of a host), network.md and safety/network.md say so. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
89f26c5771 |
docs(site): draw the diagrams at build time with pele, no Mermaid JS
The docs site's 18 mermaid blocks are now drawn as SVGs before Hugo
builds the site, by docs/render-diagrams.mjs with pele 1.13.0, and
inlined by a render hook, so no page loads Mermaid's 5.5 MB script.
- docs/render-diagrams.mjs: finds each mermaid block in docs/content,
draws it with pele in Departure Mono at 14px (a measurer from the
font's metrics), and writes <key>.svg and <key>.json (its size) to
the git-ignored docs/.build/diagrams. pele draws edge labels,
messages and notes at round(14 * 0.875) = 12px with no option, so the
measurer gives that text its 14px width and the script rewrites
font-size="12" to 14 on each small-text group (pele-edge-labels,
-notes, -boxes, -frames); a guard fails on any such group without
font-size="12", or small text outside them, and a self-check, run
whenever there's something to draw, renders an edge label, a message
and a note and fails unless pele measured them at 12 and wrote their
group with font-size="12". It also fails on a diagram without
accTitle and accDescr, or on an indented block. A newline after each
</text>, outside any text element, lets the search index see labels
as separate words; screenshots of all 18 are byte-identical with and
without it. (Newlines between a label's tspans would move centered
lines, so a label's own lines stay joined in the index.)
- Caching: a block's key is sha256(salt + "\n" + text)[:16], the salt
being sha256("pele <version>\n" + the script's text)[:16], written to
diagrams/salt. The script keeps every drawing already there, draws
only missing ones (written to .tmp and renamed), prunes files no key
names, and touches the folder. docs:diagrams has sources (the pages,
the script, package.json, the lock) and outputs (the folder), so mise
skips an unchanged run, and runs npm ci only when the lock's SHA-256
differs from docs/node_modules/.devvm-lock-sha256. An unchanged run:
0.45-0.75 s before, 0.02 s now (0.09 s forced); one diagram changed:
0.09 s. CI's check job caches ~/.npm keyed on the lock; the Docs
workflow, which publishes, keeps no cache.
- docs/package.json and package-lock.json pin pele 1.13.0
(sha512-Ie8UKY9x00MsuR3jO6AzUwzK2Z6MIV3Tf4EDdITiuk8Uaz8K7g0R082WqsqNaSU8DdgkrRvZThzhit83mi/uiw==).
- docs/layouts/_markup/render-codeblock-mermaid.html: in place of
Hextra's hook, reads the salt, computes the key from it and .Inner,
inlines the SVG from assets/diagrams (hugo.yaml mounts .build/diagrams
there), sets the wrapper's contain-intrinsic-block-size to the
diagram's height and --devvm-diagram-width to its width, and errorf's
when a drawing or the salt is missing. layouts/_partials/scripts/
mermaid.html and params.mermaid go.
- custom.css: .devvm-diagram with content-visibility: auto, and pele's
--pele-* variables from the palette (subgraphs, lifelines and notes in
the border color). A diagram wider than the text reaches into the
article's right padding (1.5rem, 3rem from 768px) as far as it needs,
then into the left padding for the rest, so it never covers the table
of contents; wider than both, it scrolls. From about 1010px no diagram
scrolls, the four wide ones included (proxy checks 751px, agent store,
VM states, SSH agent); at 900px five scroll. With the table of
contents shown, the proxy checks take 48px on the right and 31px on
the left.
- mise.toml: docs:diagrams, which docs and lint:docs depend on.
docs.yml: the next and release jobs install node and draw the
diagrams; the release job only when the tag has the script, so older
tags still build.
- scripts/bump.sh: bump_pele, named only, replaces bump_mermaid: npm
install --save-exact --ignore-scripts in docs, then mise run
docs:diagrams, whose self-check catches a pele that changed how it
draws small text. TestBumpCoversPins finds docs/package.json's
dependencies (npm:NAME); bump.txtar tests --check and the install.
The header and hextra's note say the mermaid render hook replaces
Hextra's mermaid hook, so check it still has that name.
- Every diagram gets an accTitle and accDescr, which pele makes the
SVG's title and desc (aria-labelledby, aria-describedby). Staying
safe's columns are written in reading order, as pele lays subgraphs
out from left to right. The proxy checks' description names every
branch, and a hand-placed <br> keeps "CA)" off a line of its own.
- AGENTS.md: the one Node script; no other build script is JavaScript,
and no other npm package is installed outside mise's tools.
Contributing's docs, tools and
maintaining pages describe the drawing, the caching, the margin, the
task and the bump.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
||
|
|
b6954e1e11 |
refactor(vmname): a VM's name is a vmname.VM, parsed where it's read
vmname.VM is the name of every machine devvm runs on a backend: a project VM, an image's machine (devvm-img-<key>), a build VM and a remake's aside. Fields, parameters, results and map keys that held a VM's name as a string now hold a VM, from the backend interface down to the CLI's --json structs, whose output is byte for byte the same. Boundary parsers, the only places a string becomes a VM: - vmname.Parse: a project VM's name (state's vm.json name, export file names, devvm _links's argument, the forwarder's -vm, project.Nth) - vmname.ParseListed: one path element, for what a backend lists - VM.UnmarshalText: JSON (Lima's list, proxy config and events, links' targets in state, link lists); empty stays no VM - vmname.Image(key), VM.Aside(), and typed constants for Lima's build VMs - msg.M.VM: the VM a message's function took, read back vmname's functions on names became methods (Hash, Slug, Short, Aside, AsideHash, ImageKey, IsProject); Lima's image prefix moved to vmname; vmname.Join joins VM lists. Messages' vm and vm_name fields are typed by the generator. Seven messages whose field took something else became what= (backend_lacks, backend_unreviewed, backend_unreviewed_used, starting, deleting, configuring, running_script) and rm_vm_failed's name=: the text is unchanged, the names-mode scripts follow. Review.RequireFor names an image or the tools being built. Typed sites per package (added lines with vmname.VM, non-test): msg 347 (generated), vm 124, lima 48, backendtest 32, vmssh 31, netpolicy 22, backend 16, gitprotect 14, proxy 11, cli 11, project 10, state 8, ports 6, paths 3, sshagent 2, sshconfig 2, tools 2. The structure test's owners rule now fails on a field, parameter or result named for a VM (vm, vms, otherVM, vmName) typed string, []string or map[string]…, and on converting anything but a literal to vmname.VM outside the files it lists; internal/stubtest is free. depguard holds internal/vmname to the standard library, and the proxy may import it. ParseListed and UnmarshalText refuse a name starting with -, which would read as a flag in limactl's argv, and vmname.Image refuses a key that's empty, holds a / or NUL, or makes a project VM's name, so Lima's ImageSize and DeleteImage no longer check it themselves. The check also fails on a *string VM name and an alias of vmname.VM, and says what it doesn't see. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
1ecd1faa73 |
build(nilaway): mise run nilaway against a triaged baseline, an advisory CI job, and two crashes it found
nilaway is pinned in mise.toml at its newest commit's pseudo-version (it has no releases); bump.sh's dev-tools moves it, and TestBumpCoversPins covers it through mise.toml:tool:*. mise run nilaway runs scripts/nilaway.sh: devvm's own packages, not the tests or their helpers (stubtest, backendtest), compared with testdata/nilaway-baseline.txt, the findings triaged as false positives, each with its group (checked, bounds, mapkey, nilsafe), keyed by file and trace without line numbers, one line for each finding, compared as multisets. It exits 3 on a new finding, a key found more often than the baseline has it included, and 1 when nilaway can't run, when a finding in its output can't be read, or when a baseline line is stale or malformed. TestNilawayBaseline checks each case with a stand-in nilaway. CI's nilaway job is continue-on-error: it warns on new findings and lists the new and stale ones, then every finding, in the run's summary, failing when the script exits 1. The first run reported 83 findings, 69 without the test helpers. Two were real: - agentlogin.Restore sliced above[1:] for a settings file that is one JSON string holding a placeholder, where above is empty, and devvm agent save panicked. - agentlogin's readJSON returned a nil map, with no error, for a file that is null, which the Codex and opencode captures then wrote to. It now refuses it as not a JSON object. The other 67 are the baseline. Both fixes get a CHANGELOG Fixed entry. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
02ba74e614 |
build(lint): stricter linters, and the fixes they need
golangci-lint now also runs govet's nilness, unusedwrite, hostport and waitgroup analyzers, nilnesserr, durationcheck, canonicalheader, errchkjson, forcetypeassert, contextcheck and gochecksumtype. - errchkjson checks each JSON encoding's error where the value could fail and drops it where errchkjson proves it can't, and reports structs without exported fields; tests may drop theirs. - forcetypeassert holds the code; tests are exempt. - gochecksumtype: agentlogin's format is a sum type (//sumtype:decl), and a switch on one names every case, default or not. - canonicalheader: WWW-Authenticate, X-Request-ID, X-Api-Key. - contextcheck: ctx threaded through carry, peekClientHello and sniOf, and through inject and value, whose cached lookup takes WithTimeout(WithoutCancel(ctx)), so two forbidigo nolints go; openTransparent takes its dialer's ctx. nolints stay where contextcheck can't follow: ReverseProxy's Rewrite, WithoutCancel alone, cobra's cmd.Context, e2e's runner window. - No-behaviour fixes: scrubList for redact's list, the loopback forward's ports kept with its listeners, upgradetest's Key keeps its public key, a CA's leaves read through leafOf. Contributing's Go lint rules lists each one and the sum-type convention. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
246a7aac10 |
docs(internals): a page on devvm's processes, its listeners and why Go
Processes, under How it works: one section for each process devvm runs on this machine for a VM (devvm itself, a VM's and a build's proxy, the port forwarder, the link session, the ssh masters and relays, the QEMU wrapper and its keeper, the daily tools check, the desktop relay, the SSH agents and Lima's hostagent), each with what it holds, what it reads from the VM, what it writes and its bounds, its confinement, and who starts and waits for it; an inventory of the loopback listeners a VM's bytes reach; and why devvm stays in Go. Linked from How it works' index, the security model, Staying safe, Attack vectors (a browser login's port), the ports, network, desktop and Lima pages, the design notes and Contributing's package table. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
0856205bd9 |
ci(vuln): govulncheck as its own CI job, and a weekly scan of main and the releases' binaries
mise run vuln scans the code as built for Linux and for macOS. CI's vuln job runs it on each push and pull request, apart from lint and test, with only Go and govulncheck installed. The Vulnerabilities workflow scans main's code and the binaries of the latest release and the newest release, prerelease or not (govulncheck -mode=binary, after checking that SHA256SUMS lists and matches each archive), each Monday. A read-only scan job uploads the findings, and an issue job, run only on main, opens, updates (with a comment when the findings change) or closes one issue, as the Pins workflow does. Contributing's Maintaining page says what fails, what a binary's scan can over-report and how to respond. Co-Authored-By: Claude Opus 5.5 <[email protected]> |
||
|
|
2e0d580e14 |
chore(git): ignore .worktrees, where parallel work's worktrees live
Co-Authored-By: Claude Opus 5.5 <[email protected]> |