# Ruby2Shell: Ruby Case-Conversion Heap Overflow Enables Unauthenticated RCE on Rails and Sinatra Applications (GHSA-34m4-m9fh-gqp5)

> Veria Labs disclosed Ruby2Shell (GHSA-34m4-m9fh-gqp5), a one-byte heap overflow in Ruby's string case conversion for certain legacy single-byte encodings that is reachable without authentication in default Rails and classic-style Sinatra configurations. Fixed in Ruby 3.3.14, 3.4.13 and 4.0.10; Ruby 3.2 and older (back to 2.4.0) are affected and end-of-life. No CVE assigned yet, no in-the-wild exploitation reported, and a PoC is planned about one week after disclosure.

- **Published:** 2026-11-19T10:16:46Z
- **Last reviewed:** 2026-11-19T10:16:46Z
- **Canonical:** https://intel.threadlinqs.com/threat/TL-2026-6441
- **Card image:** https://intel.threadlinqs.com/og/threat/TL-2026-6441.png
- **ID:** TL-2026-6441
- **Severity:** CRITICAL
- **Category:** VULNERABILITY
- **Status:** TRACKING
- **Detections:** 9 (1 shown free below) · **IOCs:** 12

## Description

Ruby2Shell is a one-byte heap out-of-bounds write in Ruby's String case conversion. Most single-byte legacy encodings (several ISO-8859 and Windows-125x encodings) have no uppercase form of the German sharp s (ß). Upcasing it writes two bytes ('SS'), but the conversion loop only verifies room for one byte. The output buffer is sized as input length plus 20 bytes, so an input containing 21 instances of ß overflows the buffer by one byte. The written byte is 'S' (0x53) when upcasing or 's' (0x73) when case-folding. The attacker controls the allocation size through input length, and copying the result out afterwards reads one byte out of bounds. According to Veria Labs, the flaw has existed since Ruby 2.4.0. Strings in UTF-8 take a different code path and are not affected.

Affected functions per Veria Labs are upcase, swapcase, downcase(:fold) and casecmp?. Ruby on Rails and classic-style Sinatra are exposed in their default configurations, which is why Veria Labs describes the bug as unauthenticated remote code execution; plain Rack and other frameworks are not exposed by default. Any application code that changes the case of untrusted strings in a legacy encoding may also be vulnerable. The Ruby core team published the fix as part of a seven-vulnerability advisory on 2026-11-18 (Regexp and String case conversion): this item is GHSA-34m4-m9fh-gqp5, credited to Stephan Lipp (Ada Logics) and Anthropic, upstream commit d582f8f in ruby/ruby. A second, separate case-conversion flaw, GHSA-87fm-7w84-j2px (integer overflow leading to heap overflow, credited to baba__yaga via HackerOne), was fixed in the same release; the other five advisories cover Regexp compilation, matching and Regexp#to_s (GHSA-7x2q-68qv-6p8x, GHSA-wpqw-5qxg-m68r, GHSA-3p8q-wmhx-vm2w, GHSA-7whj-cfh7-xgm4, GHSA-pvgc-g7gj-pv6h).

Affected Ruby releases are 4.0.0-4.0.9, 3.4.0-3.4.12, 3.3.0-3.3.13, and all end-of-life releases through 3.2 back to 2.4.0, which will not be patched. Veria Labs lists these bundled products as affected at their latest listed versions: GitLab 19.6.0 (Ruby 3.3.13), GitHub Enterprise Server 3.22.5 (Ruby 4.0.9), Mastodon 4.7.5 (Ruby 4.0.9), OpenProject 17.9.7 (Ruby 4.0.9), Discourse 2026.10.1 (Ruby 3.4.7) and Chatwoot 4.20.0 (Ruby 3.4.4). No workarounds are published; the only remediation is upgrading Ruby or installing the vendor's fixed release.

No CVE or CVSS score has been assigned, no in-the-wild exploitation has been reported, and no IOCs, malware names or attribution exist in the sources. Veria Labs states a proof of concept will be released about one week after the disclosure, after which opportunistic exploitation of internet-facing Rails and Sinatra applications should be anticipated. The Ruby advisory notes the team is aware of PoCs for some of the seven vulnerabilities. Because exploit details are not public, exploit-chain specifics beyond the primitive described above (heap layout, gadget selection, payload) are not documented in the sources and are intentionally not speculated on here.

## MITRE ATT&CK

- T1595.002 Vulnerability Scanning
- T1588.006 Vulnerabilities
- T1190 Exploit Public-Facing Application
- T1059 Command and Scripting Interpreter
- T1059.004 Unix Shell
- T1499.004 Application or System Exploitation

