CVE-2026-34831: Rack incorrect Content-Length calculation in Rack::Files error responses

CVE-2026-34831 · Severity: medium · CVSS 4.8 · Published 2026-04-02

Rack is a widely used interface for Ruby web applications that helps manage communication between web servers and application code. A flaw in how it handles error messages for missing files can cause the server to report an incorrect data size to the web browser or proxy. This mismatch can lead to 'response desynchronization,' potentially allowing an attacker to interfere with web traffic or bypass certain security filters in complex network environments.

Technologies: rack (RubyGems). Vendors: RubyGems.

Quick answers

Is CVE-2026-34831 exploited in the wild?
No. Junglewise Threat Intelligence has no report of CVE-2026-34831 being exploited in the wild.
How severe is CVE-2026-34831?
Medium severity, with a CVSS score of 4.8, published 2 April 2026.
Which products and versions are affected?
rack (RubyGems) ECOSYSTEM:introduced=0,fixed=2.2.23.
Is there a fix for CVE-2026-34831?
Yes. rack (RubyGems): upgrade to 2.2.23 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.
How is CVE-2026-34831 attacked?
It is attacked over the network, in a software library.
Am I affected by CVE-2026-34831?
Check whether you run rack (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

  • rack (RubyGems): upgrade to 2.2.23 or later
    bundle update rack

Technical details

A vulnerability exists in Rack::Files#fail where the Content-Length header is calculated using String#size (character count) instead of String#bytesize (byte count). When a 404 error occurs, Rack reflects the requested path in the response body; if that path contains percent-encoded multibyte UTF-8 characters, the actual byte size of the body will exceed the declared Content-Length. This discrepancy violates HTTP framing standards. An attacker can exploit this by requesting non-existent paths with specific UTF-8 characters to trigger response desynchronization or request smuggling in environments with intermediaries (proxies/load balancers) that rely on the Content-Length header for message delimitation. The issue is patched in versions 2.2.23, 3.1.21, and 3.2.6.

Affected products

  • Rack Rack < 2.2.23, >= 3.0.0.beta1 < 3.1.21, >= 3.2.0 < 3.2.6

Identifiers

  • CVE-2026-34831
  • GHSA-q2ww-5357-x388

Timeline

  • 2026-04-01: advisory: GitHub Security Advisory published
  • 2026-04-02: disclosed: CVE published to NVD
  • 2026-04-02: patched: Patched versions released

References

This page as Markdown. Free to reuse under CC BY 4.0 with a link back.