Skip to content

Commit ffd87b4

Browse files
drakkanthatnealpatel
authored andcommitted
ssh: fix panic when authority callbacks are nil
Previously, if CertChecker.IsHostAuthority or CertChecker.IsUserAuthority were left unset, calling CheckHostKey or Authenticate would result in a nil pointer dereference panic. This change adds checks to ensure these callbacks are defined before invocation, returning an error instead of panicking. This issue was found during a security audit by NCC Group Cryptography Services, sponsored by Teleport. Fixes golang/go#79563 Fixes CVE-2026-39835 Change-Id: I2bd9c8d76646232e49f6aedc7b5334f3825918be Reviewed-on: https://go-review.googlesource.com/c/crypto/+/781660 Commit-Queue: Neal Patel <nealpatel@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Neal Patel <nealpatel@google.com>
1 parent 4e7a738 commit ffd87b4

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

ssh/certs.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ func (c *CertChecker) CheckHostKey(addr string, remote net.Addr, key PublicKey)
348348
if cert.CertType != HostCert {
349349
return fmt.Errorf("ssh: certificate presented as a host key has type %d", cert.CertType)
350350
}
351+
if c.IsHostAuthority == nil {
352+
return errors.New("ssh: cannot verify certificate, IsHostAuthority not set")
353+
}
351354
if !c.IsHostAuthority(cert.SignatureKey, addr) {
352355
return fmt.Errorf("ssh: no authorities for hostname: %v", addr)
353356
}
@@ -375,6 +378,9 @@ func (c *CertChecker) Authenticate(conn ConnMetadata, pubKey PublicKey) (*Permis
375378
if cert.CertType != UserCert {
376379
return nil, fmt.Errorf("ssh: cert has type %d", cert.CertType)
377380
}
381+
if c.IsUserAuthority == nil {
382+
return nil, errors.New("ssh: cannot verify certificate, IsUserAuthority not set")
383+
}
378384
if !c.IsUserAuthority(cert.SignatureKey) {
379385
return nil, fmt.Errorf("ssh: certificate signed by unrecognized authority")
380386
}

0 commit comments

Comments
 (0)