You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
CVE-2018-25032 (zlib memory corruption on deflate) #605
CVE-2018-25032 tracks a bug in zlib 1.2.11 which allows memory corruption when deflating (i.e., when compressing) if the input has many distant matches.
Fedora and Red Hat are tracking this bug at https://bugzilla.redhat.com/show_bug.cgi?id=2067945 and there is no "fixed in" version as of this writing. It's also marked as affecting the packages "mingw-zlib" and "rsync".
I only see the first commit referenced as related to the CVE, but the linked NixOS and Alpine issues are applying both commits. I'm not sure how they knew the second commit should also be applied.
Reacted by Neustradamus, Nicholas Sherlock and AraHaan
The reference acknowledges mbuhl and millert of the OpenBSD project.
From the looks of it, @bluhm is also doing work for OpenBSD on zlib, see e.g. openbsd/src@b1b1dcf
which references 38e8ce3
fixing the CLEAR_HASH macro.
So much excitement! I will release the develop branch to master. Note that this bug is only when Z_FIXED is used, which it never is in production code. The only reason it's there is to facilitate testing of the decompression of fixed blocks.
Could anyone please give me some guidance regarding the reproducer?
I've managed to compile the deflate.c file and use its binary with the reproducer .txt file, but no error occurred in my case.
Then I saw, that I should you the zpipe utility, but that's where the problem arrives.
I'm fairly new to the zlib and I'm not really sure how to use the zpipe and what do you refer to as "garbage" from its output.
I would be so grateful for any kind of help with this.
How I've used the zpipe: wget https://www.zlib.net/zpipe.c -> Downloaded it from this source cc -o zpipe zpipe.c -lz -> Found that it should be compiled like this ./zpipe < CVE-2018-25032.txt > decompres -> Used it according to the manual
How do I determine if the decompres file is garbage?
Could anyone please give me some guidance regarding the reproducer?
I've` managed to compile the deflate.c file and use its binary with the reproducer .txt file, but no error occurred in my case.
It is an out-of-bounds memory read, which is undefined behavior, so a crash is not guaranteed. You can compile both zlib and the program using gcc's -fsanitize=address option to get AddressSanitizer to report the out-of-bounds read.
I'm fairly new to the zlib and I'm not really sure how to use the zpipe and what do you refer to as "garbage" from its output.
The point is that if CVE-2018-25032.txt is deflated and then inflated, it doesn't match the original file. There are many ways to test this. The deflate.c programs that Tavis and I posted only have the deflate(), as they were only intended to reproduce the out-of-bounds access. So you would need to add an inflate() if you wanted to verify the issue with the round trip.
The point is that if CVE-2018-25032.txt is deflated and then inflated, it doesn't match the original file. There are many ways to test this. The deflate.c programs that Tavis and I posted only have the deflate(), as they were only intended to reproduce the out-of-bounds access. So you would need to add an inflate() if you wanted to verify the issue with the round trip.
And did someone (if you know of anything that could be used in this test) create the inflate() already so I don't invent the wheel again?
@ljavorsk this commit in @zlib-ngzlib-ng/zlib-ng#1208 from @nmoinvaz adds a unit test and a "minideflate.c" and an "inflate.c" which I think is what you are looking for. No need to reinvent this particular wheel.
Activity
Fix a bug that can crash deflate on some input when using Z_FIXED.
vielmetti commentedon Mar 26, 2022
PR to fix in nixpkgs from @twz123 NixOS/nixpkgs#165642
vielmetti commentedon Mar 26, 2022
PR to fix in Alpine aports from @ncopa https://git.alpinelinux.org/aports/commit/?id=361df5902aa1e81594b17f06a13e10527dfb8aed and alpinelinux/aports@361df59
ynezz commentedon Mar 26, 2022
Fixed in OpenWrt down to 19.07 release with openwrt/openwrt@b3aa290
vielmetti commentedon Mar 26, 2022
Fixed in Debian, the relevant bug is https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1008265 and the version with the fix is zlib/1:1.2.11.dfsg-4
vielmetti commentedon Mar 26, 2022
Ubuntu has tracked this as https://ubuntu.com/security/CVE-2018-25032 and has a proposed patch which will bring the version to 1:1.2.11.dfsg-2ubuntu9, details are up to date at https://launchpad.net/ubuntu/+source/zlib . Ubuntu notes that "rsync" is also affected and is fixed in 3.1.3-6.
vielmetti commentedon Mar 26, 2022
Fedora and Red Hat are tracking this bug at https://bugzilla.redhat.com/show_bug.cgi?id=2067945 and there is no "fixed in" version as of this writing. It's also marked as affecting the packages "mingw-zlib" and "rsync".
briangreenery commentedon Mar 26, 2022
Do you know if the full fix requires both of these commits?
5c44459
4346a16
I only see the first commit referenced as related to the CVE, but the linked NixOS and Alpine issues are applying both commits. I'm not sure how they knew the second commit should also be applied.
vielmetti commentedon Mar 26, 2022
@briangreenery It looks like this Ubuntu patch at https://launchpad.net/ubuntu/+source/zlib/1:1.2.11.dfsg-2ubuntu9 also picks up the deflatePrime() validation check you reference at 4346a16 .
Assure that the number of bits for deflatePrime() is valid.
vielmetti commentedon Mar 26, 2022
@taviso posts a reproducer at https://www.openwall.com/lists/oss-security/2022/03/26/1 with a sample input file that triggers the bug when run against a minimal compressor that uses zlib.
vielmetti commentedon Mar 27, 2022
In https://twitter.com/OpenBSD_src/status/1507325285665968130 there is a reference to a (forthcoming) errata for OpenBSD with the name "errata/7.0/018_zlib.patch.sig".
From the looks of it this hasn't been published just yet, but when it does I expect it to be at https://ftp.openbsd.org/pub/OpenBSD/patches/7.0/common/
The reference acknowledges mbuhl and millert of the OpenBSD project.
From the looks of it, @bluhm is also doing work for OpenBSD on zlib, see e.g.
openbsd/src@b1b1dcf
which references 38e8ce3
fixing the CLEAR_HASH macro.
vielmetti commentedon Mar 27, 2022
In zlib-ng/zlib-ng#1208 @nmoinvaz adds a unit test for CVE-2018-25032 using test/CVE-2018-25032/test.txt which is a file beginning with AAABAACAA that was contributed by @taviso .
zlib-ng passes the unit test for that file, whereas zlib (master) does not.
madler commentedon Mar 27, 2022
So much excitement! I will release the develop branch to master. Note that this bug is only when
Z_FIXEDis used, which it never is in production code. The only reason it's there is to facilitate testing of the decompression of fixed blocks.rurban commentedon Mar 27, 2022
not really, because of this condition:
https://github.com/madler/zlib/blob/master/trees.c#L976
12 remaining items
chore: bump zlib to 1.2.12
update zlib dependency from 1.2.11 -> 1.2.12
Fix broken zlib dependency, update it from 1.2.11 to 1.2.12 (#9764)
Hanmac commentedon Mar 31, 2022
does the new 1.2.12 release fixes this problem too, or will there be a followup issue?
vittring commentedon Apr 1, 2022
I just saw this CVE using Snyk to scan a container image. Glad the bug has a patch! Thanks for the fix!
ljavorsk commentedon Apr 8, 2022
Could anyone please give me some guidance regarding the reproducer?
I've managed to compile the deflate.c file and use its binary with the reproducer .txt file, but no error occurred in my case.
Then I saw, that I should you the zpipe utility, but that's where the problem arrives.
I'm fairly new to the zlib and I'm not really sure how to use the zpipe and what do you refer to as "garbage" from its output.
I would be so grateful for any kind of help with this.
How I've used the zpipe:
wget https://www.zlib.net/zpipe.c-> Downloaded it from this sourcecc -o zpipe zpipe.c -lz-> Found that it should be compiled like this./zpipe < CVE-2018-25032.txt > decompres-> Used it according to the manualHow do I determine if the
decompresfile is garbage?ebiggers commentedon Apr 8, 2022
It is an out-of-bounds memory read, which is undefined behavior, so a crash is not guaranteed. You can compile both zlib and the program using gcc's
-fsanitize=addressoption to get AddressSanitizer to report the out-of-bounds read.The point is that if
CVE-2018-25032.txtis deflated and then inflated, it doesn't match the original file. There are many ways to test this. Thedeflate.cprograms that Tavis and I posted only have thedeflate(), as they were only intended to reproduce the out-of-bounds access. So you would need to add aninflate()if you wanted to verify the issue with the round trip.ebiggers commentedon Apr 8, 2022
This was essentially the same problem, so it was fixed by the same commit and thus is fixed in 1.2.12.
ljavorsk commentedon Apr 11, 2022
And did someone (if you know of anything that could be used in this test) create the inflate() already so I don't invent the wheel again?
vielmetti commentedon Apr 11, 2022
@ljavorsk this commit in @zlib-ng zlib-ng/zlib-ng#1208 from @nmoinvaz adds a unit test and a "minideflate.c" and an "inflate.c" which I think is what you are looking for. No need to reinvent this particular wheel.
Fix broken zlib dependency, update it from 1.2.11 to 1.2.12 (#9764)
Fix broken zlib dependency, update it from 1.2.11 to 1.2.12 (meta#9764)
Fix broken zlib dependency, update it from 1.2.11 to 1.2.12 (#9764)
Fix broken zlib dependency, update it from 1.2.11 to 1.2.12 (#9764)
Fix broken zlib dependency, update it from 1.2.11 to 1.2.12 (meta#9764)