A vulnerability has been identified in the zlib library (CVE-2018-25032) that leads to a buffer overflow when attempting to compress a specially crafted sequence of characters in the input data. Researchers have demonstrated the potential for process crashes in its current state. Whether the issue could have more serious consequences has yet to be explored.
The vulnerability manifests starting from zlib version 1.2.2.2 and affects the current release, zlib 1.2.11, among others. Notably, a patch to fix the vulnerability was proposed back in 2018, but developers did not pay attention to it and did not release a corrective version (the zlib library was last updated in 2017). The fix has also not yet been included in the packages offered by distributions. You can track the publication of fixes by distributions on these pages: Debian, RHEL, Fedora, SUSE, Ubuntu, Arch Linux, OpenBSD, FreeBSD, NetBSD. The zlib-ng library is not affected by this issue.
The vulnerability occurs if a large number of compressible matches appear in the input stream, which are processed using fixed Huffman code compression. Under certain circumstances, the contents of the intermediate buffer, which stores the compressed result, may overlap with the memory where the character frequency table is stored. This results in the formation of invalid compressed data and a crash due to writing beyond the buffer's limits.
The vulnerability can only be exploited when using a fixed Huffman code compression strategy. Such a strategy is chosen when the option Z_FIXED is explicitly enabled in the code (example sequence that leads to a crash when using the Z_FIXED option). According to the code, the Z_FIXED strategy can also be selected automatically if the optimal and static trees computed for the data have the same size.
It is still unclear whether conditions can be tailored for exploiting the vulnerability when using the Z_DEFAULT_STRATEGY compression strategy applied by default. If not, the vulnerability will be limited to specific systems where the Z_FIXED option is explicitly applied. If so, the damage from the vulnerability could be quite significant since the zlib library is the de facto standard and is used in many popular projects, including the Linux kernel, OpenSSH, OpenSSL, apache httpd, libpng, FFmpeg, rsync, dpkg, rpm, Git, PostgreSQL, MySQL, etc.
Source: opennet.ru
