Skip to content
This repository has been archived by the owner on Feb 20, 2020. It is now read-only.

Bug 1466872: Fix zip slip vulnerability #99

Closed
wants to merge 1 commit into from

Conversation

walac
Copy link
Contributor

@walac walac commented Jun 7, 2018

@walac walac requested a review from petemoore June 7, 2018 13:05
@coveralls
Copy link

Coverage Status

Coverage decreased (-52.3%) to 16.077% when pulling 23e2a8f on walac:master into 8cece2c on taskcluster:master.

@@ -150,6 +151,11 @@ func Unzip(b []byte, dest string) error {

path := filepath.Join(dest, f.Name)

// Fix for https://snyk.io/research/zip-slip-vulnerability
if !strings.HasPrefix(path, dest) {
Copy link
Member

@petemoore petemoore Jun 7, 2018

Choose a reason for hiding this comment

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

This will not work if dest has not been cleaned (see filepath.Clean).

Also the Unzip function you are patching here is the one that is used to extract zips which are embedded into the worker type definition, which are trusted. Here we are not vulnerable, since if you can modify the content of the zip, you can also modify the absolute location it should be installed to, since both are specified in the same section of the worker type definition, with the same access controls required to modify them.

The code that extracts untrusted zips is in mounts.go which calls github.com/mholt/archiver package. That was already patched in mholt/archiver#65 and since we don't vendor that library, all new builds should pick up the fix. So we should already be safe.

Probably the best is for us to delete this Unzip method, and use package github.com/mholt/archiver everywhere, for simplicity, but again, it seems we are not vulnerable as things stand, so this is just a nice simplification rather than a security enhancement.

Despite this, many thanks for the patch. 😄

@petemoore petemoore closed this Jun 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants