Huny's Dev Blog
huny.dev

Ruby2Shell (CVE-2026-132825) Architecture Deep Dive: Single-Byte Encoding (ß→SS) 1-Byte Heap Overflow, Pre-Auth Rack::MethodOverride RCE Path, and GitLab/Rails Remediation (Ruby 4.0.10 · 3.4.13 · 3.3.14)

An architectural deep dive into Ruby2Shell (CVE-2026-132825, GHSA-34m4-m9fh-gqp5), a critical 1-byte heap buffer overflow in CRuby string case conversion, alongside six additional Regexp and String memory-safety fixes in Ruby 4.0.10, 3.4.13, and 3.3.14. Covers why default Rails and classic Sinatra apps are exposed pre-authentication via Rack::MethodOverride, self-hosted bundled platform patches (GitLab 19.6.1+, Discourse), and WAF vs. non-HTTP worker boundaries.

Hun Jang
Hun Jang Nov 22, 2026

Ruby2Shell (CVE-2026-132825 · GHSA-34m4-m9fh-gqp5) Architecture Diagram: Legacy Single-Byte Encoding (ISO-8859-1 · Windows-1252) German Sharp S (ß → SS) 1-Byte Heap Overflow, Rack::MethodOverride Pre-Auth Entry Path, Self-Hosted Bundled Platforms, and Non-HTTP Worker Boundaries (Conceptual Illustration)

The most critical operational rule for mitigating Ruby2Shell (CVE-2026-132825, GHSA-34m4-m9fh-gqp5) is that the vulnerability lives inside the CRuby interpreter (libruby) rather than in the Rails or Rack gems—meaning bundle update rails provides zero protection, and every web container, background worker, and self-hosted platform bundling Ruby (such as GitLab, Discourse, or Mastodon) must be upgraded to Ruby 4.0.10, 3.4.13, or 3.3.14 and restarted.

On November 18, 2026, the Ruby core team published an urgent official security advisory releasing Ruby 4.0.10, 3.4.13, and 3.3.14 to patch seven memory-safety vulnerabilities across CRuby's string case-conversion logic and Onigmo regular expression engine. On November 19, the flagship 1-byte heap buffer overflow was assigned CVE-2026-132825 (NIST NVD) (GHSA-34m4-m9fh-gqp5, dubbed Ruby2Shell or ruby2ßhell) (Cloudflare Security Analysis, AWS Security Bulletin 2026-193-AWS). Researchers at Veria Labs demonstrated that default Ruby on Rails and classic-style Sinatra applications reach the vulnerable code path prior to any authentication, and announced plans to publish their default-Rails remote code execution (RCE) proof of concept after November 25, 2026 (Apidog Engineering Analysis, watchTowr Intelligence FAQ).

This deep dive cross-verifies the official Ruby security announcement, Cloudflare's WAF engineering post, AWS Security Bulletin 2026-193-AWS, the GitLab 19.6.1 critical patch release notes, Aikido Security's advisory, and OX Security's heap exploitability assessment as of November 22, 2026. We did not run live heap-grooming or RCE exploit payloads against production hosts; all architectural boundaries, C-level buffer calculations, and mitigation procedures below are synthesized from verified upstream advisories and patch commits.

1. Three Conceptual Boundaries: Why bundle update rails and "UTF-8 Only" Assumptions Fail

When triaging Ruby2Shell, engineering and security teams must separate three frequently confused boundaries:

  1. Updating Application Gems (bundle update rails) vs. Upgrading the CRuby Interpreter (libruby): The off-by-one heap write sits in CRuby's native C implementation of single-byte string case conversion, not in any Ruby gem (Apidog Analysis). Bumping Rails in Gemfile.lock changes nothing: a brand-new Rails 8 service running on Ruby 3.4.12 is vulnerable, whereas a legacy Rails 6.1 service running on Ruby 3.3.14 is fully patched.
  1. "Our Application Only Uses UTF-8" vs. Attacker-Controlled Multipart Charset Tagging: UTF-8 strings take a separate multi-byte code path in CRuby and do not trigger the overflow (Cloudflare Blog). However, in a multipart/form-data HTTP POST request, each individual form part can declare its own Content-Type header with a legacy character set (such as charset=ISO-8859-1 or Windows-1252). When Rack parses that multipart body, it instantiates a Ruby String tagged with that legacy encoding—forcing a UTF-8 application straight into the vulnerable single-byte conversion loop.
  1. Pre-Auth Reachability vs. Universal RCE Exploitability: As OX Security's patch review notes, turning a 1-byte out-of-bounds heap write into reliable code execution requires precise heap layout manipulation across specific allocators (jemalloc, glibc malloc, and CRuby GC heap slots). Nevertheless, both the Ruby core maintainers and Cloudflare confirm the existence of working RCE proofs of concept, and even an unweaponized 1-byte overwrite can corrupt adjacent object metadata or crash worker processes.

2. Inside CVE-2026-132825 (GHSA-34m4-m9fh-gqp5): Why 21 German Sharp S (ß) Bytes Overflow the Heap Before Authentication

2.1 The C-Level Buffer Math: Input Length + 20 Bytes vs. ß (0xDF → SS)

Every Ruby String carries an explicit Encoding object alongside its raw byte buffer. Beyond UTF-8, CRuby natively supports 14 legacy single-byte encodings in the ISO-8859-x (such as ISO-8859-1 Latin-1) and Windows-125x (Windows-1252) families (Cloudflare Blog, OX Security).

  1. The 1-to-1 Length Assumption and 20-Byte Slack Buffer: In a single-byte encoding, each character occupies one byte, so changing case normally keeps the byte length unchanged. Since Ruby 2.4.0, CRuby allocated an output buffer of input_length (N) + 20 bytes of slack when converting the case of a single-byte encoded string (Apidog).
  1. The 1-to-2 Byte Expansion of ß (0xDF): The German sharp s (ß, byte 0xDF) breaks the 1-to-1 assumption in 14 ISO-8859 and Windows-125x encodings: because those legacy code pages lack a single-byte capital ẞ, converting ß to uppercase produces the two-byte ASCII sequence SS (0x53 0x53).
  1. Checks Room for 1 Byte, Writes 2 Bytes: Inside the case-conversion loop, vulnerable CRuby builds checked that at least 1 byte remained free in the output buffer, and then wrote 2 bytes (SS) (Cloudflare Blog).
      • Each ß character consumes 1 byte of the 20-byte slack allocation.
      • With 20 ß characters (N = 20), the output takes 40 bytes, filling the allocated 20 + 20 = 40-byte buffer to the exact boundary.
      • With 21 ß characters (N = 21), the output writes 42 bytes into a 21 + 20 = 41-byte heap buffer—overflowing the end of the buffer by 1 byte.
  1. Affected String Methods: This vulnerable path is reached by String#upcase, String#swapcase, String#downcase(:fold), and String#casecmp? (as well as their in-place ! counterparts) (Cloudflare Blog).

2.2 Why Default Rails and Classic Sinatra Apps Are Reached Pre-Authentication (Rack::MethodOverride)

An application does not need to call .upcase in its own controller code to be exposed. Ruby on Rails and classic-style Sinatra applications reach the bug in their default configuration before any route handler or authentication check executes (Cloudflare Blog, Aikido Security):

  • Because standard HTML forms only support GET and POST, Rack provides the Rack::MethodOverride middleware to tunnel PUT, PATCH, and DELETE requests over POST using a _method form parameter.
  • Rails includes Rack::MethodOverride in its default middleware stack, and classic Sinatra apps enable it whenever method_override is active.
  • When any POST request arrives, Rack::MethodOverride inspects the _method parameter and calls .upcase on its value while still in the outer Rack middleware layer—before routing or authentication filters run.
  • An unauthenticated attacker can send a single multipart/form-data POST request whose _method part specifies Content-Type: text/plain; charset=ISO-8859-1 and contains 21 0xDF (ß) bytes, triggering the heap buffer overflow immediately inside Rack::MethodOverride.

3. All 7 Vulnerabilities in the November 18 Ruby Release & Self-Hosted Platform Matrix

3.1 Complete 7-Flaw Matrix in Ruby 4.0.10, 3.4.13, and 3.3.14

According to the official Ruby security advisory, upgrading to 4.0.10, 3.4.13, or 3.3.14 resolves seven distinct memory-safety bugs reported by Stephan Lipp (Ada Logics) and Anthropic, baba__yaga, aphantom, Hiroya Fujinami, and Hiroshi SHIBATA:

Advisory ID (CVE / GHSA)
Component
Vulnerability Class
Root Cause & Exposure Condition
Cloudflare WAF Rule & Remediation
CVE-2026-132825
(GHSA-34m4-m9fh-gqp5)
String Case Conversion
1-Byte Heap Buffer Overflow (Critical / RCE)
In 14 legacy single-byte encodings (ISO-8859-x, Windows-125x), converting ß (0xDF→SS) checks room for 1 byte but writes 2 bytes. Reached pre-auth in default Rails & classic Sinatra via Rack::MethodOverride (_method.upcase)
Blocked by Default
Free: 7328f23691e44b07892ebd25b19210f1
Paid: 1afa543a1ed84893b01df04c34402c88
GHSA-87fm-7w84-j2px
String Case Conversion
Integer Overflow → Heap Buffer Overflow (RCE)
Integer overflow during output buffer size calculation in string case conversion leads to a heap-based buffer overflow and potential RCE
Blocked by Default
Free: 8660e37e86444f9f9267ba22e9855f05
Paid: 6defac6a52334542adf4a162daf25922
GHSA-7x2q-68qv-6p8x
Onigmo Regexp Engine
Double Free (RCE)
Double free when compiling a crafted regular expression pattern; can allow RCE in applications that compile attacker-controlled regex patterns
Never pass raw user input to Regexp.new · Upgrade to Ruby 4.0.10 / 3.4.13 / 3.3.14
GHSA-3p8q-wmhx-vm2w
Onigmo Regexp Engine
Integer Overflow → Heap Buffer Overflow (RCE)
Integer overflow during regular expression compilation triggers a heap-based buffer overflow and potential RCE when compiling untrusted patterns
Sanitize dynamic search/filter patterns with Regexp.escape and upgrade CRuby
GHSA-7whj-cfh7-xgm4
Onigmo Regexp Engine (Regexp#to_s)
Heap Buffer Overflow (Info Disclosure / RCE)
Converting a crafted regular expression to a string via Regexp#to_s causes a heap buffer overflow, enabling memory disclosure or RCE
Restrict untrusted regex compilation and upgrade CRuby
GHSA-wpqw-5qxg-m68r
Onigmo Regexp Engine
Out-of-Bounds Read (Memory Corruption)
Out-of-bounds read during case-insensitive regular expression matching can lead to memory corruption in an attacker-controlled manner
Upgrade to Ruby 4.0.10 / 3.4.13 / 3.3.14
GHSA-pvgc-g7gj-pv6h
Onigmo Regexp Engine
Out-of-Bounds Read (Info Disclosure / DoS)
Out-of-bounds read during case-insensitive backreference matching can disclose process memory contents or crash the worker
Upgrade to Ruby 4.0.10 / 3.4.13 / 3.3.14

3.2 Self-Hosted Products and Cloud Platforms Bundling Vulnerable CRuby

Even organizations that do not write Ruby code in-house are frequently exposed through self-hosted developer and collaboration platforms that bundle their own CRuby runtime (Cloudflare Blog, GitLab 19.6.1 Patch Release, AWS Bulletin 2026-193-AWS):

Platform / Runtime
Exposed Versions (At Nov 19 Disclosure)
Patched Releases & Status (Verified Nov 22, 2026)
Required Engineering Action
Upstream CRuby
<= 3.3.13, 3.4.0 – 3.4.12, 4.0.0 – 4.0.9 (present since 2.4.0)
Ruby 4.0.10, 3.4.13, 3.3.14 (shipped Nov 18, 2026) · Ruby 3.2 & older are EOL (no fix)
Upgrade interpreter binaries across all web and Sidekiq containers/VMs and restart every process. Migrate off EOL Ruby 3.2/3.1 immediately
GitLab CE / EE
All versions from 7.0 through 19.6.0
GitLab 19.6.1, 19.5.8, 19.4.10 (shipped Nov 20, 2026; GitLab.com already patched)
Upgrade Omnibus packages and Docker deployments to 19.6.1 / 19.5.8 / 19.4.10. Self-compiled installs must manually rebuild Ruby to 3.3.14 or 3.4.13
Discourse
Discourse 2026.10.1 (bundled affected Ruby)
Official Discourse Docker base image updated to Ruby 4.0.10 on Nov 19, 2026
Run ./launcher rebuild app on your Discourse host to pull the patched Ruby 4.0.10 base image
AWS Elastic Beanstalk
Amazon Linux 2023 Ruby platform <= v4.15.3
AL2023 Ruby Platform v4.15.4 (shipped Nov 19, 2026 with Ruby 3.3.14, 3.4.13, 4.0.10)
Update Elastic Beanstalk environments to platform version 4.15.4 or run dnf upgrade on AL2023 instances
GitHub Enterprise Server (GHES)
GHES 3.22.5 (bundled affected Ruby at disclosure)
Monitor GitHub Enterprise Server patch release notes
Restrict GHES management and web access to private networks (VPN / IP allowlists) until patched
Mastodon · OpenProject · Chatwoot
Mastodon 4.7.5, OpenProject 17.9.7, Chatwoot 4.20.0
Vendor container and package updates rolling out
Apply vendor security releases or rebuild container images on Ruby 3.3.14 / 3.4.13 / 4.0.10

4. Why Perimeter WAF Rules Cannot Replace Patching: Direct-to-Origin & Non-HTTP Blind Spots

Both Cloudflare WAF (across Free and Paid Managed Rulesets, with Block enabled by default) and CrowdSec (crowdsecurity/vpatch-CVE-2026-132825) now deploy virtual patches that block HTTP requests attempting to exploit CVE-2026-132825 and GHSA-87fm-7w84-j2px.

However, relying solely on a WAF leaves three major blind spots open (Cloudflare Blog):

  1. Direct-to-Origin Requests and East-West Internal Traffic: Any request sent directly to your origin IP address—or sent between internal microservices inside your VPC—bypasses edge WAF inspection unless origin access is locked down via Cloudflare Tunnel, Authenticated Origin Pulls, or strict security groups.
  1. Non-HTTP Ingestion Pipelines (Inbound Email, File Imports, Message Queues): Because CVE-2026-132825 sits in String#upcase, swapcase, downcase(:fold), and casecmp?, it does not require an HTTP request. Background workers (Sidekiq, GoodJob, Resque) that change the case of strings extracted from inbound emails (ActionMailbox, where ISO-8859-1 and Windows-1252 MIME parts are common), uploaded CSV/legacy text files, or message queues can trigger the exact same heap overflow completely outside the WAF's visibility.
  1. Stale Container Layers in Background Workers: Teams frequently redeploy their puma web tier while forgetting to rebuild and restart sidekiq worker pods or scheduled cron containers built from the same repository.

5. Runtime Audit Script & Interim Rack Middleware Guard

5.1 One-Step Container, VM, and Process Inventory Script

Run the script below inside the actual containers, VMs, or dynos serving your API and background workers (not on a developer laptop) to verify the active CRuby binary version and locate any unpatched worker processes:

5.2 Interim Pre-Patch Mitigation: Enforcing UTF-8 Before Rack::MethodOverride

As stated in AWS Security Bulletin 2026-193-AWS, there is no workaround that replaces upgrading CRuby, but teams that cannot deploy a new runtime binary immediately should prevent untrusted input from being processed in non-UTF-8 encodings.

To close the pre-authentication Rack::MethodOverride entry point while your container rebuilds are in flight, insert a lightweight guard middleware before Rack::MethodOverride (or remove Rack::MethodOverride entirely with config.middleware.delete Rack::MethodOverride if your service is a pure JSON API that never uses HTML form _method tunneling):

6. Operational Remediation Checklist (Target Completion Before November 25, 2026)

  • Step 1 (Upgrade CRuby & Restart All Processes): Have you upgraded the CRuby interpreter across every web server (puma, unicorn, passenger) and background worker (sidekiq, good_job, resque) to Ruby 4.0.10, 3.4.13, or 3.3.14, rebuilt all container images, and verified ruby -v inside the running pods?
  • Step 2 (Eliminate EOL Ruby 3.2 and Older Runtimes): Have you inventoried and prioritized immediate upgrades for any service still running on EOL Ruby 3.2, 3.1, 3.0, or 2.x (which receive no upstream patches)?
  • Step 3 (Patch Self-Hosted Bundled Platforms): Have you upgraded self-hosted GitLab instances to 19.6.1, 19.5.8, or 19.4.10, rebuilt Discourse Docker containers (./launcher rebuild app) onto the Ruby 4.0.10 base image, and placed unpatched GitHub Enterprise Server (3.22.5), Mastodon (4.7.5), OpenProject (17.9.7), and Chatwoot (4.20.0) servers behind VPN or IP allowlists until patched?
  • Step 4 (Verify WAF Blocking & Lock Down Origin IPs): If you use Cloudflare on a paid plan, have you verified that the Cloudflare Managed Ruleset is active with rules 1afa543a1ed84893b01df04c34402c88 (CVE-2026-132825) and 6defac6a52334542adf4a162daf25922 (GHSA-87fm-7w84-j2px) set to Block, and ensured origin servers reject direct non-Cloudflare traffic?
  • Step 5 (Audit Non-HTTP Encoding Normalization & Dynamic Regexes): Have you audited inbound email processors (ActionMailbox), CSV/file import jobs, and queue workers to ensure external strings are transcoded/validated as UTF-8 before calling .upcase/.downcase(:fold)/.casecmp?, and confirmed that untrusted strings are never compiled directly via Regexp.new (GHSA-7x2q-68qv-6p8x, GHSA-3p8q-wmhx-vm2w)?

References (Verified November 22, 2026)

Korean version: Ruby2Shell(CVE-2026-132825) 아키텍처 해부: 단일 바이트 인코딩(ß→SS) 1바이트 힙 오버플로·Rack::MethodOverride 인증 전 RCE 경로와 GitLab·Rails 패치 경계 점검하기 (Ruby 4.0.10 · 3.4.13 · 3.3.14)Ruby2Shell(CVE-2026-132825) 아키텍처 해부: 단일 바이트 인코딩(ß→SS) 1바이트 힙 오버플로·Rack::MethodOverride 인증 전 RCE 경로와 GitLab·Rails 패치 경계 점검하기 (Ruby 4.0.10 · 3.4.13 · 3.3.14)

추천 글