Repository navigation
go-archives: symlink extraction attack tests - #9657
Merged
taylorsilva merged 1 commit intoJul 28, 2026
Merged
taylorsilva merged 1 commit into
taylorsilva merged 1 commit into
Conversation
aliculPix4D
commented
Jul 23, 2026
| // will not be found. The directory must exist, so that the lookup fails | ||
| // identically on every platform. GinkgoT().Setenv will restore PATH after | ||
| // the spec. | ||
| GinkgoT().Setenv("PATH", GinkgoT().TempDir()) |
Contributor
Author
There was a problem hiding this comment.
As I originally wrote in our Pix4D fork PR: Pix4D#832 (comment)
I am more than tempted to open a 2nd PR to run the same tests on Unix when tar is on the path.
They must behave the same with tar :) If these test fail with tar (reminder: a failing test means that you are vulnerable to the attack) it means you have a security issue with tar :)
Lets first see how this PR review goes :)
Contributor
Author
|
@odormond @marco-m-pix4d FYI same as the PR in our fork.. |
taylorsilva
approved these changes
Jul 27, 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.
Summary
Add regression tests that exercise classic symlink-based tar extraction attacks against
tarfs.Extract.These cover the attack shapes that matter in practice:
../relative targets)../relative targets)In each case, extraction must fail, and nothing may appear outside the destination directory.
Why
os.Rootis what makes this safe after #9601. That change intentionally relaxed the overly strict breakout checks from #9486 so legitimate intra-repo relative symlinks (especially on Windows) work again, while still blocking writes that would escape the extraction root.Without tests like these, it is easy to “simplify” extraction later and accidentally undo that protection — for example, by reverting #9601 or dropping
os.Rootwithout understanding why it is there.These specs are also concrete evidence that the security issue addressed in #9486 remains fixed under the
#9601approach: escaping symlinks may be created in some cases, but following them to write outside the destination is refused.