-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix SafeTarFile symlinks extraction #775
Merged
Merged
Conversation
This file contains 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
e3krisztian
force-pushed
the
safe_tar_symlinks_fix
branch
from
February 15, 2024 22:29
593d4f1
to
ca32156
Compare
qkaiser
reviewed
Feb 16, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small comment otherwise LGTM. Nice work on tests.
e3krisztian
force-pushed
the
safe_tar_symlinks_fix
branch
from
February 19, 2024 09:48
117aaac
to
844e058
Compare
Rebased for linear history. |
qkaiser
approved these changes
Feb 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As agreed, squash before merge.
e3krisztian
force-pushed
the
safe_tar_symlinks_fix
branch
from
February 19, 2024 19:35
844e058
to
b95225f
Compare
symlinks like sbin/halt -> ../bin/busybox were mistakenly dropped before. Co-authored-by: Andrew Fasano <[email protected]>
Absolute targets were converted before, but it was too simple to be right other than when the link target was in the same directory. With this change absolute symlinks like /sbin/ls -> /bin/busybox are converted to /sbin/ls -> ../bin/busybox Co-authored-by: Andrew Fasano <[email protected]>
tests/integration/archive/tar/__input__/symlinks.tar: test/ |-- bin | `-- busybox `-- sbin |-- cp -> /test/bin/busybox |-- find -> ../bin/../bin/busybox |-- ln -> /test/bin/../bin/busybox |-- ls -> ../bin/busybox |-- mv -> ../../bin/busybox `-- rm -> ../../../bin/busybox is extracted as tests/integration/archive/tar/__output__/symlinks.tar_extract/ └── test ├── bin │ └── busybox └── sbin ├── cp -> ../bin/busybox ├── find -> ../bin/busybox ├── ln -> ../bin/busybox ├── ls -> ../bin/busybox └── mv -> ../../bin/busybox Please note, that `rm` is missing, as that is a path traversal attempt. ---- The symlinks.tar test file is created with this script in a docker container: rm -rf /test symlinks.tar mkdir -p /test/bin echo binary > /test/bin/busybox mkdir -p /test/sbin ln -s ../bin/busybox /test/sbin/ls ln -s ../bin/../bin/busybox /test/sbin/find ln -s ../../bin/busybox /test/sbin/mv ln -s ../../../bin/busybox /test/sbin/rm ln -s /test/bin/busybox /test/sbin/cp ln -s /test/bin/../bin/busybox /test/sbin/ln tar cPf /symlinks.tar /test/ tar tvPf /symlinks.tar
Due to the previous absolute-symlink extraction fix, the following updates are made: tests/integration/archive/tar/__output__/absolute.tar_extract/absolute/absolute-symlink - -> absolute/absolute-file + -> absolute-file tests/integration/archive/tar/__output__/absolute.tar_extract/absolute/link_to_etc_shadow - -> etc/shadow + -> ../etc/shadow
e3krisztian
force-pushed
the
safe_tar_symlinks_fix
branch
from
February 19, 2024 19:37
b95225f
to
600f166
Compare
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.
Based on the work of @AndrewFasano in PR #770 this should fix most of the tar symlink extraction problems reported.
Related issue: #769