-
-
Notifications
You must be signed in to change notification settings - Fork 390
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
[sec] check if symlink points outside of destination directory #242
Comments
This one is difficult to test because it requires creating a specially crafted double-evil.zip that contains "invalid" double entries. I'd say it would be sufficient to
I'll open another issue for crafting the bad file. I don't think that can be done with Edit: deleted commentsThere were a few back and forth comments about who might take this, but in the end no one did, so I removed them. |
Hi, I'd like to take this one! :) |
I understand we need to make sure, the destination path is not a symlink, if it is, I guess we need to exit with an
Also when you say:
What do you mean by outside target? |
@stoiandan I have submitted a fix for this issue as #269. |
Thank you for the patch, @tslocum -- however, it's been a long time and v4 no longer has this issue, so, closing. (Could be relevant again if/when v4 gets a command.) |
I was able to confirm that
os.Create()
will happily follow symlinks.Although standard tools like
tar
will not likely allow you to add two files with the same name to an archive file, it's certainly easy enough to do in code. This means that we need to add an additional check before writing to a destination to make sure that it's not a symlink outside of the destination.The vulnerability only exists if
OverwriteExisting
is also turned on.What file is affected?
filecompressor.go
:Possible solution
If the destination exists we should always check if it's a symlink first:
Also, we could block ALL symilnks that have a target outside of the destination directory.
I think the former approach is the best for now, as some archives may link outside of the destination directory for legitimate reasons.
Please link to any related issues, pull requests, and/or discussion
This is related to
The text was updated successfully, but these errors were encountered: