Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2020318

Summary: Regression in patches to detect possible zipbomb
Product: Red Hat Enterprise Linux 7 Reporter: Paulo Andrade <pandrade>
Component: unzipAssignee: Jakub Martisko <jamartis>
Status: CLOSED ERRATA QA Contact: Vojtech Eichler <veichler>
Severity: high Docs Contact:
Priority: urgent    
Version: 7.9CC: amepatil, fkrska, fsumsal, hhofbaue, jamartis, jreznik, jsinclea, kvolny, rmetrich, scorneli, thoger
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: 7.9Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-01-11 17:35:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Paulo Andrade 2021-11-04 15:26:22 UTC
It appears to be an "off by one" at some place.

#0  extract_or_test_entrylist (numchunk=numchunk@entry=16384, pfilnum=pfilnum@entry=0x7fffffffdd80, pnum_bad_pwd=pnum_bad_pwd@entry=0x7fffffffdd90, pold_extra_bytes=pold_extra_bytes@entry=0x7fffffffdda0, 
    pnum_dirs=pnum_dirs@entry=0x7fffffffdd70, pdirlist=pdirlist@entry=0x7fffffffddb0, error_in_archive=error_in_archive@entry=0) at extract.c:1225
1225	            return PK_BOMB;
(gdb) bt
#0  extract_or_test_entrylist (numchunk=numchunk@entry=16384, pfilnum=pfilnum@entry=0x7fffffffdd80, pnum_bad_pwd=pnum_bad_pwd@entry=0x7fffffffdd90, pold_extra_bytes=pold_extra_bytes@entry=0x7fffffffdda0, 
    pnum_dirs=pnum_dirs@entry=0x7fffffffdd70, pdirlist=pdirlist@entry=0x7fffffffddb0, error_in_archive=error_in_archive@entry=0) at extract.c:1225
#1  0x000000000040af7d in extract_or_test_files () at extract.c:742
#2  0x0000000000416470 in do_seekable (lastchance=0) at process.c:994
#3  process_zipfiles () at process.c:401
#4  0x0000000000404155 in unzip (argc=0, argv=0x7fffffffdff0) at unzip.c:1281
#5  0x00007ffff781f555 in __libc_start_main () from /lib64/libc.so.6
#6  0x0000000000402059 in _start ()
(gdb) list
1220	        /* seek_zipf(__G__ pInfo->offset);  */
1221	        request = G.pInfo->offset + G.extra_bytes;
1222	        if (cover_within((cover_t *)G.cover, request)) {
1223	            Info(slide, 0x401, ((char *)slide,
1224	              LoadFarString(OverlappedComponents)));
1225	            return PK_BOMB;
1226	        }
1227	        inbuf_offset = request % INBUFSIZ;
1228	        bufstart = request - inbuf_offset;
1229


  The cover_within check fails. A simple C program to reproduce the state is:
"""
#include <stdio.h>

typedef unsigned long size_t;
typedef long bound_t;

typedef struct {
    bound_t beg;
    bound_t end;
} span_t;

typedef struct {
    span_t span[2];
    size_t num;
    size_t max;
} cover_t;

static size_t cover_find(cover, val)
    cover_t *cover;
    bound_t val;
{
    size_t lo = 0, hi = cover->num;
    while (lo < hi) {
        size_t mid = (lo + hi) >> 1;
        if (val < cover->span[mid].beg)
            hi = mid;
        else
            lo = mid + 1;
    }
    return hi;
}

/* Return true if val lies within any one of the spans in cover. */
static int cover_within(cover, val)
    cover_t *cover;
    bound_t val;
{
    size_t pos = cover_find(cover, val);
    return pos > 0 && val < cover->span[pos - 1].end;
}

int
main(void)
{
  cover_t cover;
  cover.span[0].beg = 0;
  cover.span[0].end = 4295096943;
  cover.span[1].beg = 5662998109;
  cover.span[1].end = 5673484139;
  cover.num = 2;
  cover.max = 16;
  printf("%d\n", cover_within(&cover, 4295096935));
}
"""

 The check eventually will be:

   return pos > 0 && val < cover->spans[pos - 1].end;

that is:

   return 1 > 0 && 4295096935 < 4295096943;

  It is 8 bytes smaller, thus the suspection of some kind of
"off by one" problem in the patches.

  At first we cannot provide a copy of the sample zip file, but can
provide any other information extracetd from the coredump.

Comment 34 Henrich Hofbauer 2021-12-09 15:26:05 UTC
OK from my side, please proceed. Thank you!

Comment 41 errata-xmlrpc 2022-01-11 17:35:00 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-2022:0061