Skip to content
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 zip slip vulnerability #47

Merged
merged 1 commit into from
Oct 2, 2019
Merged

Fix zip slip vulnerability #47

merged 1 commit into from
Oct 2, 2019

Conversation

dansimau
Copy link
Contributor

This fixes an issue where files within a zip file can break out of the target directory when being extracted.

Fixes #46.

@dansimau dansimau self-assigned this Sep 10, 2019
Copy link

@shivamdixit shivamdixit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Left a couple of small comments.

astro/tvm/utils.go Show resolved Hide resolved
@jcorbin
Copy link

jcorbin commented Sep 17, 2019

Fwiw, I have a need to implement similar zip extraction, here's the code I ended up with: https://gist.github.com/jcorbin/fd0716bd0bc4c49cd22d73e4aad23b38

  • extracts in GOMAXPROCS-parallel
  • slightly better reliability / error flow in the file extraction path
  • slightly better file permission restoration
  • more efficient for large archives, since it uses io.CopyBuffer internally with a re-used buffer, rather than io.Copy dynamically allocated a 32KB buffer for every extracted file (causing GC pressure scaling with size of archive)
  • oh and it supports context cancellation, in case that matters (e.g. timing out a large archive extraction, or otherwise)...
  • ...around this code, I'm running the extraction into a sibling temporary directory, and then either os.Rename-ing into place when done, or os.RemoveAll-ing it in case of (e.g. cancellation) error (similar to github.com/google/reanmio.PendingFile, but for directories

@dansimau dansimau merged commit 2aec9b3 into master Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential
3 participants