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]>
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]>