Skip to content

Feat/bounded tar extraction - #5

Merged
BinanIbrahim merged 2 commits into
mainfrom
feat/bounded-tar-extraction
Jun 24, 2026
Merged

Feat/bounded tar extraction#5
BinanIbrahim merged 2 commits into
mainfrom
feat/bounded-tar-extraction

Conversation

@BinanIbrahim

Copy link
Copy Markdown
Owner

Why:

The extractor unpacked container image layers with an unbounded io.Copy, so a malicious or corrupted image could carry a tar bomb that inflates to fill the disk. Symlink and hardlink entries were also never validated against the extraction root, leaving a path-traversal hole. For a tool whose whole job is scanning untrusted images, both are unacceptable.

What changed:

Introduced an Extractor with configurable per-entry (FileSizeCap, default 512 MiB) and cumulative (TotalSizeCap, default 2 GiB) size caps, enforced via io.LimitReader.
Reject absolute paths and .. components before touching the filesystem.
Validate symlink/hardlink targets stay in-tree, treating absolute targets literally so they can't re-root through filepath.Join.
ExtractImage delegates to New().Untar(...) — no change to existing callers.
Added table-driven tests covering safe/rejected entries, size caps, and a multi-hop chained-symlink escape.
Verified: go test -race ./..., golangci-lint run, and govulncheck ./... all clean. No new dependencies.

BinanIbrahim and others added 2 commits June 24, 2026 22:16
Add a Feature Briefing section requiring a plain-English what/why/how
summary to the user before starting any roadmap feature.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Unbounded io.Copy let a malicious layer fill the disk (tar bomb), and
symlink/hardlink targets were never checked against the extraction root.

Add an Extractor with per-entry and cumulative size caps via LimitReader,
reject absolute paths and ".." components, and validate symlink/hardlink
targets stay in-tree (treating absolute targets literally so they cannot
re-root through filepath.Join).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@BinanIbrahim
BinanIbrahim merged commit 99a7eff into main Jun 24, 2026
7 checks passed
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