## Free detection (Splunk SPL, Microsoft KQL, Sigma)

**Ruby2Shell (GHSA-34m4-m9fh-gqp5) - 21+ Encoded 0xDF Sharp-S Bytes in Web Request - Exploitation** (`TL-2026-6441-SPL-001`)

Detects web requests carrying 21 or more percent-encoded 0xDF bytes (sharp s in ISO-8859-1/Windows-1252). Per the Ruby advisory and Veria Labs, 21 sharp-s characters is the trigger condition for the one-byte heap overflow in Ruby legacy-encoding upcase/swapcase/downcase(:fold)/casecmp? (Ruby2Shell, GHSA-34m4-m9fh-gqp5, TL-2026-6441): the output buffer is input length + 20 bytes and each sharp s expands to 'SS'. Rails and classic-style Sinatra are exposed unauthenticated by default. No public PoC or in-the-wild exploitation exists yet (PoC expected about 2026-11-26), so the pattern is derived from the documented trigger condition and must be re-validated once a PoC is published.

- **Languages:** Splunk SPL, Microsoft KQL, Sigma
- **ATT&CK:** T1190, T1595.002
- **Data sources:** index=web sourcetype=access_combined, index=web sourcetype=nginx:plus:access, index=web sourcetype=apache:access, CommonSecurityLog, webserver logsource
- **Severity:** high
- **Confidence:** high

### Splunk SPL

````spl
index=web (sourcetype=access_combined OR sourcetype=nginx:plus:access OR sourcetype=apache:access) earliest=-24h
```Ruby2Shell GHSA-34m4-m9fh-gqp5: 21+ percent-encoded 0xDF (sharp s) bytes in one request overflow Ruby legacy-encoding case conversion by one byte```
| rex field=_raw max_match=0 "(?i)(?<sharp_s>%DF)"
| eval sharp_s_count=mvcount(sharp_s)
| where sharp_s_count>=21
| rex field=_raw "(?<http_method>GET|POST|PUT|PATCH|DELETE|HEAD|OPTIONS) (?<request_path>[^ ?]+)"
| eval client=coalesce(src, src_ip, clientip)
| stats count AS requests max(sharp_s_count) AS max_sharp_s_per_request dc(sharp_s_count) AS distinct_sharp_s_counts earliest(_time) AS first_seen latest(_time) AS last_seen values(http_method) AS methods values(request_path) AS paths by client, host
| convert ctime(first_seen) ctime(last_seen)
| sort - requests
````

### Microsoft KQL

```kql
CommonSecurityLog
| where TimeGenerated > ago(24h)
| where isnotempty(RequestURL)
// Ruby2Shell GHSA-34m4-m9fh-gqp5 trigger: 21+ encoded 0xDF (sharp s) bytes
| extend SharpSCount = array_length(extract_all(@"(?i)(%DF)", RequestURL))
| where SharpSCount >= 21
| summarize Requests = count(), MaxSharpS = max(SharpSCount), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated), Targets = make_set(DestinationHostName, 10), SampleUrls = make_set(substring(RequestURL, 0, 200), 5) by SourceIP, DeviceVendor
| project FirstSeen, LastSeen, SourceIP, DeviceVendor, Requests, MaxSharpS, Targets, SampleUrls
| order by Requests desc
```

### Sigma

```yaml
title: Ruby2Shell GHSA-34m4-m9fh-gqp5 - 21 or More 0xDF Sharp S Bytes in Web Request
id: 7c1e4a52-3b9d-4f0e-a6d1-2e8b5c90f411
status: experimental
description: Detects HTTP requests carrying 21 or more percent-encoded 0xDF bytes (sharp s in ISO-8859-1 and Windows-1252), the documented trigger condition for the one-byte heap overflow in Ruby legacy-encoding case conversion (Ruby2Shell, GHSA-34m4-m9fh-gqp5, TL-2026-6441).
references:
    - https://verialabs.com/ruby2shell/
    - https://www.ruby-lang.org/en/news/2026/11/18/multiple-vulnerabilities-in-regexp-and-string/
    - https://github.com/advisories/GHSA-34m4-m9fh-gqp5
author: Threadlinqs Team
date: 2026/11/19
tags:
    - attack.initial-access
    - attack.t1190
    - attack.reconnaissance
    - attack.t1595.002
logsource:
    category: webserver
detection:
    selection_query:
        cs-uri-query|re: '(?i)(?:%DF.*?){21,}'
    selection_uri:
        c-uri|re: '(?i)(?:%DF.*?){21,}'
    condition: 1 of selection_*
fields:
    - c-ip
    - cs-method
    - cs-uri-stem
    - cs-uri-query
falsepositives:
    - Binary data placed in the query string by a broken legacy client
    - Security scanners replaying high-byte fuzzing corpora
level: high
```

