RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1920632 - unzip -t dies due to "possible zip bomb" with Java-generated zip file
Summary: unzip -t dies due to "possible zip bomb" with Java-generated zip file
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: unzip
Version: 7.9
Hardware: x86_64
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Jakub Martisko
QA Contact: Radka Brychtova
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-01-26 19:05 UTC by Carlos Santos
Modified: 2021-06-08 22:34 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-06-08 22:33:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Java source code (1.03 KB, text/plain)
2021-01-26 19:05 UTC, Carlos Santos
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 5735561 0 None None None 2021-01-27 09:50:43 UTC
Red Hat Product Errata RHBA-2021:2317 0 None None None 2021-06-08 22:34:00 UTC

Internal Links: 1953565

Description Carlos Santos 2021-01-26 19:05:14 UTC
Created attachment 1750982 [details]
Java source code

Description of problem:

When unzipping a Java zipped archive, created by a Java application, including
a file bigger than 4.2Gb, the unzipping (unzip version 6.0.21) is failing with
error: invalid zip file with overlapped components (possible zip bomb).

Version-Release number of selected component (if applicable):

$ rpm -q java-1.8.0-openjdk java-1.8.0-openjdk-devel java-1.8.0-openjdk-headless unzip
java-1.8.0-openjdk-1.8.0.282.b08-1.el7_9.x86_64
java-1.8.0-openjdk-devel-1.8.0.282.b08-1.el7_9.x86_64
java-1.8.0-openjdk-headless-1.8.0.282.b08-1.el7_9.x86_64
unzip-6.0-21.el7.x86_64

How reproducible:

Always

Steps to Reproduce:

$ :> input1
$ dd if=/dev/zero of=input2 bs=1M count=5000
5000+0 records in
5000+0 records out
5242880000 bytes (5.2 GB) copied, 11.8114 s, 444 MB/s

$ java -version
openjdk version "1.8.0_282"
OpenJDK Runtime Environment (build 1.8.0_282-b08)
OpenJDK 64-Bit Server VM (build 25.282-b08, mixed mode)

$ rpm -q zip
zip-3.0-11.el7.x86_64
$ zip -h
Copyright (c) 1990-2008 Info-ZIP - Type 'zip "-L"' for software license.
Zip 3.0 (July 5th 2008). Usage:
zip [-options] [-b path] [-t mmddyyyy] [-n suffixes] [zipfile list] [-xi list]
  The default action is to add or replace zipfile entries from list, which
  can include the special name - to compress standard input.
  If zipfile and list are omitted, zip compresses stdin to stdout.
  -f   freshen: only changed files  -u   update: only changed or new files
  -d   delete entries in zipfile    -m   move into zipfile (delete OS files)
  -r   recurse into directories     -j   junk (don't record) directory names
  -0   store only                   -l   convert LF to CR LF (-ll CR LF to LF)
  -1   compress faster              -9   compress better
  -q   quiet operation              -v   verbose operation/print version info
  -c   add one-line comments        -z   add zipfile comment
  -@   read names from stdin        -o   make zipfile as old as latest entry
  -x   exclude the following names  -i   include only the following names
  -F   fix zipfile (-FF try harder) -D   do not add directory entries
  -A   adjust self-extracting exe   -J   junk zipfile prefix (unzipsfx)
  -T   test zipfile integrity       -X   eXclude eXtra file attributes
  -y   store symbolic links as the link instead of the referenced file
  -e   encrypt                      -n   don't compress these suffixes
  -h2  show more help

$ zip test_zip input1 input2
  adding: input1 (stored 0%)
  adding: input2 (deflated 100%)
$ unzip -v test_zip
Archive:  test_zip.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Stored        0   0% 01-26-2021 09:37 00000000  input1
5242880000  Defl:N  5088077 100% 01-26-2021 09:37 6aa043f2  input2
--------          -------  ---                            -------
5242880000          5088077 100%                            2 files

$ javac ZipMultipleFiles.java
$ java ZipMultipleFiles
$ unzip -v test_javazip
Archive:  test_javazip.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
       0  Defl:N        2   0% 01-26-2021 09:38 00000000  input1
5242880000  Defl:N  5095827 100% 01-26-2021 09:38 6aa043f2  input2
--------          -------  ---                            -------
5242880000          5095829 100%                            2 files

$ unzip -t test_zip
Archive:  test_zip.zip
    testing: input1                   OK
    testing: input2                   OK
No errors detected in compressed data of test_zip.zip.

$ unzip -t test_javazip
Archive:  test_javazip.zip
    testing: input1                   OK
error: invalid zip file with overlapped components (possible zip bomb)

$ zipinfo -v test_zip.zip 
Archive:  test_zip.zip
There is no zipfile comment.

End-of-central-directory record:
-------------------------------

  Zip archive file size:                   5088487 (00000000004DA4E7h)
  Actual end-cent-dir record offset:       5088389 (00000000004DA485h)
  Expected end-cent-dir record offset:     5088389 (00000000004DA485h)
  (based on the length of the central directory and its expected offset)

  This zipfile constitutes the sole disk of a single-part archive; its
  central directory contains 2 entries.
  The central directory is 164 (00000000000000A4h) bytes long,
  and its (expected) offset in bytes from the beginning of the zipfile
  is 5088225 (00000000004DA3E1h).


Central directory entry #1:
---------------------------

  input1

  offset of local header from start of archive:   0
                                                  (0000000000000000h) bytes
  file system or operating system of origin:      Unix
  version of encoding software:                   3.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   1.0
  compression method:                             none (stored)
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2021 Jan 26 09:37:20
  file last modified on (UT extra field modtime): 2021 Jan 26 09:37:19 local
  file last modified on (UT extra field modtime): 2021 Jan 26 12:37:19 UTC
  32-bit CRC value (hex):                         00000000
  compressed size:                                0 bytes
  uncompressed size:                              0 bytes
  length of filename:                             6 characters
  length of extra field:                          24 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  Unix file attributes (100664 octal):            -rw-rw-r--
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification/access times.
  - A subfield with ID 0x7875 (Unix UID/GID (any size)) and 11 data bytes:
    01 04 9e 56 00 00 04 9e 56 00 00.

  There is no file comment.

Central directory entry #2:
---------------------------

  input2

  offset of local header from start of archive:   64
                                                  (0000000000000040h) bytes
  file system or operating system of origin:      Unix
  version of encoding software:                   3.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   4.5
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          no
  file last modified on (DOS date/time):          2021 Jan 26 09:37:36
  file last modified on (UT extra field modtime): 2021 Jan 26 09:37:35 local
  file last modified on (UT extra field modtime): 2021 Jan 26 12:37:35 UTC
  32-bit CRC value (hex):                         6aa043f2
  compressed size:                                5088077 bytes
  uncompressed size:                              5242880000 bytes
  length of filename:                             6 characters
  length of extra field:                          36 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  Unix file attributes (100664 octal):            -rw-rw-r--
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x5455 (universal time) and 5 data bytes.
    The local extra field has UTC/GMT modification/access times.
  - A subfield with ID 0x7875 (Unix UID/GID (any size)) and 11 data bytes:
    01 04 9e 56 00 00 04 9e 56 00 00.
  - A subfield with ID 0x0001 (PKWARE 64-bit sizes) and 8 data bytes:
    00 00 80 38 01 00 00 00.

  There is no file comment.

$ zipinfo -v test_javazip
Archive:  test_javazip.zip
There is no zipfile comment.

End-of-central-directory record:
-------------------------------

  Zip archive file size:                   5096079 (00000000004DC28Fh)
  Actual end-cent-dir record offset:       5096057 (00000000004DC279h)
  Expected end-cent-dir record offset:     5096057 (00000000004DC279h)
  (based on the length of the central directory and its expected offset)

  This zipfile constitutes the sole disk of a single-part archive; its
  central directory contains 2 entries.
  The central directory is 116 (0000000000000074h) bytes long,
  and its (expected) offset in bytes from the beginning of the zipfile
  is 5095941 (00000000004DC205h).


Central directory entry #1:
---------------------------

  input1

  offset of local header from start of archive:   0
                                                  (0000000000000000h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   2.0
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   2.0
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2021 Jan 26 09:38:26
  32-bit CRC value (hex):                         00000000
  compressed size:                                2 bytes
  uncompressed size:                              0 bytes
  length of filename:                             6 characters
  length of extra field:                          0 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  There is no file comment.

Central directory entry #2:
---------------------------

  There are an extra 16 bytes preceding this file.

  input2

  offset of local header from start of archive:   54
                                                  (0000000000000036h) bytes
  file system or operating system of origin:      MS-DOS, OS/2 or NT FAT
  version of encoding software:                   4.5
  minimum file system compatibility required:     MS-DOS, OS/2 or NT FAT
  minimum software version required to extract:   4.5
  compression method:                             deflated
  compression sub-type (deflation):               normal
  file security status:                           not encrypted
  extended local header:                          yes
  file last modified on (DOS date/time):          2021 Jan 26 09:38:26
  32-bit CRC value (hex):                         6aa043f2
  compressed size:                                5095827 bytes
  uncompressed size:                              5242880000 bytes
  length of filename:                             6 characters
  length of extra field:                          12 bytes
  length of file comment:                         0 characters
  disk number on which file begins:               disk 1
  apparent file type:                             binary
  non-MSDOS external file attributes:             000000 hex
  MS-DOS file attributes (00 hex):                none

  The central-directory extra field contains:
  - A subfield with ID 0x0001 (PKWARE 64-bit sizes) and 8 data bytes:
    00 00 80 38 01 00 00 00.

  There is no file comment.

Actual results:

error: invalid zip file with overlapped components (possible zip bomb)

Expected results:

No errors detected in compressed data of test_javazip.zip.

Additional info:

The results are the same on RHEL-7.9 with

$ rpm -q java-11-openjdk java-11-openjdk-devel unzip
java-11-openjdk-11.0.10.0.9-0.el7_9.x86_64
java-11-openjdk-devel-11.0.10.0.9-0.el7_9.x86_64
unzip-6.0-21.el7.x86_64

The results are the same on RHEL-8.3 with
$ rpm -q java-1.8.0-openjdk unzip
java-1.8.0-openjdk-1.8.0.282.b08-2.el8_3.x86_64
unzip-6.0-43.el8.x86_64

The results are the same on RHEL-8.3 with
$ rpm -q java-11-openjdk java-11-openjdk-devel unzip
java-11-openjdk-11.0.10.0.9-4.el8_3.x86_64
java-11-openjdk-devel-11.0.10.0.9-4.el8_3.x86_64
unzip-6.0-43.el8.x86_64

Comment 11 errata-xmlrpc 2021-06-08 22:33:57 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (unzip bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:2317


Note You need to log in before you can comment on or make changes to this bug.