Ruby2Shell, tracked as GHSA-34m4-m9fh-gqp5, is a one-byte heap buffer overflow in the code Ruby uses to change the case of strings in several legacy single-byte encodings. According to the write-up from Veria Labs, which named the flaw, an unauthenticated attacker can reach it over the network in Rails and classic-style Sinatra applications running their default configuration, and turn it into remote code execution. The bug has been in Ruby since 2.4.0. The Ruby team fixed it on November 18, 2026, in Ruby 4.0.10, 3.4.13, and 3.3.14, together with six other flaws in the regular expression engine and in case conversion.
The Ruby advisory says the team is “aware of PoCs that prove this flaw can be used to trigger RCE in some scenarios.” No CVE has been assigned yet, and we found no reports of exploitation in the wild as of November 19. Veria Labs has not said which Rails code path reaches the bug and plans to publish its proof of concept about a week after disclosure, so defenders have a short window before the exploit details are public.
The fix is in the Ruby interpreter, so updating Rails or any other gem does nothing for this flaw. Every Ruby runtime that serves web requests, including the copies bundled inside GitLab, GitHub Enterprise Server, Mastodon, and other self-hosted products, needs the new release.
Updates
- November 20, 2026: Equixly’s Ruby2Shell check is now live.
Vulnerability details
TL;DR
- Every Ruby release from 2.4.0 until the fixed 4.0.10, 3.4.13, and 3.3.14 can write one byte past a heap buffer when it upcases a string full of the German letter ß in a legacy single-byte encoding. Veria Labs reports remote code execution without authentication against Rails and classic-style Sinatra in their default configuration.
- UTF-8 strings take a different code path and are not affected, and frameworks other than Rails and classic-style Sinatra, including plain Rack, do not expose the bug by default.
- Upgrade the Ruby runtime to 4.0.10, 3.4.13, or 3.3.14, then restart every Ruby process. A Rails or gem update does not fix it.
- Self-hosted products bundle their own Ruby. Veria Labs lists the latest releases of GitLab, GitHub Enterprise Server, Mastodon, OpenProject, Discourse, and Chatwoot as affected, so each needs a vendor update.
- Ruby 3.2 and older will stay vulnerable. Move those applications to a supported branch or isolate them.
Who is not affected by Ruby2Shell
Applications that only change the case of UTF-8 strings cannot reach this flaw, because Ruby handles UTF-8 in a separate routine. According to Veria Labs, the following are also out of scope by default:
- Ruby web applications built on frameworks other than Rails and classic-style Sinatra, and applications written directly on Rack, unless their own code upcases text received in a legacy encoding.
- Processes already running Ruby 4.0.10, 3.4.13, or 3.3.14.
The Veria Labs write-up does not list the affected encodings by name, but the upstream fix names 14: ISO-8859-1, ISO-8859-2, ISO-8859-3, ISO-8859-4, ISO-8859-9, ISO-8859-10, ISO-8859-13, ISO-8859-14, ISO-8859-15, ISO-8859-16, Windows-1250, Windows-1252, Windows-1254, and Windows-1257. Other single-byte encodings, such as ISO-8859-5 (Cyrillic), have no ß and do not reach the bug.
What is Ruby2Shell?
Ruby2Shell is a bounds-checking mistake in the loop Ruby runs when it converts the case of a string in some single-byte encodings. These encodings have a lowercase sharp s (ß) but no uppercase form, so Ruby writes it as two letters, SS, when upcasing. The loop checks that the output buffer has room for one more byte before each step, then writes two bytes whenever it meets a ß.
Ruby sizes the output buffer at the length of the input plus 20 bytes. Each ß adds one byte to the output, so the overflow needs at least 21 of them: a ß that arrives with exactly one byte of room left writes its second byte past the end of the buffer. A string of exactly 21 ß characters does this, which is the example Veria Labs gives. Veria Labs traces the loop to Ruby 2.4.0 and reports that upcase, swapcase, downcase(:fold), and casecmp? all reach it.
The Ruby advisory groups this flaw with six others fixed in the same releases. Two concern case conversion and five concern Onigmo, the regular expression engine built into Ruby:
Ruby2Shell and GHSA-87fm-7w84-j2px stand out because they need only crafted text. Ruby2Shell is also the one Veria Labs reports reachable in default Rails and Sinatra. Four of the five regular expression flaws require the application to compile or run a pattern the attacker supplies, which most applications never do.
Technical analysis
The flaw gives an attacker a single byte written directly after a heap buffer whose size the attacker chooses. The analysis below follows the Veria Labs write-up and the upstream fix. We have not reproduced it in a lab.
The loop
The case-mapping loop for the affected encodings continues while input remains and while the output pointer is below the end of the buffer. When it reads a ß and the upcase flag is set, it writes S, then falls through to the common write at the bottom of the loop, which writes a second S without checking the bound again. The check at the top of the loop guarantees room for one byte, and the ß branch uses two.
The arithmetic
On our reading of the loop, the attacker controls that alignment through where the ß characters sit in the input, and the overflow stays at one byte however many ß characters follow, because the bound check at the top of the loop stops the next iteration once the output pointer has passed the end. A string of 22 ß characters, for example, fills the buffer exactly and does not overflow. The upstream fix tests both alignments: a run of ß characters on its own, and the same run after one ASCII letter.
What gets written
The stray byte is always S (0x53) when upcasing and s (0x73) when case folding, so the attacker controls where it lands but not what it is. The attacker sets the buffer size through the length of the input, which can influence which object sits next to the buffer on the heap. Copying the result out of the buffer then reads one byte past its end as well.
Veria Labs reports that this primitive leads to code execution. It has not published the exploitation steps, and the Ruby advisory confirms only that proofs of concept for RCE exist “in some scenarios.”
Which products are affected?
Ruby branches and self-hosted products listed by Veria Labs, as of its update at 09:29 UTC on November 19, 2026:
The Ruby version a product bundles is not always the code it runs. In October, GitLab fixed the Onigmo bugs behind four of its CVEs by patching the Ruby it ships before the Ruby releases existed. Rely on each vendor’s advisory, not on the bundled version number, to decide whether a product is fixed.
What is the impact of Ruby2Shell?
The worst case is code execution as the user that runs the Ruby application server, such as a Puma or Unicorn worker. In a Rails application, that process can usually read the decrypted application credentials, the database password, and the secret_key_base used to sign sessions and cookies, along with any API tokens for downstream services.
Veria Labs has not published which input Rails passes to an affected method by default, and its proof of concept is not public. Until it is, the safe reading of its table is that any Rails or classic-style Sinatra application on an affected Ruby can be attacked by anyone who can send it an HTTP request. Authentication does not narrow that, because Veria Labs reports the flaw as reachable before login.
Two further consequences follow from the type of bug:
- A failed exploitation attempt may corrupt an object the process still uses and crash the worker. Application servers restart crashed workers, so the main symptom of probing may be a run of unexplained worker restarts.
- Self-hosted products raise the stakes. A compromised GitLab or GitHub Enterprise Server instance exposes source code, CI/CD secrets, and deploy keys, and a compromised Mastodon or Discourse server exposes user data and private messages.
The flaw is not limited to the two frameworks. Veria Labs warns that application code that upcases strings received in a legacy encoding may also be vulnerable. Likely places for such code are mail parsers, CSV and EDI importers, and integrations with older systems that still exchange ISO-8859-1 or Windows-1252 text.
Which actions should security teams take?
1. Upgrade Ruby and restart every process
Install Ruby 4.0.10, 3.4.13, or 3.3.14, the fixed release on the branch each application already uses. Both the Ruby team and Veria Labs give this as the only remediation.
- Update the Ruby runtime itself, through your version manager, your distribution’s packages, or your container base image. A
bundle updatechanges gems, not the interpreter. - Rebuild container images after the base image is updated. Images pinned to an older tag or digest keep the vulnerable interpreter.
- Restart application servers completely. A Puma phased restart reloads application code in new workers but keeps the master process on its old Ruby binary, so it does not apply a Ruby upgrade.
- For self-hosted products, install the vendor’s fixed release. Do not replace the bundled Ruby by hand unless the vendor documents how.
Ruby 3.2 and older will not receive a fix. Move those applications to a supported branch, or take them off the internet until you can.
2. Reduce exposure until you can patch
No official workaround exists. Three measures narrow the exposure while upgrades roll out:
- Put self-hosted Ruby products, such as GitLab and GitHub Enterprise Server, behind a VPN or an IP allowlist if they are reachable from the internet.
- In your own code, convert text to UTF-8 before changing its case, for example with
str.encode("UTF-8"). UTF-8 strings take the unaffected path. This does not protect the Rails code path Veria Labs found, which has not been disclosed. - At the edge, consider flagging requests that carry 21 or more ß characters in a legacy encoding within one value. In ISO-8859-1 and Windows-1252, ß is the byte 0xDF, which appears as
%DFin URL-encoded data. UTF-8 encodes ß as two different bytes,%C3%9F, so ordinary German text in UTF-8 does not match.
The edge rule is our suggestion from the published root cause, and we have not tested it against the undisclosed Rails path. It also cannot see raw 0xDF bytes inside multipart bodies unless your WAF inspects them. A starting pattern for query strings and URL-encoded form bodies:
(?i)(?:%df(?:[^%&]|%[^d&]|%d[^f&])*){21}The pattern counts %DF sequences inside a single parameter and stops at &. It is written without ambiguous repetition, so it avoids catastrophic backtracking and runs in linear time in RE2-based WAFs. Run it in detection mode first, because legitimate Latin-1 text can contain many ß characters.
3. Find exposed instances
No indicators of compromise or detection signatures have been published. To find Ruby runtimes in scope:
- Check the interpreter each running process uses, not the one on your shell’s path. On Linux,
readlink -f /proc/<PID>/exeshows the binary behind a Puma, Unicorn, or Sidekiq process, and running that binary with-vshows its version. - Check bundled runtimes. GitLab’s Linux package, for example, ships its own Ruby under
/opt/gitlab/embedded/bin/ruby, which a scan of system packages does not list. - Check container base images and the
.ruby-versionfile orrubyline in eachGemfile, so the next deployment does not bring the old interpreter back. - Search your code for
upcase,swapcase,downcase(:fold), andcasecmp?applied to text that was decoded withforce_encodingorencodeinto one of the 14 affected ISO-8859 or Windows-125x encodings. - Prioritize internet-facing Rails and classic-style Sinatra applications, then self-hosted products, then internal services.
Distribution packages can carry backported fixes under an upstream version number that looks vulnerable, the same problem we described for PHP2Shell. Check the package changelog for the GHSA identifier, or for the CVE once one is assigned.
For detection, watch the application server log for Ruby worker crashes, which show up as [BUG] Segmentation fault messages from Ruby or as glibc heap corruption aborts such as malloc(): corrupted top size or free(): invalid next size. Also watch for requests that match the edge pattern above. A single crash can have many causes, so repeated crashes that line up with requests from one source are the stronger lead.
Timeline
Veria Labs dates the vulnerable loop to Ruby 2.4.0 and expects to publish its proof of concept about a week after disclosure.
Why this keeps happening below the application
Ruby2Shell is the third unauthenticated remote code execution flaw in widely deployed server software we have covered this week, after Java4Shell in the JDK and nginx2root in nginx. Ruby2Shell and Java4Shell sit in the same kind of place: a routine conversion of incoming data, changing the case of text in one and decoding Base64 in the other, that runs before any authentication or business logic and corrupts the heap.
Ruby2Shell and Java4Shell share another trait. Both write bytes the attacker cannot choose, a fixed S here and a fixed pattern in the Java case, and in both the researchers report code execution anyway. Treating either flaw as lower risk because the written bytes are fixed would contradict what both research teams report.
Tracking adds a practical problem. Until a CVE is assigned, Ruby2Shell exists only as a GHSA identifier, so scanners that match CVE records against installed packages will not flag a vulnerable interpreter. In October, the Ruby team had not requested CVEs for the Onigmo fixes, at least for now, and asked users to track them under GitLab’s identifiers. For flaws in the runtime, the reliable check is an inventory of the interpreters each service runs and the fixes each one carries.
How Equixly helps
Equixly now includes a check for Ruby2Shell, live in production. When it finds the flaw, it reports an issue that names the service and the Ruby version behind it.
Equixly maps the web applications and APIs that attackers can reach and records how each endpoint behaves, which, combined with your inventory of Ruby runtimes, shows which Rails and Sinatra services face the internet. For applications reachable only from your internal network, Equixly runs its tests through Space Link, a container you deploy inside that network.
For the difference between a version match and a confirmed exposure, see Penetration testing vs. vulnerability scanning.
Book a demo to see how Equixly maps your exposed applications and APIs and tests them after you patch.






