Security

Ruby2Shell: Critical Heap Overflow in Ruby Puts Rails and Sinatra Apps at Risk Until Patched

Ruby 3.3.14, 3.4.13 and 4.0.10 fix a critical one-byte heap overflow in string case conversion that researchers say default Rails and Sinatra apps can reach without login.

Key facts: Fixed Ruby 4.0 release (3.4.13 and 3.3.14 for older lines), 4.0.10; Byte written past the end of the buffer, 1; Total memory-safety flaws fixed in the release, per CyberSecurityNews, 7; Oldest Ruby version with the vulnerable code, per Orca Security, 2.4.0; Planned public proof-of-concept, after disclosure, ~1 week.

Ruby’s maintainers have shipped emergency releases for a critical memory-safety bug nicknamed “Ruby2Shell”. The flaw sits in the interpreter itself, not in a library, so updating Rails or other gems does not fix it. Teams running Ruby web applications need to upgrade the runtime and restart their processes.

A note on method: the technical facts come from the Ruby project’s own GitHub security advisory, which is our primary source, cross-checked against reporting and analysis from Orca Security, Astra Security, Equixly and CyberSecurityNews, all opened in full. Opinions are labelled as the Wandertech team’s.

What happened

The Ruby core team published an advisory titled “Heap buffer overflow in case conversion of strings” on 19 November 2026 and rated it Critical. The patched releases, Ruby 3.3.14, 3.4.13 and 4.0.10, were released a day earlier, on 18 November, according to Orca Security and Equixly.

According to the advisory, changing the case of a specially crafted string can write one byte past the end of the output buffer. This happens with some single-byte encodings such as ISO-8859-1 and Windows-1252. The maintainers say this may allow remote code execution and that they know of proof-of-concept exploits that achieve it in some scenarios. They credit Stephan Lipp of Ada Logics and Anthropic.

The advisory’s weakness class is an off-by-one error. As of the advisory page, no CVE identifier had been assigned and one was “pending”. Some security vendors have already used a CVE-style number in their headlines, but we could not confirm it against the advisory, so we do not use it here.

Who is affected

Affected versions, per the advisory, are Ruby 3.3.13 and earlier, 3.4.0 through 3.4.12, and 4.0.0 through 4.0.9. Orca and Astra add that Ruby 3.2 and older are end of life and will receive no fix, and that the vulnerable code dates back to Ruby 2.4.0.

Researchers describe the bug as reachable through upcase, swapcase, downcase(:fold) and casecmp?. UTF-8 strings take a different code path and are not affected. Equixly’s analysis adds that the output buffer has some slack, so an attacker needs a fairly long input made of a specific character before the overflow occurs.

The part that worries operators is exposure. According to Veria Labs, as relayed by Astra and Equixly, default Rails and classic-style Sinatra applications can reach the bug over the network without authentication. Equixly and Astra say other frameworks and plain Rack are not exposed by default, though application code that changes the case of legacy-encoded input could still be vulnerable.

Self-hosted products that bundle Ruby are also in scope. Orca names GitLab, GitHub Enterprise Server, Mastodon, Discourse, OpenProject and Chatwoot. Astra and Equixly list specific versions that shipped an affected Ruby at the time of writing, and each product needs its own vendor update.

Seven bugs, not one

CyberSecurityNews reports that the same release fixes seven memory-safety flaws in Ruby’s regular-expression engine and case-conversion code, and that the Ruby team knows of proofs of concept showing code execution for five of them, including this one. The others include a double free during regex compilation and out-of-bounds reads in case-insensitive matching. That outlet notes the maintainers identify them by GitHub advisory IDs, because CVE numbers had not yet been issued.

Background

Ruby on Rails powers a large share of long-lived web back ends, internal tools and developer platforms, and Ruby also sits inside tools many teams run on their own servers. A bug in the interpreter is a different kind of problem from a bug in one gem: it affects every application on the same runtime, whatever its dependencies.

Equixly’s timeline shows that the previous point releases, Ruby 4.0.9, 3.4.12 and 3.3.13, came out on 23 October and fixed other regex-engine issues but not this one.

Why it matters

For operators. There is no official workaround, per Orca and Astra. The fix is to move to a patched Ruby, rebuild container images on a fixed base, and fully restart every application process. Equixly warns that some phased-restart setups keep running the old binary, so verify the running version rather than assuming. Linux distributions may backport the fix without changing the version number, so check your distribution’s advisory.

Timing. Veria Labs plans to publish its proof of concept about a week after disclosure, according to Orca and Astra. No in-the-wild exploitation had been reported as of the sources we read. Public exploit code usually shortens the time between a patch and attacks, so the practical window is days, not weeks.

The Wandertech angle (our opinion). For software teams the lesson is about visibility. Many organisations know which gems they depend on but not which interpreter build each service and container is actually running. Keep a current inventory of runtime versions, put base images on a regular rebuild schedule, and treat interpreter patches as first-class security updates. Teams still on Ruby 3.2 or older should read this as a deadline to migrate, since no patch will arrive for them.

Different perspectives and risks

The exploitability claims come mostly from the researchers and the Ruby team, not from independent reproduction. Equixly states it has not reproduced remote code execution itself. Exposure also depends on how an application handles input encodings, so some deployments will be safer than the headline suggests, while others may be exposed through custom code. Interim measures suggested by security vendors, such as restricting internet access to self-hosted tools, are stopgaps and are not endorsed by the Ruby project.

What to watch next

Watch for a CVE assignment and a severity score, vendor releases for GitLab, GitHub Enterprise Server, Mastodon, Discourse and others, Linux distribution backports, and the public proof of concept expected in roughly a week.

Conclusion

Ruby2Shell is a reminder that a one-byte mistake in a language runtime can matter as much as a flaw in a web framework. The facts are clear enough to act on now: upgrade to 3.3.14, 3.4.13 or 4.0.10, restart everything, and check your bundled products.

Sources