🛡️ Sentinel: [HIGH] Fix MITM vulnerability in ssh2 backend#505
Conversation
- Implemented host key verification in `SshConnection` (`src/connection/ssh.rs`). - Loads `known_hosts` and checks server key after handshake. - Respects `StrictHostKeyChecking` configuration. - Aborts connection on key mismatch. Co-authored-by: dolagoartur <146357947+dolagoartur@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f3a465b484
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
🚨 Severity: HIGH
💡 Vulnerability: The
ssh2backend (used whenssh2-backendfeature is enabled) did not perform host key verification during connection establishment. It calledsession.handshake()but failed to check the server's host key againstknown_hosts, allowing any server to be accepted and exposing the connection to Man-in-the-Middle (MITM) attacks.🎯 Impact: Attackers could intercept SSH connections, potentially stealing credentials or executing malicious commands on the control node or remote hosts if the user enabled the
ssh2-backendfeature (legacy/alternative to the defaultrusshbackend).🔧 Fix: Implemented
verify_host_keyinsrc/connection/ssh.rs. This function loads~/.ssh/known_hosts(or the configuredUserKnownHostsFile), retrieves the server's host key, and verifies it usingssh2::KnownHosts. It respectsStrictHostKeyCheckingconfiguration: if strict checking is disabled (default for this tool's config in some contexts, butfalsein code), it adds new keys to memory (and tries to append to file); if enabled, it rejects unknown hosts. Mismatched keys are always rejected as a security error.✅ Verification: Verified that the code compiles with
cargo check --lib --features ssh2-backend. Confirmed via code inspection thatsession.host_key()is now checked againstknown_hostsbefore authentication proceeds.PR created automatically by Jules for task 4155186710690112462 started by @dolagoartur