Newshot

Ruby2ßhell: Pre-authentication RCE on stock Rails

Original text(via Hacker News)

Affected software

题图
题图

Ruby versions

Ruby seriesAffectedFixed in
4.04.0.0 to 4.0.94.0.10
3.43.4.0 to 3.4.123.4.13
3.33.3.0 to 3.3.133.3.14
3.2 and olderAll releases back to 2.4.0EOL

Your deployment

The bug is reachable from the following frameworks in their default configuration. Other frameworks are not exposed by default, but application code that upcases strings received in a legacy encoding may also be vulnerable.

FrameworkStatus on an affected Ruby
RailsAffected
Sinatra (classic style)Affected
Other frameworks and plain RackNot exposed by default

Self-hosted software

The latest version of the following popular software bundles an affected Ruby.

SoftwareBundled RubyStatus
GitLab 19.6.03.3.13Affected
GitHub Enterprise Server 3.22.54.0.9Affected
Mastodon 4.7.54.0.9Affected
OpenProject 17.9.74.0.9Affected
Discourse 2026.10.13.4.7Affected
Chatwoot 4.20.03.4.4Affected

Updated 19 November 2026 at 09:29 UTC.

Remediation

Your deployment

Upgrade Ruby to a fixed release: 3.3.14, 3.4.13 or 4.0.10.

Self-hosted software

Install the vendor's fixed release. See Self-hosted software for fixed versions of popular products.

Technical details

Root cause

Most of Ruby's single-byte encodings have no capital ß. Upcasing it writes two bytes, SS, but the loop only bounds-checks one (to < to_end).


        1while (*pp < end && to < to_end) {    /* room for one byte */2    code = *(*pp)++;3    if (code == SHARP_s) {4        if (flags & ONIGENC_CASE_UPCASE) {5            *to++ = 'S';              /* first byte */6            code = 'S';7        }8        /* ... */9    }10    /* ... */11    *to++ = code;                     /* second byte, unchecked */12}
      

The output buffer is allocated as the input length plus 20 bytes. Each ß adds one byte to the output, so an input with 21 of them overflows the buffer by one byte.

The same loop is in several ISO-8859 and Windows-125x encodings and has been there since Ruby 2.4.0. It is reached by upcase, swapcase, downcase(:fold) and casecmp?.

UTF-8 strings take a different code path and are not affected.

Fixed upstream in ruby/ruby@d582f8f.

Primitive

A one-byte heap overflow. The byte written is S (0x53) when upcasing or s (0x73) when case-folding, and it lands directly after the output buffer. The attacker controls the size of the buffer through the input length.

Copying the result out of the buffer then reads one byte out of bounds.

Proof of concept

We'll be publishing a proof of concept in a week, once people have had time to upgrade.

The text above was extracted automatically from the source page and may miss images, tables or code blocks. The original is authoritative.

Published by Hacker News
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