CVE-2026-27820: Buffer Overflow in Zlib :GzipReader Ungetc Vulnerability
MODERATECVE-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
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).
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.
Upgrade zlib to 3.2.3
Upgrade zlib to 3.1.2
Upgrade zlib to 3.0.1
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
CVE-2026-27820 Affected Buffer Overflow in Zlib Versions
3 component(s)References
Frequently Asked Questions
What is CVE-2026-27820?
Which Buffer Overflow in Zlib versions are affected?
What version fixes CVE-2026-27820?
Is zlib affected?
What is the CVSS score of CVE-2026-27820?
What CWE is associated with CVE-2026-27820?
How can I check RubyGems dependencies for CVE-2026-27820?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"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"
}
}