8000 Minizip allows extraction outside root folder · Issue #433 · zlib-ng/minizip-ng · GitHub
[go: up one dir, main page]

Skip to content

Minizip allows extraction outside root folder #433

Closed

Description

@tim-janik

With a specially crafted ZIP file, Minizip (via mz_zip_reader_save_all()) will write into $CWD/..

Minizip 2.9.0 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
-l t.zip 
      Packed     Unpacked Ratio Method   Attribs Date     Time  CRC-32     Name
      ------     -------- ----- ------   ------- ----     ----  ------     ----
          17           17  100% Stored  81800080 11-04-06 11:33 c7f761e7   ././y/x/../../../../../../../tmp/zz
          21           56   37% Defl:X  81800080 10-22-19 23:48 572b1c12   ././y/x/../../../../../../../tmp/zz

Extraction:

Minizip 2.9.0 - https://github.com/nmoinvaz/minizip
---------------------------------------------------
-x t.zip 
Archive t.zip
Extracting ././y/x/../../../../../../../tmp/zz
The file ../tmp/zz exists. Overwrite ? [y]es, [n]o, [A]ll: 

Note how e.g. UnZip 6.00 handles this situation:

$ unzip t.zip
Archive:  t.zip
warning:  skipped "../" path component(s) in ././y/x/../../../../../../../tmp/zz
 extracting: y/x/tmp/zz              
warning:  skipped "../" path component(s) in ././y/x/../../../../../../../tmp/zz
replace y/x/tmp/zz? [y]es, [n]o, [A]ll, [N]one, [r]ename: 

Activity

  1. Coeur commented on Oct 23, 2019

    @Coeur
    Collaborator

    For reference, SSZipArchive (which uses minizip internally) shouldn't be affected by this issue, as I'm using native (Apple) path sanitation:
    https://github.com/ZipArchive/ZipArchive/blob/63cc9b455c32cbbeb4df5017390e0f6a2af50c78/SSZipArchive/SSZipArchive.m#L1253-L1256

  2. nmoinvaz commented on Oct 24, 2019

    @nmoinvaz
    Member

    It is now fixed in dev branch. Thanks. Ref #268.

  3. added
    1.2Related to older version of minizip 1.2
    fixedIssue or bug has been fixed
    and removed
    1.2Related to older version of minizip 1.2
    on Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixedIssue or bug has been fixedsecuritySecurity issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0