Repository navigation
Description
@chrisddwrt requested issue #80288 to be considered for backport to the next 1.26 minor release.
Independent confirmation on real hardware, plus a request to backport the fix to the supported release branches.
Reproduced with the program below on amd64 hardware (Intel Xeon, AES-NI/PCLMULQDQ) with go1.24.7 and go1.25.1, and on arm64 hardware (Apple M-series, AES+PMULL) with go1.24.7 and go1.25.1 under Linux 6.8 and with go1.26.3 under macOS — identical results everywhere. release-branch.go1.25 (go1.25.14) and release-branch.go1.26 (go1.26.9) still contain the unfixed assembly (checked in git, not run). The arm64 path is the same construction (
gcm_arm64.s,encReduce:→VST1.P [B0.B16], 16(dstPtr)reached fromtailLast:). With-tags puregonothing is written out of bounds.Exact behaviour on all affected versions (guard bytes behind a destination slice of exact capacity):
tag size plaintext length (mod 16) bytes written past cap(dst) 12 1 / 2 / 3 3 / 2 / 1 13 1 / 2 2 / 1 14 1 1 15, 16 – none i.e.
16 - (len % 16) - tagSizewhen positive. The bytes written are always zero (the block is masked withandMaskbefore the full-block store atgcm_amd64.sptxLoadLoop→MOVOU X0, (DX)). Plaintexts shorter than one block (len 1..3) are affected too.Openonly over-reads up to 3 bytes.Why "nearly always harmless due to allocator semantics" does not hold in practice: the slack argument assumes
dstis a freshly allocated slice whose size class leaves padding. In packet-processing codedstis routinely a sub-slice of a larger live buffer —buf[:0:n], ring buffers,sync.Poolbuffers, send buffers that already hold the next packet. We hit this in production code: the zero bytes landed in a pooled HMAC state (crypto/sha256: invalid hash state identifier) and, on go1.24, in a SIGSEGV. Any program usingNewGCMWithTagSizewith 12–14 byte tags on amd64/arm64 with hardware AES can be affected, and the plaintext length is attacker-controlled in most network protocols.The fix (CL 801600, e36c20c) is currently only on master. Since this is a memory-safety bug in
crypto/cipherwith an attacker-influenceable trigger, and the fix is small and self-contained (tail load/store only, with new boundary tests), could it please be considered for backport to go1.25 and go1.26?@gopherbot please consider this for backport to 1.25 and 1.26: memory safety issue in crypto/cipher (out-of-bounds write with short GCM tags), fix is on master.
Minimal reproduction (prints the number of bytes written past cap for each length):
package main import ( "crypto/aes" "crypto/cipher" "fmt" "runtime" ) func main() { blk, _ := aes.NewCipher(make([]byte, 16)) a, _ := cipher.NewGCMWithTagSize(blk, 12) nonce := make([]byte, 12) for _, l := range []int{1, 17, 18, 19, 20, 33} { buf := make([]byte, l+12+8) for i := range buf { buf[i] = 0xEE } a.Seal(buf[:0:l+12], nonce, make([]byte, l), nil) // dst has exact capacity over := 0 for _, c := range buf[l+12:] { if c != 0xEE { over++ } } fmt.Printf("%s %s len=%d: %d bytes written past cap(dst)\n", runtime.Version(), runtime.GOARCH, l, over) } }
Activity
dr2chase commentedon Oct 20, 2026
@rolandshoemaker @FiloSottile how do you guys feel about this?
neild commentedon Oct 20, 2026
Copying @rolandshoemaker's comment from elsewhere:
visiongaiatechnology commentedon Oct 23, 2026
Independent confirmation on Go 1.26.10 (linux/amd64, AES-NI/PCLMULQDQ):
Go 1.26.10 is a current supported release and still contains the unfixed assembly. Please backport CL 801600 / CL 803120 to the 1.26 branch. I can provide the full standalone programs; no attachments sent here.
— VisionGaiaTechnology
JunyangShao commentedon Oct 27, 2026
@rolandshoemaker ping on backport CLs, thanks.
FiloSottile commentedon Oct 27, 2026
It would be important for this backport to land after the #82626 ones. It can land in the same release, we just need a commit with #82626 and without this to re-wrap the FIPS 140-3 module at. (This change is too large and would trigger an algorithm re-test.)