From abbc44d451a6f9236a2bbd26cbcd4d0fec473da3 Mon Sep 17 00:00:00 2001 From: Neal Patel Date: Fri, 15 May 2026 20:04:07 +0000 Subject: [PATCH] ssh: fix incorrect operator order Arithmetic is incorrectly applied to 'byte' instead of 'int' resulting in a possible overflow that allows for a panic. Fixes CVE-2026-46597 Fixes golang/go#79561 Change-Id: I83edabeeda676f0209d29d5e2554890bbd0eef8f Reviewed-on: https://go-review.googlesource.com/c/crypto/+/781620 Reviewed-by: Roland Shoemaker Auto-Submit: Gopher Robot Reviewed-by: Nicholas Husin Reviewed-by: Nicholas Husin LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com --- ssh/cipher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ssh/cipher.go b/ssh/cipher.go index ad2b370..48d0199 100644 --- a/ssh/cipher.go +++ b/ssh/cipher.go @@ -407,7 +407,7 @@ func (c *gcmCipher) readCipherPacket(seqNum uint32, r io.Reader) ([]byte, error) return nil, fmt.Errorf("ssh: illegal padding %d", padding) } - if int(padding+1) >= len(plain) { + if int(padding)+1 >= len(plain) { return nil, fmt.Errorf("ssh: padding %d too large", padding) } plain = plain[1 : length-uint32(padding)]