The DataSize field was on the wire. The decoder did not read it.
Batch is the protobuf wrapper Klever-Go uses for every gossip-broadcast group of transactions, block bodies, and trie nodes. The generated struct has five wire fields:
type Batch struct {
Data [][]byte `protobuf:"bytes,1,rep,name=Data..."`
Stream []byte `protobuf:"bytes,2,opt,name=Stream..."`
IsCompressed bool `protobuf:"varint,3,opt,name=IsCompressed..."`
Algo CType `protobuf:"varint,4,opt,name=Algo..."`
DataSize int32 `protobuf:"varint,5,opt,name=DataSize..."`
...
}
Compress writes DataSize on the way out, after marshaling and right before the function returns:
ba.Stream = make([]byte, len(result))
copy(ba.Stream, result)
ba.IsCompressed = true
ba.DataSize = int32(len(data)) // #nosec G115
ba.Data = nil
return nil
len(data) is the length of the marshaled batch before gzip ran. Every batch the cluster sends advertises, in its own wire-visible header, the size it will be after decompression. The protocol declares it.
Decompress ran on every batch the cluster received. At v1.7.16 the gzip branch reads:
} else {
result, err = decompressGzip(ba.Stream)
if err != nil {
return err
}
}
// decode
err = m.Unmarshal(ba, result)
No reference to ba.DataSize. The LZ4 branch threads ba.DataSize into decompressLZ4(dataSize int32, data []byte), but the LZ4 path is a stub that falls through to gzip and the parameter is unused:
func decompressLZ4(dataSize int32, data []byte) ([]byte, error) {
return decompressGzip(data)
/*output := make([]byte, dataSize)
_, err := lz4.Uncompress(output, data)
...*/
}
The commented-out implementation is testimony. output := make([]byte, dataSize) is the line the original author wrote when they intended to use dataSize. They left it inside a comment alongside the replacement, which does not. make([]byte, dataSize) against an attacker-controlled dataSize is one DoS primitive; the replacement shipped a different one. The choice was between two paths, both reachable by any peer on the topic, neither bounded against the same protocol field that arrived alongside the payload.
decompressGzip itself does the rest:
func decompressGzip(data []byte) ([]byte, error) {
rdata := bytes.NewReader(data)
reader, err := gzip.NewReader(rdata)
if err != nil {
return nil, err
}
result, err := io.ReadAll(reader)
if err != nil {
return nil, err
}
...
}
io.ReadAll(reader) against a gzip stream the attacker assembled. No limit. No bound. No reference to DataSize. The gzip format permits 1024:1 compression ratios trivially and pushes well past that with a tuned dictionary; the CVE description names "multi-gigabyte heaps from a sub-50 KiB gossip payload" and the fix commit's regression suite includes a dedicated "high-ratio" test for the same primitive.
The size the sender wrote into field 5 was sitting on the byte stream the decoder owned. The decoder did not look.
The 1 MiB ceiling was on the bus. The decompressor was downstream of it.
MultiDataInterceptor.ProcessReceivedMessage is the entry point that lands every multi-data batch arriving on a topic. At v1.7.16, the order of operations was:
func (mdi *MultiDataInterceptor) ProcessReceivedMessage(message p2p.MessageP2P, fromConnectedPeer core.PeerID) error {
err := mdi.preProcessMessage(message, fromConnectedPeer)
if err != nil {
return err
}
b := batch.Batch{}
err = mdi.marshalizer.Unmarshal(&b, message.Data())
...
if b.IsCompressed {
err = b.Decompress(mdi.marshalizer)
if err != nil {
log.Error("MultiDataInterceptor.ProcessReceivedMessage", "err", err.Error())
return err
}
}
multiDataBuff := b.Data
lenMultiData := len(multiDataBuff)
...
err = mdi.antifloodHandler.CanProcessMessagesOnTopic(
fromConnectedPeer,
mdi.topic,
uint32(lenMultiData),
uint64(len(message.Data())),
message.SeqNo(),
)
Two anti-flood frames bracket the decompression step. preProcessMessage, above, ran against the wire-sized message. The wire was capped at 1 MiB by libp2p's pubsub.DefaultMaxMessageSize. CanProcessMessagesOnTopic, below, ran against the post-decompression lenMultiData. By the time CanProcessMessagesOnTopic returned its answer, the gzip stream had already inflated and the goroutine was holding the full inflated payload as live heap.
The anti-flood pipeline existed. It saw the bomb after the bomb went off.
The error path of the bomb leaked a throttler slot.
The if err != nil after b.Decompress reads:
if b.IsCompressed {
err = b.Decompress(mdi.marshalizer)
if err != nil {
log.Error("MultiDataInterceptor.ProcessReceivedMessage", "err", err.Error())
return err
}
}
The function returns. The throttler slot acquired by preProcessMessage is not released. The sibling error paths in the same function (the unmarshal failure, the empty-data check, the topic anti-flood failure, the per-originator whitelist check) all call mdi.throttler.EndProcessing() explicitly before returning. The decompression failure does not.
The throttler is the local goroutine pool. Production sizing is 100. A peer that ships 100 malformed compressed batches, each cheap to construct and each failing decompression, fills the throttler permanently. Subsequent legitimate batches arrive to a full pool and return ErrSystemBusy until the operator restarts.
GitHub assigned this companion bug a separate identifier, GHSA-74m6-4hjp-7226. CVE-2026-44697 picked up the OOM primitive at GHSA-87m7-qffr-542v. The throttler-leak primitive does not have a CVE of its own. The same merge closed both.
The fix names the assumption out loud.
The merge that became v1.7.17 landed eight security commits in one push on 2026-05-11. The first, KLC-2352, added MaxDecompressedBatchSize = 10 * 1024 * 1024 and threaded it through decompressGzip as an io.LimitReader(reader, max+1) cap, plus a cross-check that the inflated length equals ba.DataSize:
if int64(len(result)) != int64(ba.DataSize) {
return common.ErrDecompressedSizeMismatch
}
The second, KLC-2353, added MaxItemsPerBatch = 8192 and checked it twice: once immediately after unmarshal (catches uncompressed item bombs) and once after decompress (catches compressed item bombs whose inflated payload fits under the 10 MiB cap). The third, KLC-2356, moved throttler.CanProcess() out of the !isMessageFromSelfToSelf branch so the local goroutine-capacity gate runs on every incoming message. Five more cleaned up panic recovers in HdrInterceptorProcessor, a debugHandler race exposed by go test -race, the absent BlacklistPeer call on malformed compressed batches, comma-ok guards on the transaction interceptor's type assertions, and a shouldProcess := isWhiteListed || true tautology in SingleDataInterceptor that had been quietly reducing one filter to a constant.
The KLC-2353 commit body carries the assumption the original code had been running on, transcribed and signed:
ProcessReceivedMessage is reachable only via the libp2p pubsub callback in networkMessenger.pubsubCallback, so the pubsub.DefaultMaxMessageSize (1 MiB) ceiling is always upstream and a duplicate cap at our layer would be dead code.
The wire bound is real. The maintainer is correct, today, that every path into ProcessReceivedMessage traverses libp2p pubsub. The bug is the rest of the sentence the original author did not write down: the 1 MiB bound is on the wire, not on the inflated payload. A 48 KiB gzip stream is a 48 KiB wire payload, and the bus's 1 MiB ceiling is satisfied. Decompression turns it into multiple gigabytes of heap. The 1 MiB ceiling caps the input to the gzip extractor. The gzip extractor's output was unbounded by anything in this codebase.
The comment names the upstream cap accurately and is silent about the function the gzip extractor applies between the upstream cap and the parser's working set. The fix is a 10 MiB explicit cap and a runtime check against the sender's own DataSize field. The sender's own DataSize field had been on the wire the whole time.
The 1 MiB was the medium's. The 10 MiB is the parser's.
This is the Closed Network Assumed pattern. A parser written for a "trusted" bus accepts framing fields as if the protocol's valid-range constraints were guaranteed by the medium. Sequence numbers, length fields, and indices arrive without bounds checks because the developer's threat model excludes adversaries on the wire. When the bus admits a malformed frame, the protocol-derived constant becomes the size of the overflow.
Klever-Go is not OP-TEE J1939 reading a sequence number off a CAN frame, and it is not BIRD's as_path_match allocating a 2048-entry stack array against an RFC 4271 wire cap that RFC 8654 quietly lifted a decade later. The medium is libp2p pubsub. The constraint the medium guarantees is pubsub.DefaultMaxMessageSize = 1 MiB. The transform that breaks the proportionality between the medium's bound and the parser's bound is gzip. The 1 MiB the bus enforces and the multiple gigabytes the parser allocates are connected by a function whose inverse lives in the gzip library, not in the framing.
The exhibits on this pattern share one move: a constant somewhere in the codebase was sized to fit a bound the medium enforced at the time the code was written, and the implementer wrote down the resulting number rather than the relationship that produced it. CZ.NIC published BIRD's closed-network assumption inside the CVE record when MITRE asked them to fix the bug. Klever-Go's maintainer published it inside the fix commit. Same worldview, two different artifacts of the moment the assumption broke.
The Klever-Go fix introduces MaxDecompressedBatchSize as an explicit constant inside data/batch/batch.go. The comment above the constant runs four lines and names libp2p, the per-peer antiflood budget, and the blacklist threshold. It is the same constant the previous file did not have, sized against the same considerations the previous author had implicitly used to decide they did not need one. The bound moved into the code.
What was not in the CVE description
The CVE record names Batch.Decompress and MultiDataInterceptor. The companion advisory GHSA-74m6-4hjp-7226 adds throttler-slot accounting. Neither names the seven non-decompression security commits the same merge landed: the panic-recover gap in HdrInterceptorProcessor.Save, the debugHandler race the worker goroutines were carrying past a released RLock, the shouldProcess := isWhiteListed || true tautology in SingleDataInterceptor, the missing BlacklistPeer call on malformed compressed batches that previously left a no-cost retry channel for the throttler-leak primitive, the comma-ok guards on the transaction-type assertions inside the interceptor goroutine body, the mutHandlers.RLock held across user callbacks that recursive-RLock self-deadlocked when a handler called RegisterHandler, and the nil propagation in baseDataInterceptor.processInterceptedData that had been reusing a stale loop-variable error on the Save success path.
The CVE captures the most legible bug in the interceptor pipeline. It does not capture the audit that found it.
PoC: klever-io/klever-go @ 333f6ec
The bound was in libp2p. The bound was in DataSize. The bound was not in decompressGzip.