[crypto] ssh: permit empty but non-nil HostKeyAlgorithms, KeyExchanges, Ciphers, MACs

3 views
Skip to first unread message

Ian Chen (Gerrit)

unread,
Jul 13, 2026, 8:09:11 AM (9 days ago) Jul 13
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Ian Chen has uploaded the change for review

Commit message

ssh: permit empty but non-nil HostKeyAlgorithms, KeyExchanges, Ciphers, MACs

The documentation of ClientConfig.HostKeyAlgorithms says:

If empty, a reasonable default is used.

However, if HostKeyAlgorithms is empty but non-nil, the reasonable default
won't be applied, and the SSH handshake will fail. Fix this by changing the nil
check to a length check.

While here, do the same for KeyExchanges, Ciphers, MACs in Config.
Change-Id: I1b3d2d2159f3c7d57a9a690ad04f1f6818b39a5c

Change diff

diff --git a/ssh/common.go b/ssh/common.go
index 2e44e9c..613b7db 100644
--- a/ssh/common.go
+++ b/ssh/common.go
@@ -544,7 +544,7 @@
if c.Rand == nil {
c.Rand = rand.Reader
}
- if c.Ciphers == nil {
+ if len(c.Ciphers) == 0 {
c.Ciphers = defaultCiphers
}
var ciphers []string
@@ -556,7 +556,7 @@
}
c.Ciphers = ciphers

- if c.KeyExchanges == nil {
+ if len(c.KeyExchanges) == 0 {
c.KeyExchanges = defaultKexAlgos
}
var kexs []string
@@ -571,7 +571,7 @@
}
c.KeyExchanges = kexs

