Skip to content

Cap total decompressed size in tar and gem readers#7

Merged
andrew merged 1 commit intomainfrom
fix/decompression-size-limit
May 2, 2026
Merged

Cap total decompressed size in tar and gem readers#7
andrew merged 1 commit intomainfrom
fix/decompression-size-limit

Conversation

@andrew
Copy link
Copy Markdown
Contributor

@andrew andrew commented May 2, 2026

openTar buffers every entry via io.ReadAll(tr) with no size cap. A crafted archive with a high compression ratio (e.g. 199 KiB gzip -> 515 MiB decompressed) can exhaust process memory.

Adds a 512 MiB cumulative limit on total decompressed bytes read across all tar entries, using io.LimitReader per entry. If the running total exceeds the cap, openTar returns ErrDecompressLimit.

Same treatment for openGem, which does io.ReadAll(tr) on the inner data.tar.gz before handing it to openTar.

…exhaustion

Wraps decompressed reads with `io.LimitReader` tracking cumulative bytes
across all entries, rejecting archives that exceed 512 MiB decompressed.
Applies to both `openTar` (per-entry and cumulative) and `openGem`
(`data.tar.gz` read).
@andrew andrew merged commit 96dc088 into main May 2, 2026
2 checks passed
@andrew andrew deleted the fix/decompression-size-limit branch May 2, 2026 15:38
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.

1 participant