Skip to content

fix(sandbox): pin ssh known_hosts to sandbox id - #76

Merged
BhautikChudasama merged 1 commit into
mainfrom
fix/ssh-hostkeyalias-per-sandbox
Aug 21, 2026
Merged

fix(sandbox): pin ssh known_hosts to sandbox id#76
BhautikChudasama merged 1 commit into
mainfrom
fix/ssh-hostkeyalias-per-sandbox

Conversation

@pratikbin

Copy link
Copy Markdown
Contributor

Problem

createos sandbox editor --via tunnel writes HostName 127.0.0.1 for every sandbox. All sandboxes therefore share a single known_hosts identity, [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:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Offending ED25519 key in ~/.ssh/known_hosts_createos:2

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 keys known_hosts on 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              root

One line per transport. No behaviour change for a single sandbox, and no client-side change needed — HostKeyAlias is standard OpenSSH and is surfaced through ssh -G, so tools that resolve config that way pick it up automatically.

Test plan

  • go build ./... passes.
  • go test ./cmd/sandbox/ passes.
  • New cmd/sandbox/editor_test.go covers the previously untested renderSSHBlock:
    • both transports emit the pin,
    • two sandbox ids produce two distinct host-key identities (the actual regression),
    • an unknown mode still errors.
  • Reproduced live against sb-01m0hp7v5vtdnj2pwpj25drhwe; the offending entry was a prior sandbox at known_hosts_createos:2.

Note for reviewers

Existing ~/.ssh/known_hosts_createos files still hold the old 127.0.0.1 entries. They are harmless once this lands, because lookups move to the alias. Deleting that file is safe if you want a clean slate.

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.
@BhautikChudasama
BhautikChudasama merged commit b6f98bb into main Aug 21, 2026
1 check passed
@BhautikChudasama
BhautikChudasama deleted the fix/ssh-hostkeyalias-per-sandbox branch August 21, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants