CVE-2026-27820

zlib: Buffer Overflow in Zlib::GzipReader ungetc via large input leads to memory corruption

Published Apr 16, 2026 CVSS 4.0 · 1.7 Low EPSS < 1% KEV · Not listed
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.

Analysis

AI-generated

Technical impact

The flaw is a buffer overflow in Zlib::GzipReader’s zstream_buffer_ungets function within the Ruby zlib library. The function prepends caller‑supplied bytes ahead of existing output but does not verify the backing Ruby string has adequate capacity before the memmove operation. When the combined input exceeds the capacity, memory corruption occurs. This type of vulnerability aligns with CWE‑120 and CWE‑131 and can result in arbitrary code execution or process crash if an attacker supplies a sufficiently large payload.

Affected Systems

Affected are Ruby zlib versions 3.0.0 and earlier, 3.1.0, 3.1.1, 3.2.0, and 3.2.1. The issue was fixed in version 3.0.1, 3.1.2, and 3.2.3. All Ruby applications that depend on zlib and invoke Zlib::GzipReader::ungetc with large streams are vulnerable.

Risk and Exploitability

The CVSS score is 1.7, indicating low severity. Exploit probability is not available, and it is not recognized in the CISA known exploitation catalog. Based on the description, it is inferred that the likely attack vector involves supplying a large gzip payload to the Zlib::GzipReader::ungetc function, which could trigger the overflow. The risk is limited to applications that accept large gzip payloads but should still be mitigated promptly.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Upgrade the Ruby zlib library to version 3.0.1, 3.1.2, 3.2.3 or later.
  • Avoid using Zlib::GzipReader.ungetc on data from untrusted sources.
  • Validate input size and reject gzip streams exceeding a safe threshold before passing them to ungetc.

Generated by OpenCVE AI on April 17, 2026 at 04:52 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DLA Debian DLA DLA-4716-1 ruby2.7 security update
Github GHSA Github GHSA GHSA-g857-hhfv-j68w Buffer Overflow in Zlib::GzipReader ungetc via large input leads to memory corruption
Ubuntu USN Ubuntu USN USN-8556-1 Ruby vulnerabilities
History
Type Values Removed Values Added
First Time appeared Ruby-lang
Ruby-lang zlib
CPEs cpe:2.3:a:ruby-lang:zlib:*:*:*:*:*:ruby:*:*
Vendors & Products Ruby-lang
Ruby-lang zlib
Metrics cvssV3_1

{'score': 5.6, 'vector': 'CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L'}

cvssV3_1

{'score': 9.8, 'vector': 'CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H'}

Type Values Removed Values Added
First Time appeared Ruby
Ruby zlib
Vendors & Products Ruby
Ruby zlib
Type Values Removed Values Added
References
Metrics threat_severity

None

cvssV3_1

{'score': 5.6, 'vector': 'CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L'}

threat_severity

Moderate

Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'yes', 'Exploitation': 'none', 'Technical Impact': 'partial'}, 'version': '2.0.3'}

Type Values Removed Values Added
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.
Title zlib: Buffer Overflow in Zlib::GzipReader ungetc via large input leads to memory corruption
Weaknesses CWE-120
CWE-131
References
Metrics cvssV4_0

{'score': 1.7, 'vector': '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'}

Weaknesses
  • CWE-120

    Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')

  • CWE-131

    Incorrect Calculation of Buffer Size

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Apr 16, 2026, 6:20 PM
Reserved
Feb 24, 2026, 2:32 AM
Status
Analyzed
Published
Apr 16, 2026, 6:16 PM
Modified
Oct 26, 2026, 9:10 PM
Severity
Moderate
Public date
Apr 16, 2026, 5:27 PM