Skip to content

fix(remote): reject snappy bombs in /api/v1/read (CVE-2026-42154)#335

Merged
vporoshok merged 2 commits into
ppfrom
fix/cve-2026-42154-remote-read-snappy
May 18, 2026
Merged

fix(remote): reject snappy bombs in /api/v1/read (CVE-2026-42154)#335
vporoshok merged 2 commits into
ppfrom
fix/cve-2026-42154-remote-read-snappy

Conversation

@vporoshok
Copy link
Copy Markdown
Collaborator

Summary

Backports the upstream Prometheus security fix prometheus/prometheus#18584 (GHSA-8rm2-7qqf-34qm / CVE-2026-42154) to our fork.

The remote-read endpoint (/api/v1/read) decompresses the snappy-encoded request body via storage/remote.DecodeReadRequest without checking the declared decoded length. A small crafted payload can claim a huge decoded size and force a multi-GB heap allocation per request; under concurrent load this exhausts memory and crashes the process. The fix calls snappy.DecodedLen first and rejects anything above the existing 32 MiB decodeReadLimit before allocating.

pp/tools/block_converter (the path Dependabot flagged on alert #186) is an offline CLI that only uses tsdb/labels/chunks and never reaches this code path, so that alert is unaffected by this PR — this PR fixes the same class of vulnerability inside our own Prometheus fork tree, which Dependabot doesn't see.

Changes

  • storage/remote/codec.go: validate snappy.DecodedLen(compressed) against decodeReadLimit before calling snappy.Decode.
  • storage/remote/codec_test.go: add TestDecodeReadRequestTooLarge — a 5-byte snappy header claiming 256 MiB decoded length is rejected with exceeds limit.
  • CHANGELOG.md: entry under v0.8.0Fixes.

Test plan

  • go test -tags stringlabels -run TestDecodeReadRequest ./storage/remote/ (new test passes)
  • go test -tags stringlabels ./storage/remote/... (full package, 48s, all green)

Made with Cursor

Backport of upstream prometheus/prometheus#18584 (GHSA-8rm2-7qqf-34qm).
DecodeReadRequest now checks snappy.DecodedLen before allocating, so a
small crafted payload that claims a huge decoded size is rejected
instead of triggering a multi-GB heap allocation per request.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vporoshok vporoshok self-assigned this May 16, 2026
@vporoshok vporoshok requested a review from u-veles-a May 16, 2026 06:35
Signed-off-by: Bastrykov Evgeniy <vporoshok@gmail.com>
@vporoshok vporoshok merged commit bc72475 into pp May 18, 2026
30 checks passed
@vporoshok vporoshok deleted the fix/cve-2026-42154-remote-read-snappy branch May 18, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants