SSH agent: per-key destination filtering using OpenSSH session binding #22382
V1rg1lee
started this conversation in
Password Manager
Replies: 1 comment
|
✨ Thank you for your code contribution proposal! While the Bitwarden team reviews your submission, we encourage you to check out our contribution guidelines. Please ensure that your code contribution includes a detailed description of what you would like to contribute, along with any relevant screenshots and links to existing feature requests. This information helps us gather feedback from the community and Bitwarden team members before you start writing code. To keep discussions focused, posts that do not include a proposal for a code contribution will be removed.
Thank you for contributing to Bitwarden! |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Select Topic Area
✅ Code Contribution Proposal
Code Contribution Proposal
Background
The Bitwarden SSH agent currently exposes all eligible SSH identities to the SSH client.
This can cause connections to fail on servers with a low
MaxAuthTriesvalue when the correct key is reached too late. This is the problem described in:I ran into the same issue with a vault containing several SSH keys. In my test case, the agent returned 6 identities and the server disconnected with
Too many authentication failuresbefore OpenSSH reached the correct key.Proposed UX
Add an optional SSH agent destinations section to SSH key items in the Desktop client.
A user can associate an SSH key with one or more SHA256 SSH host-key fingerprints:
Leaving the list empty keeps the current behavior for that key: it remains available for any destination.
The setting is Desktop-local and is not added to the synchronized cipher data.
Configured destination
The field accepts multiple destination fingerprints and validates non-empty values as SHA256 host-key fingerprints.
Validation error
Agent behavior
The SSH agent protocol's normal
REQUEST_IDENTITIESmessage does not include a hostname or IP address, so this proposal does not attempt to infer one.OpenSSH does, however, support the
session-bind@openssh.comextension. Bitwarden's SSH Agent v2 already verifies this session binding and has access to the destination host-key fingerprint.When a verified destination fingerprint is available, identities are returned in this order:
Keys that are restricted to other destinations are omitted.
Ordering is stable within each group.
If no verified session binding is available, all keys are returned as before. This preserves compatibility with SSH clients that do not provide destination information.
This is intended as an identity-selection/ordering optimization, not as an authorization or security boundary.
Why prioritize instead of only filtering
A user should not have to configure every SSH key before seeing a benefit.
For example, if a vault contains six unrestricted keys and the user associates only the correct key with a server, that explicit match is returned before the other unrestricted Bitwarden identities.
Unrestricted keys are still available afterwards, so configuring a destination for one key does not make unrelated unrestricted keys unusable for the same host.
Testing
I tested the change against a real OpenSSH server on Windows.
Before configuring a destination:
Too many authentication failures.With the destination configured on the correct key:
I also tested the stricter case where unrelated keys are configured for different destinations; in that case only the matching key is returned.
The implementation includes Rust unit/integration coverage for filtering, prioritization, stable ordering and the no-session-bind fallback, as well as Desktop/UI tests for local persistence, Save/Cancel behavior and validation.
Scope
The proposed change is intentionally limited to Desktop SSH Agent v2:
ssh-keyscan;I'd appreciate feedback on the UX and on using verified host-key fingerprints as the destination identifier.
All reactions