Résumé
gopacket: SCTP chunk sub-decoder out-of-bounds panics on crafted segments
Détails de l’avis
Summary
gopacket decodes SCTP (IP protocol 132) by walking the chunk chain through per-chunk-type decoder functions (decodeSCTPInit, decodeSCTPShutdown, decodeSCTPError, decodeSCTPSack, in layers/sctp.go). Each of these reads fixed-size header fields and runs count-driven loops without validating the chunk's declared length against the minimums those reads require. A single crafted SCTP segment causes a runtime panic (out-of-bounds slice read, or inverted slice from unsigned length arithmetic) on any decode path that does not install gopacket's per-packet panic recovery (gopacket.DecodeOptions.SkipDecodeRecovery: true); with the default API the same input degrades to a per-packet decode error.
The defect is present in every released version through v1.7.1 and at current master (18c5805). It is the SCTP component named - but not remediated - in CVE-2026-65819 (GHSA-8mcr-459q-5mx2, "Multiple layer decoders panic …", patched per advisory metadata in v1.7.1). The v1.7.1 hardening commit b772f56 ("layers:various: add protocol decoder length checks (#163)") added generic bounds to the chunk dispatcher and decodeSCTPChunk, but left every chunk sub-decoder without a per-type minimum-length check. The advisory's own description lists "SCTP chunk/parameter decoders (sctp.go)" among items "being confirmed; they should be remediated together with the above" - this report demonstrates that, at v1.7.1 and HEAD, that remediation still does not exist.
Patches
Fixed in v1.7.2 by commit 5080443 ("layers/sctp: bound chunk sub-decoders and parameters"). INIT/INIT-ACK, SACK and SHUTDOWN now check their chunk type's minimum length, SACK rejects gap-ack and duplicate-TSN counts the chunk can't hold, and decodeSCTPParameter rejects TLV lengths below 4 or beyond the buffer. Each case returns a decode error instead of panicking. The same commit fixes a panic on valid input, where a final parameter's padding lies outside the chunk length (RFC 9260 3.2). Regression tests: TestDecodeSCTPChunkRegression and TestDecodeSCTPParameterPadding in layers/decode_oob_test.go.
Upgrade with go get github.com/gopacket/gopacket@v1.7.2.
Workarounds
Before v1.7.2, keep panic recovery on: use gopacket.NewPacket without SkipDecodeRecovery, and DecodingLayerParser with IgnorePanic: false. The crafted packet then fails to decode instead of crashing the process.
Vulnerability Details
All line numbers refer to layers/sctp.go at commit 18c5805028329a6a8944f054d8d3f64ebc0f1373 (master, 2026-09-01; v1.7.1-1-g18c5805).
The shared entry point already present in v1.7.1 validates only that a chunk is present and that its declared length is ≥ 4 and covered by real bytes:
// sctp.go:129
func decodeSCTPChunk(data []byte) (SCTPChunk, error) {
if len(data) < 4 { ... }
length := binary.BigEndian.Uint16(data[2:4])
if length < 4 { ... }
actual := roundUpToNearest4(int(length))
ct := SCTPChunkType(data[0])
if ct == SCTPChunkTypeData && length < 16 { ... } // only DATA gets a 16-byte minimum
if len(data) < actual { ... }
...
The Data-chunk minimum of 16 bytes is never applied to the other chunk types, and none of the sub-decoders re-check before indexing. Four independent panic paths result (each reproduced at HEAD):
Defect 1 - INIT / INIT-ACK chunks (decodeSCTPInit, sctp.go:423): reads data[4:8], data[8:12] (line 431), data[12:14], data[14:16], data[16:20] (line 434), then slices paramData := data[20:sc.ActualLength] (line 436).
- Declared length 8–11, actual 8–12 ->
data[8:12]reads past the chunk:panic: runtime error: slice bounds out of range [:12] with capacity 8 - Declared length 15, actual 16 ->
data[16:20]past the chunk:panic: runtime error: slice bounds out of range [:20] with capacity 16 - Declared length ≤ 19 -> the
data[20:ActualLength]slice is inverted (panic) or the subsequent parameter loop runs on attacker data without thedecodeSCTPParameterlength check (Defect 3).
Defect 2 - SHUTDOWN chunks (decodeSCTPShutdown, sctp.go:670): reads binary.BigEndian.Uint32(data[4:8]) (line 677) on a chunk whose declared length is only validated as ≥ 4:
panic: runtime error: slice bounds out of range [:8] with capacity 4 (4-byte chunk).
Defect 3 - ERROR (and HEARTBEAT/INIT) parameter decoder (decodeSCTPParameter, sctp.go:193): the crafted Length field is used to slice with no bound against the parameter buffer:
// sctp.go:193
func decodeSCTPParameter(data []byte) SCTPParameter {
length := binary.BigEndian.Uint16(data[2:4])
return SCTPParameter{
...
Value: data[4:length], // line 198: no check length >= 4 or length <= len(data)
ActualLength: roundUpToNearest4(int(length)),
}
}
length < 4-> inverted slice:panic: runtime error: slice bounds out of range [4:0](reached fromdecodeSCTPErrorline 632paramData := data[4:sc.Length], and from the INIT (438) / HEARTBEAT (578) parameter loops).length > len(data)-> slice-bounds-check panic (Go's slice bounds check panics; the read never silently over-reads).
Defect 4 - SACK chunk count loops (decodeSCTPSack, sctp.go:484): NumGapACKs / NumDuplicateTSNs (attacker-controlled uint16 fields) drive loops that slice the remaining bytes with no bound:
// sctp.go:512
bytesRemaining := data[16:]
for i := 0; i < int(sc.NumGapACKs); i++ { // line 513
sc.GapACKs = append(sc.GapACKs, binary.BigEndian.Uint16(bytesRemaining[:2])) // line 514
bytesRemaining = bytesRemaining[2:]
}
for i := 0; i < int(sc.NumDuplicateTSNs); i++ { // line 517
sc.DuplicateTSNs = append(sc.DuplicateTSNs, binary.BigEndian.Uint32(bytesRemaining[:4])) // line 518
bytesRemaining = bytesRemaining[4:]
}
A 16-byte SACK chunk declaring NumGapACKs = 1 with no following bytes:
panic: runtime error: slice bounds out of range [:2] with capacity 0
Note this is not the sFlow/Diameter "unbounded allocation" family already covered by CVE-2026-54332/CVE-2026-54345; the SACK make() capacities are already capped against ActualLength (lines 505–510) - the loop iteration counts are not, so the panic is an out-of-bounds read, not an allocation.
History / version range. decodeSCTPInit and the chunk sub-decoders were introduced in commit 2fca351 (original full-featured SCTP implementation; at the time the file was named layer_sctp.go - the current sctp.go path dates from the rename in dea6b39). The sinks are present in every release from v1.0.0 through v1.7.1 and at HEAD (also confirmed at v1.6.0). b772f56 (2026-07-08, included in v1.7.1) touched layers/sctp.go but only hardened the dispatcher (decodeWithSCTPChunkTypePrefix) and the generic decodeSCTPChunk/decodeSCTPDataChunk bounds; the four sub-decoder paths above are unchanged by it. The v1.7.1 regression-test commit 2220269 covers the advisory's other decoders, not SCTP chunk sub-decoders. Affected range is therefore every gopacket version: <= 1.7.1, plus current master 18c5805. (Maintainer update: fixed in v1.7.2, commit 5080443; see Patches.)
Relationship to the published advisory (dedup context). CVE-2026-65819 / GHSA-8mcr-459q-5mx2 (published 2026-07-27) declares vulnerable_version_range: <= 1.7.0 / patched_versions: 1.7.1. Its description explicitly names "SCTP chunk/parameter decoders (sctp.go)" among decoder families "(on the recovering path only) … being confirmed; they should be remediated together with the above". Because the advisory metadata tells consumers that upgrading to 1.7.1 remediates the advisory, and this SCTP component was not actually fixed, the practical status of this finding is incomplete remediation of a published advisory: consumers of the 1.7.1 "patched" version remain exposed to the SCTP panic path. The finding is reported here so the maintainers can either
Références
- https://github.com/advisories/GHSA-358w-w75h-x6rx
- https://github.com/gopacket/gopacket/security/advisories/GHSA-358w-w75h-x6rx
- https://nvd.nist.gov/vuln/detail/CVE-2026-119299
- https://github.com/gopacket/gopacket/commit/508044327cc2c065b3db753c010a027e7d1ca621
- https://github.com/gopacket/gopacket/releases/tag/v1.7.2
Vulnérabilités liées
Tout Supply chain →- MEDIUMCVE-2026-107220
Excelize: Panic in cellInRange on a worksheet with an empty mergeCell ref
- HIGHCVE-2026-115578
go-guerrilla crashes on a bare XCLIENT command (7-byte slice off-by-one panic)
- MEDIUMCVE-2026-102945
Aether Project amf: panic on an unrecovered NGAP goroutine
- HIGHGHSA-494m-4556-wf5p
imgproxy has out-of-bounds heap read/write in ICO loader BMP header reconstruction that allows unauthenticated remote worker crash
- MEDIUMCVE-2026-115920
ONNX: Out-of-bounds read in ConvTranspose shape inference via undersized weight rank
- MEDIUMCVE-2026-115919
ONNX: Out-of-Bounds Read in RNN/GRU/LSTM Shape Inference (Old Opsets, Missing Rank Check)