gdraheim / zziplib

The ZZIPlib provides read access on ZIP-archives and unpacked data. It features an additional simplified API following the standard Posix API for file access
Other
62 stars 50 forks source link

Bus error in __zzip_fetch_disk_trailer (src/zzip/zip.c) [CVE-2018-6484] #14

Closed ProbeFuzzer closed 6 years ago

ProbeFuzzer commented 6 years ago

On latest version (0.13.67) and master branch of zziplib: there is a bus error caused by loading of misaligned address in __zzip_fetch_disk_trailer function of src/zzip/zip.c, which could be triggered by the POC below.

The issue happens since the struct zzip_disk_trailer "orig" (line 318) could be manipulated by a crafted zip file, resulting in a misaligned memory access and bus error. Note that the issue is in libzip and may affect downstream programs. The POC is as small as 100 bytes.

312                     struct zzip_disk_trailer *orig =
313                         (struct zzip_disk_trailer *) tail;
...
318                     trailer->zz_rootseek = zzip_disk_trailer_rootseek(orig);

To reproduce the issue, run: ./zzdir $POC The POC could be downloaded at: https://github.com/ProbeFuzzer/poc/blob/master/zziplib/zziplib_0-13-67_zzdir_memory-alignment-errors___zzip_fetch_disk_trailer.zip

master/src/zzip/zip.c:315:43: runtime error: load of misaligned address 0x7f079d64a027 for type 'uint16_t', which requires 2 byte alignment 0x7f079d64a027: note: pointer points here 00 00 00 20 01 40 00 70 47 50 50 50 51 55 50 50 50 50 50 50 00 00 00 00 00 00 00 00 00 00 00 00 ^

abergmann commented 6 years ago

CVE-2018-6484 was assigned to this issue. https://nvd.nist.gov/vuln/detail/CVE-2018-6484

abergmann commented 6 years ago

The POC download link is not working.

ProbeFuzzer commented 6 years ago

@abergmann Thanks, the poc link should work now.

gdraheim commented 6 years ago

using "unzzip -l" should be comparable but test_64844 does not reproduce the problem

gdraheim commented 6 years ago

checking the download-sizes, and adding an explicizt zzdir-testcase, which however only has an encoding-problem ("Invalid or incomplete multibyte")

make test_64848

May be a misaligned is dependent on the processor? Here it is a Core i7-3630QM

gdraheim commented 6 years ago

checking back with v0.13.67 where the testcase actually show a bus error.

As the testcase on the master is fine now, this may be assumed as => fixed