zlib: Buffer Overflow in Zlib::GzipReader ungetc via large input leads to memory corruption
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.
- Products
- Not specified
- Affected versions
- Not specified
- Fixed versions
- Not specified
- CVEs
- CVE-2026-27820
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 3 Nov 2026, 13:51 UTC · Revision 1
Source evidence
zlib: Buffer Overflow in Zlib::GzipReader ungetc via large input leads to memory corruption
core-osv · Original sourcePublished 16 Apr 2026, 17:27 UTC
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.
osv:CVE-2026-27820
Complete source record
{
"id": "c46e76977f7d300c35777004b98a483a656ace146714897ab2b476e77fe323cf",
"url": "https://osv.dev/vulnerability/CVE-2026-27820",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "zlib: Buffer Overflow in Zlib::GzipReader ungetc via large input leads to memory corruption",
"summary": "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.",
"evidence": "osv:CVE-2026-27820",
"products": [],
"severity": "low",
"structured": {
"id": "CVE-2026-27820",
"aliases": [
"CVE-2026-27820",
"GHSA-g857-hhfv-j68w"
],
"metrics": [
{
"type": "CVSS_V4",
"score": "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"
}
],
"affected": [
{
"ranges": [
{
"repo": "https://github.com/ruby/zlib",
"type": "GIT",
"events": [
{
"introduced": "0"
},
{
"fixed": "2ce25b3cd8722250fd650c49bef96f8ce862aaf5"
},
{
"introduced": "2561e122aca1241f95aa8a337938fc00f13db14a"
},
{
"fixed": "c247f56b4f8e6a536770f4c8326a49f1b85bf667"
},
{
"introduced": "7bb6d982fe657359a36556c80b94a23d5cec1aa3"
},
{
"fixed": "899f9fdb801062a3f2714b242f57477aabeca644"
}
],
"database_specific": {
"extracted_events": [
{
"cpe": "cpe:2.3:a:ruby-lang:zlib:*:*:*:*:*:ruby:*:*",
"range": [
{
"introduced": "0"
},
{
"fixed": "3.0.1"
}
],
"source": "CPE_RANGE"
},
{
"cpe": "cpe:2.3:a:ruby-lang:zlib:*:*:*:*:*:ruby:*:*",
"range": [
{
"introduced": "3.1.0"
},
{
"fixed": "3.1.2"
}
],
"source": "CPE_RANGE"
},
{
"cpe": "cpe:2.3:a:ruby-lang:zlib:*:*:*:*:*:ruby:*:*",
"range": [
{
"introduced": "3.2.0"
},
{
"fixed": "3.2.3"
}
],
"source": "CPE_RANGE"
}
]
}
}
],
"versions": [
"v3.0.0",
"v3.2.2",
"v3.1.1",
"v3.2.1",
"v3.2.0",
"v3.1.0",
"v2.1.1",
"v2.1.0",
"v1.1.0",
"v1.0.0",
"v0.1.0",
"v0.0.1"
],
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2026-27820.json"
}
}
],
"modified": "2026-10-28T02:30:29.579513290Z",
"provider": "osv",
"references": [
"https://hackerone.com/reports/3467067",
"https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/27xxx/CVE-2026-27820.json",
"https://github.com/ruby/zlib/security/advisories/GHSA-g857-hhfv-j68w",
"https://nvd.nist.gov/vuln/detail/CVE-2026-27820"
],
"provider_metadata": {
"cwe_ids": [
"CWE-120",
"CWE-131"
],
"cna_assigner": "GitHub_M",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2026/27xxx/CVE-2026-27820.json"
}
},
"related_cves": [
{
"value": "CVE-2026-27820",
"evidence": "/id"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 496092,
"published_at": "2026-04-16T17:27:48.944+00:00"
}