1.7low
zlib: Buffer Overflow in Zlib::GzipReader ungetc via large input leads to memory corruption
- Severity
- 1.7low CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.58% (higher than 49% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-g857-hhfv-j68w
Description
zlib is a Ruby interface for the zlib compression/decompression library. Versions 3.0.0 and below, 3.1.0, 3.1.1, 3.2.0 and 3.2.1 contain a buffer overflow vulnerability in the Zlib::GzipReader. The zstream_buffer_ungets function prepends caller-provided bytes ahead of previously produced output but fails to guarantee the backing Ruby string has enough capacity before the memmove shifts the existing data. This can lead to memory corruption when the buffer length exceeds capacity. This issue has been fixed in versions 3.0.1, 3.1.2 and 3.2.3.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| ruby zlib | < 3.0.1, >= 3.1.0, < 3.1.2, >= 3.2.0, < 3.2.3 | CVE List |
| zlib (RubyGems) | from 3.2.0 before 3.2.3, from 3.1.0 before 3.1.2, before 3.0.1 | GitHub Advisory Database |
| ruby-lang zlib | before 3.0.1, from 3.1.0 before 3.1.2, from 3.2.0 before 3.2.3 | NVD |
All scores
| GitHub_M | 1.7low CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N/E:U |
| GitHub | 9.8medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
| GitHub | medium CVSS:4.0 | CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:P/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:U |
| NVD | 9.8critical CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H |
Classification
What each source says
CVE List
zlib is a Ruby interface for the zlib compression/decompression library. Versions 3.0.0 and below, 3.1.0, 3.1.1, 3.2.0 and 3.2.1 contain a buffer overflow vulnerability in the Zlib::GzipReader. The zstream_buffer_ungets function prepends caller-provided bytes ahead of previously produced output but fails to guarantee the backing Ruby string has enough capacity before the memmove shifts the existing data. This can lead to memory corruption when the buffer length exceeds capacity. This issue has been fixed in versions 3.0.1, 3.1.2 and 3.2.3.
GitHub Advisory Database
Details
A buffer overflow vulnerability exists in Zlib::GzipReader.
The zstream_buffer_ungets function prepends caller-provided bytes ahead of previously produced output but fails to guarantee the backing Ruby string has enough capacity before the memmove shifts the existing data. This can lead to memory corruption when the buffer length exceeds capacity.
Recommended action
We recommend to update the zlib gem to version 3.2.3 or later. In order to ensure compatibility with bundled version in older Ruby series, you may update as follows instead:
- For Ruby 3.2 users: Update to zlib 3.0.1
- For Ruby 3.3 users: Update to zlib 3.1.2
You can use gem update zlib to update it. If you are using bundler, please add gem "zlib", ">= 3.2.3" to your Gemfile.
Affected versions
zlib gem 3.2.2 or lower
Credits
References
NVD (es)
zlib es una interfaz Ruby para la biblioteca de compresión/descompresión zlib. Las versiones 3.0.0 e inferiores, 3.1.0, 3.1.1, 3.2.0 y 3.2.1 contienen una vulnerabilidad de desbordamiento de búfer en Zlib::GzipReader. La función zstream_buffer_ungets antepone bytes proporcionados por el llamador delante de la salida producida previamente, pero no garantiza que la cadena Ruby subyacente tenga suficiente capacidad antes de que memmove desplace los datos existentes. Esto puede llevar a corrupción de memoria cuando la longitud del búfer excede la capacidad. Este problema ha sido solucionado en las versiones 3.0.1, 3.1.2 y 3.2.3.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2026-27820 changed 2026-04-16 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-g857-hhfv-j68w changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2026-27820 changed 2026-10-26 | Public domain |