-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Potential Zip Slip vulnerability on querylog #40631
Comments
@nicowaisman Thank you for the report! @yuzefovich Can you take a look at this? I'm not sure where the input to this function comes from; is there a simple fix that would let us extract the zip files in a safer/more conservative way? |
The path to a zip file comes via a flag to the querylog (like We could simply remove the option to use the zip file as a source of the query log and force the user to extract the archive and then specify the path to the directory containing the log. |
The problem really is that if you use a zip file, that has files like with a name like: Again, as it is right now, you need to unzip a harmful file, so the risk is quite reduced, but we want to warn you about a future potential outcome. |
I see, thanks for the explanation @nicowaisman. As far as I understand, the same thing will happen if the user extracts the harmful zip file manually, right? Or I guess it might depend on the way the zip is extracted? Anyway, the |
Well, you don't really need to stop them from unziping, you just need to double check for path traversal. Or you could check this article: Regards |
Relevant snippet from the last link, modified for use here: // Check for ZipSlip. More Info: http://bit.ly/2MsjAWE
if !strings.HasPrefix(path, filepath.Clean(dest)+string(os.PathSeparator)) {
return fmt.Errorf("%s: illegal file path", path)
} Possibly adding a message about trusting the zip file in the error. It's a reasonable sanity check to have. Most unzipping tools don't allow this behavior:
and disallowing paths such as these should never affect normal use. |
@nicowaisman @sauyon Thanks for the input folks! I opened a PR using @sauyon's suggested fix (with a modification of the error message). |
Describe the problem
Hey cockroach team,
We found a potentially vulnerable function to the Zip Slip vulnerability. The idea of the vulnerability is that by triggering a path transversal on a zip file you are able to write files outside of your folder (https://cwe.mitre.org/data/definitions/29.html)
Here is the vulnerable function:
https://github.com/cockroachdb/cockroach/blob/master/pkg/workload/querylog/querylog.go#L544
We are well aware, that downloads files passed to unzip only occur from a specific URL provided by cockroach, so the risk is really low, but we thought we should let you know about the potential risk.
Regards
Semmle Security Team
Discovered by Max Schaefer
The text was updated successfully, but these errors were encountered: