Ruby2Shell: A One-Byte Overflow to RCE

Ruby2Shell: A One-Byte Overflow to RCE


Ruby has become the latest programming language to attract serious security attention with the disclosure of Ruby2Shell, a heap-based buffer overflow vulnerability that could potentially allow remote code execution in vulnerable environments.

Disclosed on November 19, 2026, the vulnerability affects Ruby’s string case-conversion functionality. What makes this particularly interesting is that a seemingly ordinary operation, such as converting a string to uppercase, can become an entry point for memory corruption.

What happened?

The vulnerability originates in how Ruby handles string case conversion when processing certain non-UTF-8 character encodings.

For example, the German character ß expands into SS when converted to uppercase. Under specific encoding conditions, Ruby incorrectly calculates the required output buffer size. This can result in a one-byte heap buffer overflow, allowing an attacker to overwrite adjacent memory.

Depending on the application and memory layout, the consequences can include application crashes, memory corruption and potentially arbitrary code execution.

The vulnerability is tracked as CVE-2026-132825 and is also known as Ruby2Shell.

Why is this concerning?

The exposure is not necessarily limited to applications explicitly performing string conversion within their business logic.

Ruby on Rails and classic-style Sinatra applications use Rack middleware that can process HTTP method-override requests. This creates a potential path to the vulnerable functionality before an application’s authentication controls are reached.

An attacker could craft a specially constructed multipart HTTP request containing maliciously encoded input to trigger the vulnerable operation.

This makes internet-facing Ruby applications particularly important to investigate.

However, exploitation depends on the affected runtime, the request-processing path and the encoding of attacker-controlled input. It should not be assumed that every Ruby deployment is equally exposed.

What is affected?

The vulnerable Ruby releases include:

  • Ruby 3.3.13 and earlier.
  • Ruby 3.4.0 through 3.4.12.
  • Ruby 4.0.0 through 4.0.9.

The Ruby maintainers have released security fixes in:

  • Ruby 3.3.14
  • Ruby 3.4.13
  • Ruby 4.0.10

Ruby 3.2 and earlier are end-of-life versions and do not receive upstream security fixes.

The concern also extends to self-hosted platforms that bundle their own Ruby runtime. GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse and Chatwoot have been highlighted in security research. Organisations should verify the precise product release and bundled runtime rather than assuming that every deployment is affected.

What should security teams do?

This is not a vulnerability that should be addressed by checking only the operating system’s installed Ruby package.

Security teams should identify every Ruby runtime across application servers, containers, CI/CD environments and self-hosted platforms.

Prioritise internet-facing Rails and classic-style Sinatra deployments, verify whether vulnerable middleware paths are reachable, and upgrade to the appropriate patched Ruby release.

Where applications cannot be upgraded immediately, restrict exposure to trusted networks and avoid processing untrusted input in affected legacy encodings.

Input normalisation to UTF-8 can reduce exposure in specific scenarios, but it is not a replacement for applying the security update.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.