CVE-2026-27820: Buffer Overflow in Zlib :GzipReader Ungetc Vulnerability

MODERATE
Advisory Identifier: GHSA-g857-hhfv-j68w
CVSS 9.8
CWE-120
Published
Advisory Summary

CVE-2026-27820 is a MODERATE (CVSS 9.8) :gzipreader ungetc vulnerability (CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')) affecting Buffer Overflow in Zlib libraries in the RubyGems ecosystem. The issue involves :gzipreader ungetc via large input leads to memory corruption. Remediation is available by upgrading affected packages to version 3.2.3, 3.1.2, 3.0.1.

CVE-2026-27820 at a Glance

CVE Identifier CVE-2026-27820
GHSA Identifier GHSA-g857-hhfv-j68w
Severity MODERATE
CVSS v3.1 Base Score 9.8
CWE Classification CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow')
Affected Product Buffer Overflow in Zlib
Package Ecosystem RubyGems
Published Date
Last Updated

Security Impact

CVSS: 9.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-27820

To remediate this vulnerability, upgrade all affected Buffer Overflow in Zlib dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

zlib fixed: 3.2.3
Upgrade zlib to 3.2.3
zlib fixed: 3.1.2
Upgrade zlib to 3.1.2
zlib fixed: 3.0.1
Upgrade zlib to 3.0.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for zlib

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-27820, inspect your project dependencies for Buffer Overflow in Zlib:

inspect dependencies for zlib

Analyze the terminal output to locate any version of Buffer Overflow in Zlib in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.2.3), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow'), where the product copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer. In Buffer Overflow in Zlib, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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](https://hackerone.com/calysteon) ### References * https://hackerone.com/reports/3467067

CVE-2026-27820 Affected Buffer Overflow in Zlib Versions

3 component(s)
Fixed Versions:
3.2.33.1.23.0.1
Product / Package Ecosystem Affected Versions Fixed Version
zlib
RubyGems
≥ 3.2.0
< 3.2.3
3.2.3
zlib
RubyGems
≥ 3.1.0
< 3.1.2
3.1.2
zlib
RubyGems
< 3.0.1
3.0.1

References

Frequently Asked Questions

What is CVE-2026-27820?
CVE-2026-27820 is a security vulnerability in Buffer Overflow in Zlib involving :GzipReader ungetc via large input leads to memory corruption under CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow').
Which Buffer Overflow in Zlib versions are affected?
Affected versions include releases prior to 3.2.3, 3.1.2, 3.0.1 across affected packages: zlib.
What version fixes CVE-2026-27820?
Upgrading to 3.2.3, 3.1.2, 3.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is zlib affected?
Yes, zlib is affected in releases prior to 3.2.3, 3.1.2, 3.0.1. Upgrade your dependency to 3.2.3, 3.1.2, 3.0.1 or later.
What is the CVSS score of CVE-2026-27820?
CVE-2026-27820 has a CVSS v3.1 base score of 9.8 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-27820?
CVE-2026-27820 is classified under CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') (The product copies an input buffer to an output buffer without verifying that the size of the input buffer is less than the size of the output buffer.).
How can I check RubyGems dependencies for CVE-2026-27820?
Run the dependency tree command: 'inspect dependencies for zlib'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-g857-hhfv-j68w",
  "modified" : "2026-06-10T13:40:46Z",
  "published" : "2026-04-16T20:40:54Z",
  "aliases" : [ "CVE-2026-27820" ],
  "summary" : "Buffer Overflow in Zlib::GzipReader ungetc via large input leads to memory corruption",
  "details" : "### Details\n\nA buffer overflow vulnerability exists in `Zlib::GzipReader`.\n\nThe `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.\n\n### Recommended action\n\nWe 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:\n\n* For Ruby 3.2 users: Update to zlib 3.0.1\n* For Ruby 3.3 users: Update to zlib 3.1.2\n\nYou can use gem update zlib to update it. If you are using bundler, please add `gem \"zlib\", \">= 3.2.3\"` to your Gemfile.\n\n### Affected versions\n\nzlib gem 3.2.2 or lower\n\n### Credits\n\n[calysteon](https://hackerone.com/calysteon)\n\n### References\n\n* https://hackerone.com/reports/3467067",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "zlib"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.2.0"
      }, {
        "fixed" : "3.2.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "zlib"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "3.1.0"
      }, {
        "fixed" : "3.1.2"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "RubyGems",
      "name" : "zlib"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/ruby/zlib/security/advisories/GHSA-g857-hhfv-j68w"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-27820"
  }, {
    "type" : "WEB",
    "url" : "https://hackerone.com/reports/3467067"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/ruby/zlib"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/rubysec/ruby-advisory-db/blob/master/gems/zlib/CVE-2026-27820.yml"
  }, {
    "type" : "WEB",
    "url" : "https://www.ruby-lang.org/en/news/2026/03/05/buffer-overflow-zlib-cve-2026-27820"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-120" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-04-16T20:40:54Z",
    "nvd_published_at" : "2026-04-16T18:16:44Z"
  }
}