Ruby2Shell: how one byte of "SS" became a pre-auth Rails risk


SaveAdd to Google
Ruby

Upcasing the German ß produces "SS" — two bytes where Ruby budgeted for one.

Analysis TORONTO, ON

On November 18, the Ruby core team shipped Ruby 4.0.10, 3.4.13 and 3.3.14 to fix seven memory-safety bugs in the interpreter's regular expression engine and its string case conversion. One of them, a one-byte heap overflow nicknamed "Ruby2Shell" (CVE-2026-132825), has drawn most of the attention because researchers say it is reachable without authentication in a default Rails application.

This analysis looks at how the bug works, why a single byte can matter, how web frameworks reach it, and where the real exposure is: often not in the Ruby you installed yourself, but in the copy bundled inside products like GitLab and Mastodon.

The seven flaws at a glance

Ruby's announcement groups the bugs into two families. Only one has a CVE so far; the others are tracked by GitHub Security Advisory (GHSA) IDs while CVEs are pending.

  • GHSA-34m4-m9fh-gqp5 / CVE-2026-132825 (Ruby2Shell): one-byte heap overflow in string case conversion (CWE-193, off-by-one).
  • GHSA-87fm-7w84-j2px: integer overflow in case conversion leading to a heap overflow. Hitting it requires a result larger than 4 GiB, which makes it impractical through most web requests.
  • GHSA-7x2q-68qv-6p8x: double free when compiling a regex that uses character-class intersection (&&).
  • GHSA-3p8q-wmhx-vm2w: integer overflow in the compiled pattern's size, causing a heap overflow during regex compilation.
  • GHSA-7whj-cfh7-xgm4: heap overflow in Regexp#to_s when converting a crafted compiled regex back to text.
  • GHSA-wpqw-5qxg-m68r: out-of-bounds read in case-insensitive matching; maintainers say proof-of-concept code achieves attacker-controlled memory corruption.
  • GHSA-pvgc-g7gj-pv6h: out-of-bounds read in case-insensitive backreference matching, which can leak memory or crash the process.

Four of the seven were credited to Stephan Lipp of Ada Logics and Anthropic; the others to researchers reporting through HackerOne and to Hiroya Fujinami and Hiroshi SHIBATA.

The regex bugs are serious, but most of them need an application that compiles or matches attacker-supplied patterns, such as a search feature that passes user input to Regexp.new. Ruby2Shell is different: it needs only attacker-supplied text that the application changes the case of.

How Ruby2Shell works

The bug comes down to the German letter ß (sharp s). In Unicode, upcasing ß produces two characters, "SS". Most of Ruby's single-byte encodings, such as ISO-8859-1 and Windows-1252, have no capital ß, so Ruby's case-mapping code writes "SS" in its place: two output bytes for one input byte.

According to Veria Labs, which published the Ruby2Shell write-up, the output buffer is allocated at the input length plus 20 bytes of slack. Each ß grows the output by one byte, so 20 of them fit exactly. The 21st pushes the second "S" one byte past the end of the heap buffer. The loop's bounds check (to < to_end) only confirms room for one byte before writing two.

Several properties shape what an attacker can do with this:

  • The overflow is exactly one byte, and its value is fixed: S (0x53) when upcasing, or s (0x73) when case-folding. The attacker does not choose the byte.
  • The attacker controls the buffer size through the input length, which lets them influence what sits next to the buffer on the heap.
  • Copying the result out also reads one byte out of bounds.
  • The reachable methods named by Veria Labs are upcase, swapcase, downcase(:fold) and casecmp?, on strings in an affected single-byte encoding. UTF-8 strings take a different code path and are not affected.
  • The loop has existed since Ruby 2.4.0, so every release back to 2.4 is vulnerable. Ruby 3.2 and earlier are end-of-life and will not be fixed.

A fixed-value, single-byte overflow sounds limited, but off-by-one heap writes are a well-established exploitation primitive. Corrupting one byte of a neighbouring object or allocator structure can be enough to set up a larger, attacker-controlled corruption. Red Hat's bulletin describes code execution as possible "with careful heap layout manipulation."

Why Rails is exposed by default

A bug in a string method only matters if untrusted input reaches it. Veria Labs reports that Rails and classic-style Sinatra both reach the vulnerable code in their default configurations, without authentication; other frameworks and plain Rack are not exposed by default. Moritz Sanft, who found the bug independently, traces the path through Rack: during its normal handling of a crafted form submission, Rack changes the case of a request field, so a brand-new rails new application reaches the overflow before any of its own code runs.

Neither Veria Labs nor Sanft has published the exact field or request shape, which is deliberate. Applications outside those frameworks can still be vulnerable if their own code changes the case of text received in a legacy encoding, for example input converted with force_encoding or encode to ISO-8859-1 or Windows-1252.

How serious is it, really?

Assessments differ. Ruby rates the bug Critical and says proof-of-concept exploits achieve remote code execution "in some scenarios." Veria Labs and Sanft both say they achieved code execution against stock Rails. The CVE record published by MITRE scores it 7.4 (High) under CVSS 3.1. OX Security has gone further, calling Ruby2Shell more marketing than actual risk because turning the primitive into reliable code execution depends on heap layout and application behaviour.

Both views can be true at once. A reliable, generic exploit is hard, but a crash is easy: even without code execution, a crafted request can bring down a Ruby worker, which makes denial of service a realistic outcome for any exposed, unpatched app.

As of the latest reports, no exploitation in the wild has been confirmed and the flaw was not in CISA's Known Exploited Vulnerabilities catalog. Veria Labs had scheduled public release of its Rails proof of concept for November 25, "or later if major vendors have not shipped a fix by then." Organizations should assume working exploit code is public or close to it.

The bundled-Ruby problem

Many self-hosted products ship their own Ruby runtime, so upgrading the system Ruby does nothing for them. Veria Labs lists vendor fixes for:

  • GitLab: 19.6.1, 19.5.8 and 19.4.10 (affected: 19.6.0 and earlier)
  • GitHub Enterprise Server: 3.22.6, 3.21.11, 3.20.13 and 3.19.17
  • Mastodon: 4.7.6, 4.6.12, 4.5.22 and 4.4.29
  • Discourse: base image 2.0.20261119-0203
  • Chatwoot: 4.20.1
  • OpenProject: 17.9.8 and 17.8.3

Self-managed GitLab and Mastodon are common in Canada, from university and government development teams to community-run Mastodon instances, and they are often the most internet-exposed Ruby applications an organization runs.

What to do

1. Find every Ruby runtime. Check the system Ruby, version managers (rbenv, rvm, asdf), container base images and bundled runtimes. ruby -v on the host is not enough: run it inside each container, and check vendor paths such as GitLab's embedded Ruby.

2. Upgrade the interpreter, not just gems. Move to Ruby 4.0.10, 3.4.13 or 3.3.14. Updating Rails or other gems does not fix the interpreter. Rebuild container images and restart every Ruby process, including background workers like Sidekiq.

3. Patch bundled products. Install the vendor releases listed above for GitLab, GitHub Enterprise Server, Mastodon, Discourse, Chatwoot and OpenProject.

4. Get off end-of-life Ruby. Ruby 3.2 and earlier will not be fixed. Ruby 3.3 is in security maintenance until the end of March 2027.

5. Review your own code. Look for case conversion on input in legacy single-byte encodings, and for regular expressions built from user input. Use Regexp.escape where user text must go into a pattern, and avoid compiling user-supplied patterns at all where possible.

6. Watch for crashes. Unexplained segmentation faults or worker restarts in Ruby processes can indicate probing. Ruby has published no other workaround, so patching is the only complete fix.

The vulnerability in this story

  1. 7.4 High CVE-2026-132825 (cve.org, opens in a new tab)

    Ruby before 3.3.14, 3.4.13, and 4.0.10 has a heap-based buffer overflow during case conversion.

    Published Nov 19, 2026

Scores and dates: NVD (not endorsed by the NVD). Each ID opens its record on cve.org.

About the author

Editor's Picks

The best of cybersecuritynews.ca, delivered to you weekly.

On Display
Geoserver

How two exploited GeoServer bugs chain into a full server takeover

Pacific Blue Cross

Pacific Blue Cross cyber incident halts claims for B.C. members

Java4Shell: patched Java, still exposed? Check the bundled runtime