**Known false positives:**

- Legacy ISO-8859-1 clients submitting very long German-language text through GET query strings
- Authorized vulnerability scanners or WAF test suites replaying high-byte fuzzing payloads

**Tuning notes:** Limit to Rails and Sinatra frontends by host or vhost. Log request bodies or WAF payload inspection where available, since POST bodies are not visible in access logs. Also review requests using charset=iso-8859-x or windows-125x in the Content-Type header. UTF-8 sharp s (%C3%9F) does not reach the vulnerable code path and is intentionally not matched. Allowlist authorized scanner source IPs. Re-validate the pattern once the Veria Labs PoC (expected around 2026-11-26) is public. Companion rules KQL-001 (allocation-size probing) and SIG-001 (double-encoded and raw-escaped variants) cover tuning and evasion.

### 8 more detection rules (Splunk SPL, Microsoft KQL, Sigma), unlock with TL Creds

- Ruby2Shell (GHSA-34m4-m9fh-gqp5) - Allocation-Size Probing with Repeated Sharp-S Requests (Sentinel) - Exploitation (locked: unlock with TL Creds)
- Ruby2Shell (GHSA-34m4-m9fh-gqp5) - Secret and Credential File Access by Ruby Application Server Children (Sentinel) - Post-Exploitation (locked: unlock with TL Creds)
- Ruby2Shell (GHSA-34m4-m9fh-gqp5) - Ruby Application Server Outbound Connection to Public IP on Non-Standard Port (Sentinel) - C2 (locked: unlock with TL Creds)
- Ruby2Shell (GHSA-34m4-m9fh-gqp5) - 21+ Double-Encoded or Raw-Escaped 0xDF Bytes in Web Request (Sigma) - Exploitation (locked: unlock with TL Creds)
- Ruby2Shell (GHSA-34m4-m9fh-gqp5) - Persistence Commands Spawned by Ruby Application Server (Sigma) - Post-Exploitation (locked: unlock with TL Creds)
- Ruby2Shell (GHSA-34m4-m9fh-gqp5) - Ruby Inline Interpreter Reverse Shell or Downloader (Sigma) - C2 (locked: unlock with TL Creds)
- Ruby2Shell (GHSA-34m4-m9fh-gqp5) - Ruby Application Server Memory-Corruption Crash - Exploitation Fallout (locked: unlock with TL Creds)
- Ruby2Shell (GHSA-34m4-m9fh-gqp5) - Ruby Application Server Spawning Shell or Download/Reverse-Shell Tooling - Post-Exploitation / C2 (locked: unlock with TL Creds)

Sign up free to unlock the detection rules: https://threadlinqs.com/?modal=signup

## Sources

- [Veria Labs - Ruby2Shell disclosure (GHSA-34m4-m9fh-gqp5)](https://verialabs.com/ruby2shell/)
- [Ruby Security advisories: multiple vulnerabilities in Regexp and String case conversion](https://www.ruby-lang.org/en/news/2026/11/18/multiple-vulnerabilities-in-regexp-and-string/)
- [GBHackers - Ruby2Shell: Critical Ruby Vulnerability Allows Unauthenticated RCE on Rails and Sinatra Applications](https://gbhackers.com/ruby2shell-critical-ruby-vulnerability/)
- [GitHub Advisory GHSA-34m4-m9fh-gqp5](https://github.com/advisories/GHSA-34m4-m9fh-gqp5)
- [ruby/ruby upstream fix commit d582f8f](https://github.com/ruby/ruby/commit/d582f8f)
- [Ruby news index (3.3.14, 3.4.13, 4.0.10 release posts)](https://www.ruby-lang.org/en/news/)
- [GBHackers - GitLab patches 37 security vulnerabilities](https://gbhackers.com/gitlab-patches-37-security-vulnerabilities/)

## Full data

The other 8 detection rules (Splunk SPL / Microsoft KQL / Sigma) unlock with TL Creds; a free account includes daily creds: https://threadlinqs.com/?modal=signup
Indicator values unlock with TL Creds, at a lower price on Red and Purple; AI agents can query rules and IOCs through the Threadlinqs MCP server (Purple): https://intel.threadlinqs.com/mcp

Canonical: https://intel.threadlinqs.com/threat/TL-2026-6441
