Repository navigation
Use os.Root when extracting files - #9601
Conversation
Basically reverting #9486, but adding one safe-guard against path escapes from symlinks when creating a relative symlink. `os.Root` is doing the heavy-lifting for us here. It'll protect us from extraction attacks that try to write outside the destination directory. Signed-off-by: Taylor Silva <[email protected]>
|
@taylorsilva first impressions: it doesn't seem to fully resolve the issue for us. This is all the logs I have so far: from ATC: From worker: the What I noticed is the following:
I will get back to you as soon as I have more information and confirmation that this is still related to the symlink issue. UPDATE: this is definitely still related to symlinks. Doing a simple test, just by removing the symlinks from the repo, and everything passes.
UPDATE 3: Thanks to @odormond who noticed that contrary to: |
|
The "exit status 9" indicates to me that we're in another part of the code where we are exec'ing some binary. The immediate spot that comes to mind is when we call Are you still able to reproduce the issue with your example repo: https://github.com/Pix4D/concourse-tar-streaming-issue ? |
So your example in the PR description would reproduce the issue, if instead of Sure, in this case, it will successfully stream, but the created symlink will be unusable (due to forward slashes on Windows). This just manifested itself differently when you also have a directory symlink in the repository. In that case, it will fail during the streaming, as the error in my original post shows... but the root cause remains the same: root.Symlink (we think; otherwise there are really 2 issues) Please allow me some time to prepare the examples. |
|
Feel free to open a new issue when you have a final report. |
Finally done in: #9609 It took a lot more time than expected :) |
Changes proposed by this PR
closes #9597
Basically reverting #9486, but adding one safe-guard against path escapes from symlinks when creating a relative symlink.
os.Rootis doing the heavy-lifting for us here. It'll protect us from extraction attacks that try to write outside the destination directory. It'll still allow us to create the symlink, but it'll fail if someone tries to do an extraction attack using the symlink.I left a comment in the code path where we create symlinks explaining this a bit more.
I manually setup a pipeline using the test repo from Pix4D: https://github.com/Pix4D/concourse-tar-streaming-issue
and streamed it from a linux to windows worker. I verified I could reproduce the issue from
masterfirst:Redeploying the windows worker with this PR, it worked:
