Skip to content

feat(cli): verify sandbox SSH host keys - #5703

Draft
alangou wants to merge 2 commits into
mainfrom
feat/verify-sandbox-ssh-host-keys/alangou
Draft

alangou wants to merge 2 commits into
mainfrom
feat/verify-sandbox-ssh-host-keys/alangou

Conversation

@alangou

@alangou alangou commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Summary

The CLI, the TUI, and generated SSH config entries accepted any SSH host key from a sandbox. They now check it against the fingerprint the gateway publishes, so a connection that reaches the wrong SSH server fails before authentication.

Related Issue

Follow-on to #3835 (item 4 of its design, "CLI and TUI verify against the fingerprint"). #3835 is closed, so this PR needs its own tracking issue before it leaves draft.

Changes

  • ssh runs with StrictHostKeyChecking=yes against one known-hosts file per sandbox, under <config>/openshell/known_hosts/<gateway>/. Other trust sources are disabled.
  • ssh-proxy reads the host key from the server's key exchange reply. It pins the key only when its SHA-256 fingerprint equals the published one, and withholds the reply otherwise. It accepts only the exact cleartext sequence a server sends before NEWKEYS.
  • New module openshell_core::ssh_host_key owns the fingerprint format, the pin file, the ssh options, and the relay check. sandbox_ssh_args cannot be called without it.
  • No protobuf change. No dependency on the OpenSSH version.

Out of scope: the gateway's own SSH client for ExecSandbox (#557), and a readable multi-line refusal in the TUI, which stays a one-line status.

Release Notes

OpenShell clients now verify the sandbox SSH host key on every SSH connection they open.

  • A sandbox with no published fingerprint is refused. Upgrade the gateway, or stop and start the sandbox. OPENSHELL_SSH_ALLOW_UNVERIFIED_HOST_KEY=1 allows the connection with a warning.
  • SSH config entries generated by earlier releases are refused. The message prints the command that regenerates the entry.

Testing

  • Checks appropriate to the affected code and behavior pass
  • Unit tests added/updated (if applicable)
  • E2E tests added/updated (if applicable)

Ran on Linux with OpenSSH 10.0p2: cargo test for openshell-core, openshell-cli, and openshell-tui, cargo clippy --all-targets -D warnings on the same crates, cargo fmt --check, and the lockfile check.

ssh_proxy_host_key_integration runs the real ssh binary through the built openshell ssh-proxy against a russh server: the published key connects, another key is refused before any command runs, a stale pin is replaced, and ssh refuses a key missing from its own known-hosts file.

Not run locally: the E2E suites, macOS, and OpenSSH 8.x. The existing conformance test ssh_host_identity_stable_across_stop_start_and_new_on_recreate exercises the relay check against a real supervisor in CI.

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

The CLI, the TUI, and generated SSH config entries accepted any SSH host key. They now run ssh with StrictHostKeyChecking=yes against a per-sandbox known-hosts file. The ssh-proxy relay reads the host key from the server's key exchange reply, pins it only when its SHA-256 fingerprint equals the one the gateway published, and withholds the reply otherwise.

A sandbox with no published fingerprint is refused unless OPENSHELL_SSH_ALLOW_UNVERIFIED_HOST_KEY=1 is set. SSH config entries generated by earlier releases are refused with the command that regenerates them.

Signed-off-by: Adrien Langou <alangou@nvidia.com>
@copy-pr-bot

copy-pr-bot Bot commented Nov 18, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the state:accepted A maintainer decided OpenShell should pursue this issue label Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Restore the base shape of the SSH option and proxy-command helpers where the feature does not need a new one, fold duplicate tests into tables, and drop tests that repeat a proof at a more expensive level. No change to what is verified or refused.

Signed-off-by: Adrien Langou <alangou@nvidia.com>
@alangou alangou added the test:e2e Requires end-to-end coverage label Nov 18, 2026
@github-actions

Copy link
Copy Markdown

Label test:e2e applied, but pull-request/5703 does not exist yet. A maintainer needs to comment /ok to test 3cdb3a9710e393e622c35c2bb339dc206a30dbdf to mirror this PR. Once the mirror exists, re-apply the label or re-run Branch E2E Checks from the Actions tab.

@alangou

alangou commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 3cdb3a9

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state:accepted A maintainer decided OpenShell should pursue this issue test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant