Skip to content

fix(ssh): add host key verification to SSH client#1227

Merged
chaliy merged 4 commits intomainfrom
fix/issue-1171-ssh-host-key-verification
Apr 11, 2026
Merged

fix(ssh): add host key verification to SSH client#1227
chaliy merged 4 commits intomainfrom
fix/issue-1171-ssh-host-key-verification

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 11, 2026

Summary

Closes #1171

  • strict_host_key_checking defaults to true — connections rejected unless server key matches a trusted key configured via SshConfig::trusted_host_key()
  • When disabled, a warning is emitted to stderr (MITM risk)
  • keys_match() compares key type+data, ignoring trailing comments
  • Threat model updated with TM-SSH-006 mitigation status

Test plan

  • test_strict_host_key_checking_default_true — default is strict
  • test_strict_host_key_checking_disabled — can opt out
  • test_trusted_host_key_builder — API stores keys correctly
  • test_keys_match_same_key / different_key / different_type / ignores_comment
  • test_strict_mode_rejects_unknown_key — connection rejected with no trusted key
  • test_strict_host_key_checking_propagation — config flows through client

chaliy added 4 commits April 11, 2026 22:44
Closes #1171 — The RusshHandler previously accepted all server keys
without verification (MITM vulnerability). Now:
- strict_host_key_checking defaults to true
- Connections rejected unless server key matches a trusted key
- SshConfig::trusted_host_key() API for configuring known keys
- Warning emitted when strict checking is disabled
…ample

The ssh_supabase_tests and ssh_supabase example didn't configure
strict_host_key_checking(false), causing CI failures when the new
default-strict host key verification rejects the supabase.sh
connection (no trusted key configured).
@chaliy chaliy merged commit 572e6ac into main Apr 11, 2026
27 checks passed
@chaliy chaliy deleted the fix/issue-1171-ssh-host-key-verification branch April 11, 2026 23:31
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.

sec(network): SSH client lacks host key verification by default

1 participant