CVE-2026-27820
JSON

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 packageVersionsReported by
ruby zlib< 3.0.1, >= 3.1.0, < 3.1.2, >= 3.2.0, < 3.2.3CVE List
zlib (RubyGems)from 3.2.0 before 3.2.3, from 3.1.0 before 3.1.2, before 3.0.1GitHub Advisory Database
ruby-lang zlibbefore 3.0.1, from 3.1.0 before 3.1.2, from 3.2.0 before 3.2.3NVD

All scores

GitHub_M1.7low CVSS:4.0CVSS: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
GitHub9.8medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
GitHubmedium CVSS:4.0CVSS: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
NVD9.8critical CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

Classification

CWE-120CWE-131

SSVC (CISA-ADP): exploitation none, automatable yes, technical impact partial.

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

calysteon

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

SourceRecordLicence
CVE ListCVE-2026-27820 changed 2026-04-16CVE Terms of Use
GitHub Advisory DatabaseGHSA-g857-hhfv-j68w changed 2026-09-10CC-BY-4.0
NVDCVE-2026-27820 changed 2026-10-26Public domain