fix(sandbox): pin ssh known_hosts to sandbox id - #76
Merged
Conversation
Tunnel mode writes `HostName 127.0.0.1` for every sandbox, so all sandboxes share one known_hosts identity. After the first box is recorded, the next one presents a different host key on the same `[127.0.0.1]:22` entry and ssh reports REMOTE HOST IDENTIFICATION HAS CHANGED. OpenSSH downgrades that to a warning when public-key auth is used, but stricter clients treat a changed host key as an attack and refuse the connection outright. Orca's SSH relay is one of them, which makes a second CreateOS sandbox unusable as a remote host. VPN mode has the same defect with a longer fuse: it keys on the overlay IP, and those are recycled between sandboxes. Add `HostKeyAlias <sandbox-id>` to both blocks. OpenSSH then keys known_hosts on the sandbox id, which is unique and stable across pause/resume, instead of on a shared address. Reproduced against sb-01m0hp7v5vtdnj2pwpj25drhwe while integrating CreateOS sandboxes as Orca remote hosts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
createos sandbox editor --via tunnelwritesHostName 127.0.0.1for every sandbox. All sandboxes therefore share a singleknown_hostsidentity,[127.0.0.1]:22.The first sandbox records its host key. The next sandbox presents a different key on the same entry, and ssh reports:
OpenSSH downgrades this to a warning when public-key auth succeeds, so the CLI's own flows keep working and the bug stays invisible. Stricter clients do not. They treat a changed host key as an active attack and refuse to connect.
That makes the second CreateOS sandbox unusable as a remote host for those clients. We hit it while integrating CreateOS sandboxes into Orca, whose SSH relay has a dedicated host-key verification subsystem.
VPN mode has the same defect with a longer fuse: it keys on the overlay IP, and overlay IPs are recycled between sandboxes.
Fix
Add
HostKeyAlias <sandbox-id>to both the tunnel and VPN blocks. OpenSSH then keysknown_hostson the sandbox id, which is unique per sandbox and stable across pause/resume, instead of on a shared address.Host sb-01m0hp7v5vtdnj2pwpj25drhwe my-box HostName 127.0.0.1 + HostKeyAlias sb-01m0hp7v5vtdnj2pwpj25drhwe Port 22 User rootOne line per transport. No behaviour change for a single sandbox, and no client-side change needed —
HostKeyAliasis standard OpenSSH and is surfaced throughssh -G, so tools that resolve config that way pick it up automatically.Test plan
go build ./...passes.go test ./cmd/sandbox/passes.cmd/sandbox/editor_test.gocovers the previously untestedrenderSSHBlock:sb-01m0hp7v5vtdnj2pwpj25drhwe; the offending entry was a prior sandbox atknown_hosts_createos:2.Note for reviewers
Existing
~/.ssh/known_hosts_createosfiles still hold the old127.0.0.1entries. They are harmless once this lands, because lookups move to the alias. Deleting that file is safe if you want a clean slate.