fix(ssh): try none-auth before password/key to avoid leaking defaults#1582
Merged
Conversation
Previously, RusshHandler::connect attempted public-key auth when a key was present and password auth when target.password was present, only falling back to authenticate_none when neither credential existed. Because cmd.rs supplies SshConfig::default_password to user-selected SSH/SCP/SFTP targets, a malicious allowlisted server could harvest the configured default password even when it would have accepted none-auth. Attempt authenticate_none first; only fall back to publickey or password if the server rejects none. Add a regression test that asserts the call order in the connect() body. Closes #1574
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | 664ce88 | Commit Preview URL Branch Preview URL |
May 07 2026, 03:59 AM |
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.
Closes #1574.
Summary
RusshHandler::connectpreviously attempted public-key auth when a key was present and password auth whentarget.passwordwas present, only falling back toauthenticate_nonewhen neither credential existed.Because
cmd.rssuppliesSshConfig::default_passwordto user-selected SSH/SCP/SFTP targets, a malicious allowlisted server could harvest the configured default password even when it would have accepted none-auth.Fix
authenticate_nonefirst; return immediately on success so credentials are never offered.test_auth_order_none_firstthat asserts the call order inconnect()(a runtime test would require a real SSH server).Test plan
cargo test -p bashkit --features ssh --lib builtins::ssh::russh_handler(11/11 passing)cargo fmt --all -- --checkcargo clippy -p bashkit --features ssh --all-targets -- -D warningsGenerated by Claude Code