-
-
Notifications
You must be signed in to change notification settings - Fork 670
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
Remove symlinks in zip files #1424
Comments
This is interesting. Is there any harm it can do to end user as well? I mean should application prevent uploading zip-files containing symlinks, or it is only necessary when application actually extracts files (from user) and processes their content. |
If the user directly uploads a symlink that links to /etc/passwd the user's passwd file would be uploaded to the server. But if the app has a function to untar or unzip (for example, a Ruby app), and then the user is able to see the content of the uploaded zip or tar file, then the user will be able to see the server's passwd file. I believe on of the mitigations is to remove any symlinks when the app starts to extract a compressed file. |
Interesting attack vector. Seems like a valid requirement to have. Does this mean it is sort of an RCE-level kind of threat the way this vulnerability works? |
@csfreak92 It could lead to an RCE if the attacker would be able to fetch some sensitive secrets in the environment variables files or the source code. |
Well, played with that a bit. Now there is nice question - what is the actual defense? Original proposal:
Options:
|
Why? (It is not mine either, see below, just asking for clarification.)
Indeed.
The risk for *.zip bombs will not increase on inspection if one just scans the archive structure, because files in *.zip archives are always compressed individually (not-solid compression). For example one can use:
For other formats like compressed tarballs, *.7z, etc. using solid compression, this may indeed a problem. Uncompressed tarballs are OK too: similarly
With a sandbox symlinks do not do harm at once, but when deleting the sandbox one still has to make sure not to follow symlinks... Another much better "meta-option" is of course to find a library or framework with safe defaults and good structured logging (for detection) that can do most of the hard work above... |
Why I don't like removing symlinks - it is automodification (changing integrity) for user-provided data. Is there any valid and needed use-case why an application should allow symlinks? My direction is something like (wordsmithing and correction needed): Category V12.1, Level 2 (as zip bomb 12.1.2 is also level 2) |
I am also inclined to agree with @elarlang on this one. Automodification of any uploaded files that may contain symlinks breaks the principle of integrity of the user's data. @ImanSharaf, I am on the same boat as with that question of what is the valid and needed use-case for an application to allow symlinks? Maybe you could enlighten us more about it? |
I think the question was addressed to @guillaume-d |
@elarlang @csfreak92 @guillaume-d where are we at right now for this one? Can I commit the new item with the proposed solution? |
I don't think it's ready yet. FYI: we do some "commit sessions" with Josh and it will be addressed one day :) |
Sorry I missed the correction! I do not have a usecase for symlinks in archives either. |
As proposal we can finetune input from #1424 (comment)
Category V12.1, Level 2 (as zip bomb 12.1.2 is also level 2) |
What happens if we do need to accept symlinks? Is there a way to protect ourselves in that case @elarlang? |
I don't know what could be the reason to accept symlinks? But if you really need to, you need to validate it against allow-list or use sandboxed environment etc. Anyway, I don't think we need to cover that in more detailed than "if not especially intended by the application". |
Ok so how about:
|
ok for me |
Opened #1670 |
Opened #1671 to include a better CWE |
I was checking this HackerOne report with a $29000 bounty and I found it very interesting. This is different than Zip Slip. In case of Zip Slip we can inject .. in the file path so we can extract our file in a wrong place. In this report, the attacker crafts a malicious symlink to /etc/passwd when the backend extracts it untar_zxf function only changes the permissions and extract the symlink as is, so the attacker was able to read the passwd file!
I believe we need an ASVS item to check for removal of symlinks in the zip files.
The text was updated successfully, but these errors were encountered: