{"id":"CVE-2026-27820","aliases":["CVE-2026-27820","GHSA-g857-hhfv-j68w"],"related":[],"kind":"vulnerability","state":"published","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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### 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","format":"markdown","source":"ghsa"},{"lang":"es","text":"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.","source":"nvd"}],"published":"2026-04-16T17:27:48.944Z","modified":"2026-10-26T21:10:00.170Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","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","score":1.7,"rating":"LOW"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","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","score":1.7,"rating":"LOW"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H","score":9.8,"rating":"CRITICAL"}],"cwes":["CWE-120","CWE-131"],"affected":[{"ranges":[{"version":"< 3.0.1","status":"affected"},{"version":">= 3.1.0, < 3.1.2","status":"affected"},{"version":">= 3.2.0, < 3.2.3","status":"affected"}],"vendor":"ruby","product":"zlib","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"3.2.0","status":"affected","fixed":"3.2.3"}],"ecosystem":"RubyGems","package":"zlib","purl":"pkg:gem/zlib","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"3.1.0","status":"affected","fixed":"3.1.2"}],"ecosystem":"RubyGems","package":"zlib","purl":"pkg:gem/zlib","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"3.0.1"}],"ecosystem":"RubyGems","package":"zlib","purl":"pkg:gem/zlib","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"3.0.1"},{"status":"affected","introduced":"3.1.0","fixed":"3.1.2"},{"status":"affected","introduced":"3.2.0","fixed":"3.2.3"}],"vendor":"ruby-lang","product":"zlib","cpe":"cpe:2.3:a:ruby-lang:zlib:*:*:*:*:*:ruby:*:*","source":"nvd"}],"references":[{"url":"https://github.com/ruby/zlib/security/advisories/GHSA-g857-hhfv-j68w","tags":["vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://hackerone.com/reports/3467067","tags":["permissions-required","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-27820","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/ruby/zlib","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/rubysec/ruby-advisory-db/blob/master/gems/zlib/CVE-2026-27820.yml","tags":["web"],"sources":["ghsa"]},{"url":"https://www.ruby-lang.org/en/news/2026/03/05/buffer-overflow-zlib-cve-2026-27820","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-04-16T18:20:13.051Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-27820","url":"https://www.cve.org/CVERecord?id=CVE-2026-27820","licence":"CVE Terms of Use","modified":"2026-04-16T18:20:21.451Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-g857-hhfv-j68w","url":"https://github.com/advisories/GHSA-g857-hhfv-j68w","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:44.477Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-27820","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-27820","licence":"Public domain","modified":"2026-10-26T21:10:00.170Z"}],"updatedAt":"2026-11-25T22:59:18.910Z","epss":{"score":0.00583,"percentile":0.49222,"date":"2026-12-01T12:00:22.000Z"}}