Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bus error in zzip_disk_findfirst (src/zzip/mmapped.c) [CVE-2018-6540] #15

Closed
ProbeFuzzer opened this issue Feb 1, 2018 · 6 comments
Closed

Comments

@ProbeFuzzer
Copy link

ProbeFuzzer commented Feb 1, 2018

On latest version (0.13.67) and master branch of zziplib:
there is a bus error caused by loading of misaligned address in zzip_disk_findfirst function of src/zzip/mmapped.c, which could be triggered by the POC below. Note that this issue is different from CVE-2018-6484.

The issue happens since the pointer "trailer" (line 420) 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.

419             struct zzip_disk_trailer *trailer = (struct zzip_disk_trailer *) p;
420             zzip_size_t rootseek = zzip_disk_trailer_get_rootseek(trailer);

To reproduce the issue, run: ./unzip-mem $POC
The POC could be downloaded at: https://github.com/ProbeFuzzer/poc/blob/master/zziplib/zziplib_0-13-67_unzip-mem_memory-alignment-errors_zzip_disk_findfirst.zip

master/src/zzip/mmapped.c:420:36: runtime error: load of misaligned address 0x7fc6924310f2 for type 'uint32_t', which requires 4 byte alignment
0x7fc6924310f2: note: pointer points here
47 00 00 00 80 00 b5 b5 b5 b5 b5 b5 b5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
^

@abergmann
Copy link

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

gdraheim added a commit that referenced this issue Feb 4, 2018
@gdraheim
Copy link
Owner

gdraheim commented Feb 5, 2018

can not reproduce in test_65407

@gdraheim
Copy link
Owner

gdraheim commented Feb 5, 2018

after double-checking the download-zip, the error is now reproduced in

make test_65402

gdraheim added a commit that referenced this issue Feb 5, 2018
@gdraheim
Copy link
Owner

gdraheim commented Feb 5, 2018

fixed => now OK for test_65402

@gdraheim gdraheim added this to the v0.13.68 next release milestone Feb 5, 2018
@gdraheim
Copy link
Owner

gdraheim commented Feb 5, 2018

The main problem had been

    if (file->stored + size >= file->endbuf)
    {
        DBG1("try to read beyond end of file");
        return 0; /* ESPIPE */
    }

@gdraheim
Copy link
Owner

gdraheim commented Feb 5, 2018

checking back v0.13.67 where the testcase has shown the problem => fixed

@gdraheim gdraheim closed this as completed Feb 5, 2018
@gdraheim gdraheim changed the title Bus error in zzip_disk_findfirst (src/zzip/mmapped.c) Bus error in zzip_disk_findfirst (src/zzip/mmapped.c) [CVE-2018-6540] Mar 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants