Repository navigation
[release-0.x] fix: offer no X25519 key exchanges when the curve is unusable - #512
Merged
kke merged 1 commit intoNov 2, 2026
Merged
Conversation
A FIPS 140-only build refuses X25519, but x/crypto/ssh still offers mlkem768x25519-sha256 first, so a server that accepts it picks it and the handshake fails even though usable algorithms were offered too. Probe the curve once and, when it is refused, configure the supported key exchanges without the X25519 ones. Signed-off-by: Sopho Merkviladze <smerkviladze@mirantis.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the SSH fallback when FIPS restrictions make X25519 unavailable.
No open issues 🎉
What changed in this PR
This release-0.x fix allows SSH connections when FIPS restrictions make X25519 unavailable, while preserving the default key exchange behavior when X25519 works.
Changes:
- Probe X25519 availability once per process.
- Exclude X25519-based key exchanges when the probe fails, preserving the remaining supported algorithms’ order.
- Add tests for both availability outcomes.
| File | Description |
|---|---|
ssh.go |
Adds the cached X25519 probe and conditional key exchange filtering. |
ssh_test.go |
Tests unchanged defaults when X25519 is available and filtered offers when unavailable. |
Review effort: Balanced
Contributor
|
in rig v2 these come from the default ssh_config entries :
None of them have that algorithm. I don't know if we need to error out if user has it in their config. |
5 of 7 tasks
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.
A FIPS 140-only build of a rig v0.21 consumer cannot open an SSH connection to a host whose sshd supports
mlkem768x25519-sha256. OpenSSH 10.0 made that algorithm the default key agreement, and Ubuntu 26.04 ships sshd 10.2p1 with it first in the list, so every such host is unreachable.The failure:
Cause, from the sources:
crypto/ecdhrefuses X25519 underGODEBUG=fips140=only, and toolchains that route crypto through an external FIPS module refuse it whenever that module is active.mlkem768x25519-sha256first in its default key exchange list in FIPS mode too (itskex.gonotes it works withfips140=onbut notfips140=only).ecdh-sha2-nistp256was in the same offer.ssh.ClientConfig.KeyExchanges, so consumers cannot work around it.Fix
clientConfigprobes X25519 once per process throughcrypto/ecdh. When the curve is refused,KeyExchangesis set tossh.SupportedAlgorithms().KeyExchangeswithout the X25519 based entries, in x/crypto's order;ssh.Config.SetDefaultsthen drops what the current mode does not support. When the curve works, nothing is configured and x/crypto keeps its defaults, so non-FIPS behaviour is unchanged.Verification
Unit tests: the X25519 probe is a variable, as
agentSignerSourceis, and two tests cover both branches.End to end, with a FIPS toolchain (Go 1.26.6 with an OpenSSL FIPS backend, X25519 refused) against an Ubuntu 26.04 sshd (OpenSSH 10.2p1, default config), sshd at
LogLevel DEBUG1:kex: algorithm: ecdh-sha2-nistp256,Accepted publickeykex: algorithm: mlkem768x25519-sha256(fix inactive)All three also connect to the same sshd started with
-o KexAlgorithms=-mlkem768x25519-sha256.Tracked in BOP-7172.