Skip to content

fix: bound gzip decompression in /import to prevent decompression bomb DoS#108

Open
hacktron-app-stg[bot] wants to merge 1 commit into
add-auth-gateway-gofrom
hacktron/fix-26b465b5
Open

fix: bound gzip decompression in /import to prevent decompression bomb DoS#108
hacktron-app-stg[bot] wants to merge 1 commit into
add-auth-gateway-gofrom
hacktron/fix-26b465b5

Conversation

@hacktron-app-stg

Copy link
Copy Markdown

Vulnerability

The /import endpoint (importHandler in auth_gateway.go) decompressed the untrusted gzip request body and read it fully via io.ReadAll(gz) with no size cap. A small, highly compressed payload (decompression bomb) expands to an arbitrary size in memory, exhausting host RAM and crashing the Go process (high-severity DoS).

Taint path: gzip.NewReader(r.Body) (source) → io.ReadAll(gz) (unbounded sink).

Fix

  • Wrap the gzip reader in io.LimitReader(gz, maxImportSize+1) so at most 10 MiB (plus one sentinel byte) of decompressed data is ever read into memory.
  • Introduce a maxImportSize constant (10 MiB) documenting the cap.
  • Return 413 Request Entity Too Large when the decompressed payload exceeds the limit, and 400 Bad Request when reading the stream fails.
  • Add defer gz.Close() and stop silently discarding the read error.

This addresses the root cause: decompressed input is now bounded regardless of the compressed input size.

Verification

Reviewed the resulting handler for correctness. Go toolchain is not available in the sandbox and the repository has no test infrastructure, so the change was verified by manual reasoning about the control/data flow rather than an automated run.


Automated fix by Hacktron for finding: https://staging.hacktron.ai/testestesttest/findings/26b465b5-7a48-4ab1-bbc5-ba2b4c78a6d5

Wrap the gzip reader with io.LimitReader (10 MiB cap) so a small
decompression-bomb payload can no longer expand unbounded into memory
and OOM-crash the process. Oversized payloads now return HTTP 413 and
read errors return HTTP 400.
@hacktron-app-stg
hacktron-app-stg Bot requested a review from maekuss July 23, 2026 05:26
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.

0 participants