Описание
Compress/s2: Integer Overflow or Wraparound and Out-of-bounds Write in compress
Signed Integer Overflow in s2.NewDict
Summary
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:
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():
load32 calls le.Load32 which uses unsafe.Pointer arithmetic without bounds checking:
This causes a segmentation fault (SIGSEGV) when the negative index is dereferenced.
PoC
Impact
- Denial of Service: The process crashes immediately with SIGSEGV
Attack Vector
Any application that:
- Accepts user-supplied S2 dictionary data via
s2.NewDict() - Calls
Dict.Encode()on any data ≥32 bytes
Suggested Fix
Validate the uvarint value before converting to int:
Or use uint for the repeat field and validate against uint(len(dict)).
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/
Ссылки
- https://github.com/klauspost/compress/security/advisories/GHSA-259r-337f-4rfw
- https://nvd.nist.gov/vuln/detail/CVE-2026-63209
- https://github.com/klauspost/compress/pull/1163
- https://github.com/klauspost/compress/commit/539243b8823ee8f03e49969823d57c348c917536
- https://github.com/klauspost/compress/commit/8668e357e776d5152ed62f33c17f21b8690664fa
- https://github.com/klauspost/compress/releases/tag/v1.18.7
Пакеты
github.com/klauspost/compress
<= 1.18.6
1.18.7
Связанные уязвимости
compress provides various compression algorithms. Prior to version 1.18.7, 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. This issue has been patched in version 1.18.7.
compress provides various compression algorithms. Prior to version 1.18.7, 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. This issue has been patched in version 1.18.7.
compress provides various compression algorithms. Prior to version 1.18.7, 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. This issue has been patched in version 1.18.7.
Integer Overflow or Wraparound and Out-of-bounds Write in compress
compress provides various compression algorithms. Prior to version 1.1 ...