- if c.MACs == nil {
+ if len(c.MACs) == 0 {
c.MACs = defaultMACs
}
var macs []string
diff --git a/ssh/handshake.go b/ssh/handshake.go
index 4be3cbb..711a7f7 100644
--- a/ssh/handshake.go
+++ b/ssh/handshake.go
@@ -162,7 +162,7 @@
t.remoteAddr = addr
t.hostKeyCallback = config.HostKeyCallback
t.bannerCallback = config.BannerCallback
- if config.HostKeyAlgorithms != nil {
+ if len(config.HostKeyAlgorithms) > 0 {
t.hostKeyAlgorithms = config.HostKeyAlgorithms
} else {
t.hostKeyAlgorithms = defaultHostKeyAlgos

Change information

Files:
  • M ssh/common.go
  • M ssh/handshake.go
Change size: XS
Delta: 2 files changed, 4 insertions(+), 4 deletions(-)
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newchange
Gerrit-Project: crypto
Gerrit-Branch: master
Gerrit-Change-Id: I1b3d2d2159f3c7d57a9a690ad04f1f6818b39a5c
Gerrit-Change-Number: 800080
Gerrit-PatchSet: 1
Gerrit-Owner: Ian Chen <databa...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Ian Chen (Gerrit)

unread,
Jul 13, 2026, 8:10:57 AM (9 days ago) Jul 13
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Ian Chen uploaded new patchset

Ian Chen uploaded patch set #2 to this change.
Open in Gerrit

Related details

Attention set is empty
Submit Requirements:
  • requirement is not satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: newpatchset
Gerrit-Project: crypto
Gerrit-Branch: master
Gerrit-Change-Id: I1b3d2d2159f3c7d57a9a690ad04f1f6818b39a5c
Gerrit-Change-Number: 800080
Gerrit-PatchSet: 2
Gerrit-Owner: Ian Chen <databa...@gmail.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Filippo Valsorda (Gerrit)

unread,
Jul 21, 2026, 6:23:14 AM (18 hours ago) Jul 21
to Ian Chen, goph...@pubsubhelper.golang.org, Filippo Valsorda, Nicola Murino, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Ian Chen and Nicola Murino

Filippo Valsorda voted Code-Review+2

Code-Review+2
Open in Gerrit

Related details

Attention is currently required from:
  • Ian Chen
  • Nicola Murino
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: crypto
Gerrit-Branch: master
Gerrit-Change-Id: I1b3d2d2159f3c7d57a9a690ad04f1f6818b39a5c
Gerrit-Change-Number: 800080
Gerrit-PatchSet: 2
Gerrit-Owner: Ian Chen <databa...@gmail.com>
Gerrit-Reviewer: Filippo Valsorda <fil...@golang.org>
Gerrit-Reviewer: Nicola Murino <nicola...@gmail.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Roland Shoemaker <rol...@golang.org>
Gerrit-Attention: Nicola Murino <nicola...@gmail.com>
Gerrit-Attention: Ian Chen <databa...@gmail.com>
Gerrit-Comment-Date: Tue, 21 Jul 2026 10:23:07 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Nicola Murino (Gerrit)

unread,
Jul 21, 2026, 6:23:19 AM (18 hours ago) Jul 21
to Ian Chen, goph...@pubsubhelper.golang.org, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Ian Chen

Nicola Murino voted Code-Review+2

Code-Review+2
Open in Gerrit

Related details

Attention is currently required from:
  • Ian Chen
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: crypto
Gerrit-Branch: master
Gerrit-Change-Id: I1b3d2d2159f3c7d57a9a690ad04f1f6818b39a5c
Gerrit-Change-Number: 800080
Gerrit-PatchSet: 2
Gerrit-Owner: Ian Chen <databa...@gmail.com>
Gerrit-Reviewer: Filippo Valsorda <fil...@golang.org>
Gerrit-Reviewer: Nicola Murino <nicola...@gmail.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Roland Shoemaker <rol...@golang.org>
Gerrit-Attention: Ian Chen <databa...@gmail.com>
Gerrit-Comment-Date: Tue, 21 Jul 2026 10:23:13 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Nicola Murino (Gerrit)

unread,
Jul 21, 2026, 6:23:33 AM (18 hours ago) Jul 21
to Ian Chen, goph...@pubsubhelper.golang.org, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Ian Chen

Nicola Murino voted Commit-Queue+1

Commit-Queue+1
Open in Gerrit

Related details

Attention is currently required from:
  • Ian Chen
Submit Requirements:
  • requirement satisfiedCode-Review
  • requirement satisfiedNo-Unresolved-Comments
  • requirement is not satisfiedReview-Enforcement
  • requirement is not satisfiedTryBots-Pass
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: crypto
Gerrit-Branch: master
Gerrit-Change-Id: I1b3d2d2159f3c7d57a9a690ad04f1f6818b39a5c
Gerrit-Change-Number: 800080
Gerrit-PatchSet: 2
Gerrit-Owner: Ian Chen <databa...@gmail.com>
Gerrit-Reviewer: Filippo Valsorda <fil...@golang.org>
Gerrit-Reviewer: Nicola Murino <nicola...@gmail.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Roland Shoemaker <rol...@golang.org>
Gerrit-Attention: Ian Chen <databa...@gmail.com>
Gerrit-Comment-Date: Tue, 21 Jul 2026 10:23:27 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Carlos Amedee (Gerrit)

unread,
Jul 21, 2026, 5:31:59 PM (7 hours ago) Jul 21
to Ian Chen, goph...@pubsubhelper.golang.org, golang...@luci-project-accounts.iam.gserviceaccount.com, Nicola Murino, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
Attention needed from Ian Chen

Carlos Amedee voted Code-Review+1

Code-Review+1
Open in Gerrit

Related details

Attention is currently required from:
  • Ian Chen
Submit Requirements:
    • requirement satisfiedCode-Review
    • requirement satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    • requirement satisfiedTryBots-Pass
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: crypto
    Gerrit-Branch: master
    Gerrit-Change-Id: I1b3d2d2159f3c7d57a9a690ad04f1f6818b39a5c
    Gerrit-Change-Number: 800080
    Gerrit-PatchSet: 2
    Gerrit-Owner: Ian Chen <databa...@gmail.com>
    Gerrit-Reviewer: Carlos Amedee <car...@golang.org>
    Gerrit-Reviewer: Filippo Valsorda <fil...@golang.org>
    Gerrit-Reviewer: Nicola Murino <nicola...@gmail.com>
    Gerrit-CC: Gopher Robot <go...@golang.org>
    Gerrit-CC: Roland Shoemaker <rol...@golang.org>
    Gerrit-Attention: Ian Chen <databa...@gmail.com>
    Gerrit-Comment-Date: Tue, 21 Jul 2026 21:31:54 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Cherry Mui (Gerrit)

    unread,
    Jul 21, 2026, 7:25:17 PM (5 hours ago) Jul 21
    to Ian Chen, goph...@pubsubhelper.golang.org, Carlos Amedee, golang...@luci-project-accounts.iam.gserviceaccount.com, Nicola Murino, Filippo Valsorda, Roland Shoemaker, Gopher Robot, golang-co...@googlegroups.com
    Attention needed from Ian Chen

    Cherry Mui voted Code-Review+1

    Code-Review+1
    Open in Gerrit

    Related details

    Attention is currently required from:
    • Ian Chen
    Submit Requirements:
      • requirement satisfiedCode-Review
      • requirement satisfiedNo-Unresolved-Comments
      • requirement satisfiedReview-Enforcement
      • requirement satisfiedTryBots-Pass
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: crypto
      Gerrit-Branch: master
      Gerrit-Change-Id: I1b3d2d2159f3c7d57a9a690ad04f1f6818b39a5c
      Gerrit-Change-Number: 800080
      Gerrit-PatchSet: 2
      Gerrit-Owner: Ian Chen <databa...@gmail.com>
      Gerrit-Reviewer: Carlos Amedee <car...@golang.org>
      Gerrit-Reviewer: Cherry Mui <cher...@google.com>
      Gerrit-Reviewer: Filippo Valsorda <fil...@golang.org>
      Gerrit-Reviewer: Nicola Murino <nicola...@gmail.com>
      Gerrit-CC: Gopher Robot <go...@golang.org>
      Gerrit-CC: Roland Shoemaker <rol...@golang.org>
      Gerrit-Attention: Ian Chen <databa...@gmail.com>
      Gerrit-Comment-Date: Tue, 21 Jul 2026 23:25:13 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages