# CVE-2026-27820: Ruby zlib buffer overflow in Zlib::GzipReader

Source: https://junglewise.ai/threats/cve-2026-27820-ruby-zlib-buffer-overflow-in-zlib-gzipreader  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-16. Updated: 2026-06-09  
License: CC BY 4.0 with a link back

CVE-2026-27820 · Severity: critical · CVSS 9.8 · Published 2026-04-16

A security vulnerability has been identified in the Ruby zlib library, which is used by applications to compress and decompress data. An attacker could provide specially crafted input that causes the application to crash or potentially allow for unauthorized access to data. This could lead to service outages or the exposure of sensitive information handled by the application.

Technologies: [zlib (RubyGems)](https://junglewise.ai/threats/technologies/zlib). Vendors: [RubyGems](https://junglewise.ai/threats/vendors/rubygems).

## Quick answers

**Is CVE-2026-27820 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-27820 being exploited in the wild.

**How severe is CVE-2026-27820?** Critical severity, with a CVSS score of 9.8, published 16 April 2026.

**Which products and versions are affected?** zlib (RubyGems) ECOSYSTEM:introduced=3.2.0,fixed=3.2.3.

**Is there a fix for CVE-2026-27820?** Yes. zlib (RubyGems): upgrade to 3.2.3 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-27820 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-27820?** Check whether you run zlib (RubyGems) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- zlib (RubyGems): upgrade to 3.2.3 or later

  ```sh
  bundle update zlib
  ```


## Technical details

A classic buffer overflow (CWE-120) exists in the `zstream_buffer_ungets` function within `Zlib::GzipReader`. The vulnerability occurs because the function prepends caller-provided bytes to previously produced output without verifying that the underlying Ruby string buffer has sufficient capacity. When the buffer length exceeds its capacity during a `memmove` operation, memory corruption occurs. This can be triggered by providing large inputs to the `ungetc` method. The flaw allows for potential remote code execution or denial of service. Patches are available in versions 3.0.1, 3.1.2, and 3.2.3.

## Affected products

- Ruby zlib < 3.0.1, >= 3.1.0, < 3.1.2, >= 3.2.0, < 3.2.3

## Identifiers

- CVE-2026-27820
- GHSA-g857-hhfv-j68w

## Timeline

- 2026-03-05: disclosed: Initial publication by Ruby-lang
- 2026-04-16: advisory: GitHub and NVD advisory published

## References

- [https://github.com/ruby/zlib/security/advisories/GHSA-g857-hhfv-j68w](https://github.com/ruby/zlib/security/advisories/GHSA-g857-hhfv-j68w)
- [https://hackerone.com/reports/3467067](https://hackerone.com/reports/3467067)
- [https://github.com/rubysec/ruby-advisory-db/blob/master/gems/zlib/CVE-2026-27820.yml](https://github.com/rubysec/ruby-advisory-db/blob/master/gems/zlib/CVE-2026-27820.yml)
- [https://www.ruby-lang.org/en/news/2026/03/05/buffer-overflow-zlib-cve-2026-27820](https://www.ruby-lang.org/en/news/2026/03/05/buffer-overflow-zlib-cve-2026-27820)
- [https://api.github.com/repos/ruby/zlib/security-advisories/GHSA-g857-hhfv-j68w](https://api.github.com/repos/ruby/zlib/security-advisories/GHSA-g857-hhfv-j68w)
