cockroachdb / cockroachdb/cockroach

drpc: snappy compression decode allocation bomb

Open
#172,572 1 comment 0 reactions 0 assignees View on GitHub
branch-master C-bug T-db-server
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

A crafted KindMessage payload of ~6 bytes can trick snappy.Decode into attempting a 4 GiB allocation on 64-bit platforms. snappy.Decode reads the claimed decompressed length from the header and allocates the full buffer before validating the rest of the payload. There is currently no size cap on decompressed output, unlike gRPC's MaxRecvMsgSize.

Untested fix: call `snappy.DecodedLen(src)` in `drpcwire.Decompress` and reject payloads exceeding a configurable limit before decoding. Could gate on `Options.MaximumBufferSize` or a dedicated `MaxDecompressedSize` field.

Low severity for authenticated node-to-node traffic, but cheap insurance against a buggy or compromised peer OOM-killing the receiver.

Jira issue: CRDB-65819

Contributor guide

Open the contributing guide

Research direction

Start at drpcwire.Decompress and inspect how snappy.Decode currently handles the payload length. Compare using snappy.DecodedLen with Options.MaximumBufferSize or a dedicated MaxDecompressedSize limit, then add coverage showing oversized decompressed output is rejected before allocation and that normal decoding still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
distributed-systems, security
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.