Conversation
Add a shared SafeArchivePath helper in pkg/archiveutil that validates tar entry paths before writing them. Use it in all hand-rolled tar extractors (pkg/archives, pkg/util, pkg/archiveutil, pkg/image, pkg/upstream) and add regression tests for dot-dot and absolute path traversal attempts.
|
SafeArchivePath now walks each parent component of the target path and rejects any existing symlink as a potential escape. This prevents an archive entry like link/pwned from being written outside the extraction root when dest/link points to a directory outside the root. Add a regression test that creates a symlink in the destination and verifies the entry is rejected.
|
Reviews (2): Last reviewed commit: "fix: detect symlink escapes in archive e..." | Re-trigger Greptile |
sgalsaleh
approved these changes
Jul 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Add a shared SafeArchivePath helper in pkg/archiveutil that validates tar entry paths before writing them. Use it in all hand-rolled tar extractors (pkg/archives, pkg/util, pkg/archiveutil, pkg/image, pkg/upstream) and add regression tests for dot-dot and absolute path traversal attempts.
Which issue(s) this PR fixes:
Does this PR require a test?
Does this PR require a release note?
Does this PR require documentation?