Skip to content

security: limit decompressed gzip output to prevent DoS via decompression bomb#7515

Merged
friedrichg merged 1 commit into
cortexproject:masterfrom
danielblando:fix/gzip-decompression-bomb
May 13, 2026
Merged

security: limit decompressed gzip output to prevent DoS via decompression bomb#7515
friedrichg merged 1 commit into
cortexproject:masterfrom
danielblando:fix/gzip-decompression-bomb

Conversation

@danielblando
Copy link
Copy Markdown
Contributor

@danielblando danielblando commented May 13, 2026

Summary

Fix unbounded gzip decompression that allows a denial-of-service attack via decompression bombs.
Using the same limit as we apply to snappy compression

Fix

Wrap gzip.Reader with a second io.LimitReader(gzReader, maxSize+1) before buf.ReadFrom in both locations:

  • pkg/util/http.godecompressFromReader() Gzip case
  • pkg/util/push/otlp.go — OTLP JSON decompression path

Testing

Added TestParseProtoReader_GzipDecompressionBomb which creates a 1 MB payload compressed to under 4 KB and verifies that decompression is bounded (returns an error instead of allocating 1 MB).

@danielblando danielblando force-pushed the fix/gzip-decompression-bomb branch 4 times, most recently from 9522e37 to f75e698 Compare May 13, 2026 18:12
… ingestion path

Wrap gzip.Reader with io.LimitReader(maxSize+1) before reading
decompressed bytes in both pkg/util/http.go and pkg/util/push/otlp.go.

Signed-off-by: Daniel Blando <ddeluigg@amazon.com>
@danielblando danielblando force-pushed the fix/gzip-decompression-bomb branch from f75e698 to 74bd5fb Compare May 13, 2026 18:15
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label May 13, 2026
@friedrichg friedrichg merged commit 8379d7d into cortexproject:master May 13, 2026
37 checks passed
@danielblando danielblando deleted the fix/gzip-decompression-bomb branch May 13, 2026 20:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer size/M type/security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants