Ruby2ßhell: Pre-authentication RCE on stock Rails
128 points by jdns 6 hours ago | 45 comments

cowlevel 47 minutes ago
So the recent RCE wave seems to be people finding more single byte overflows and such, but reporting them as RCEs because AI can do the tedious grunt work of finding the rest of the vulnerability chain.

If any single byte overflow can be converted into an RCE with minimal human effort then we have no choice but to prove the whole software stack is memory safe.

reply
toastal 9 minutes ago
I like your comment since it points out that we need to enforce the memory situation—but it doesn’t prescribe Rust is the only solution.
reply
boomlinde 27 minutes ago
From my understanding it's only a single byte overflow if your payload only contains a single ß.
reply
miohtama 40 minutes ago
This is bad news for C/C++
reply
xnickb 29 minutes ago
This is bad news for computer industry. See the recent Java4Shell.
reply
eecc 21 minutes ago
because the assembly for the base64 decoding was handwritten, the paren't comment is still valid
reply
trismegisti 35 minutes ago
But are those generic exploits, that don't rely on specific dynamic library and kernel versions? i doubt it.
reply
circularfoyers 3 hours ago
Thought this was another vulnerability for a second, but for anyone else who thought the same, this is already covered in the Ruby advisory being discussed here https://news.ycombinator.com/item?id=50554038 (which covers six other vulnerabilities).
reply
barbegal 2 hours ago
More interested to see how you can use just a single byte overflow to trigger RCE. Definitely achievable but sounds tough.
reply
deprave 24 minutes ago
There was an article on this topic in Phrack 55 back in 1999: https://phrack.org/issues/55/frame-pointer-overwriting#artic...

Exploitation conditions are likely more challenging today but that’s the earliest reference I know for exploiting a single byte overflow.

reply
valleyer 10 minutes ago
The commit message for the Ruby fix says it's a heap buffer, so frame pointer smashing would not apply here.
reply
weinzierl 3 hours ago
There should be other codepoints other than ß that in principle could be used for a vulnerability like that. There are even ones that expand to three codepoints, like ffi.
reply
stuxf 2 hours ago
this relies on specific behavior with how the upcase function worked, the ß is the only one that expands in a way that works for this vulnerability.
reply
weinzierl 39 minutes ago
Can you elaborate on what makes ß special enough to enable the vulnerability.

A quick search showed that there are other cases in legacy encodings that expand to multiple bytes.

For example 0xEF in ISO 6937 expands to CA BC 4E in UTF-8 after case transformation. Similar to ß this is a case with a single byte legacy encoding with a single lowercase unicode codepoint which has no precomposed upper case equivalent.

reply
debugnik 26 minutes ago
From the Ruby docs:

> Non-ASCII case mapping and folding are supported for UTF-8, UTF-16BE/LE, UTF-32BE/LE, and ISO-8859-1~16 Strings/Symbols.

ß might actually be the only character that expands to multiple bytes on the original encoding from that list of ISO encodings.

reply
weinzierl 14 minutes ago
Ah, good point. If ISO-8859-1 is the only supported single-byte legacy encoding then ß is most likely the only case.

EDIT: Thinking about it, my example from above should work with UTF-16 input.

U+0149 is a single lower case BMP codepoint, so two bytes in UTF-16. It has no precomposed uppercase, so it turns into two codepoints and 4 bytes in UTF-8 and UTF-16.

reply
Panzerschrek 3 hours ago
I suppose this function has been written first in assumption, that case conversion doesn't affect length, but later ß -> SS conversion has been added without proper testing.
reply
johnp_ 2 hours ago
There was never any guarantee that case conversion is byte length equivalent. Except for pure ASCII, that's just been an incorrect assumption from the start.
reply
debugnik 18 minutes ago
This only affects ISO-8859-1~16 encodings, Ruby only supports non-ASCII case folding for those and UTF. It might actually be the only character from that list of ISO encodings for which the length changes.
reply
rob74 2 hours ago
Ah, so that's the real reason "ß" is now allowed in uppercase too (https://en.wikipedia.org/wiki/%C3%9F)? Reducing the risk of security issues by removing an edge case?
reply
pwdisswordfishq 57 minutes ago
The Unicode case mappings are covered by backwards-compatibility guarantees. "ß" is going to be mapped to "SS" forever.
reply
cubefox 55 minutes ago
It even seems the "more correct" uppercase form of ß is now ẞ, not SS.

> Traditionally, ⟨ß⟩ did not have a capital form, and was capitalized as ⟨SS⟩. Some type designers introduced capitalized variants. In 2017, the Council for German Orthography officially adopted a capital form ⟨ẞ⟩ as an acceptable variant, ending a long debate.[4] Since 2024 the capital has been preferred over ⟨SS⟩.[5]

reply
shevy-java 25 minutes ago
> It even seems the "more correct" uppercase form of ß is now ẞ, not SS.

But that is wrong. In german I only know of ß aka downcased version.

ẞ seems another character. I have no idea what it is, other than looking close to ẞ, but it most assuredly is not existing in the german language. There is simply no uppercased variant. 'ss' is "Doppel-s' - that is not ß. In german we have "das" (which is the), but it can be "das" or "dass" depending on the sentence, in particular after a ',' character. I often misspell it, since I prefer "das", when in reality sometimes one has to use "dass". But 'ß' is very different to that - to claim that 'ß' is equivalent to 'ss' is simply incorrect. I have no idea who that "Council for German Orthography" is, but clearly they don't know anything about German. Who put that Council in charge of anything? Are these drunks? The claim that the capital has been preferred, is also factually wrong. Who is writing all that?

Edit: Oh I see, you have that from Wikipedia.

The .pdf can be found here:

https://www.rechtschreibrat.com/DOX/RfdR_Amtliches-Regelwerk...

So from what I can see, this is only the:

"Leibniz-Institut für Deutsche Sprache"

That is not a unified authority for anything. It is totally unclear to me why the wikipedia article claims that this is legally binding for anyone. That's just factually incorrect. Is Wikipedia no longer proofreading?

reply
speedgoose 2 hours ago
But can the attacker specify the encoding in rails? It's not like UTF-8 or GTFO?
reply
CER10TY 2 hours ago
You can freely specify the encoding when sending multipart/form-data POST since Rails respects the charset attribute in Content-Type, eg Content-Type: text/plain; charset=Windows-1252
reply
bloak 57 minutes ago
So you have to convert ISO-2022-JP, for example? That sounds like a disaster waiting to happen.
reply
lmz 52 minutes ago
Clients have to do the same with server responses.
reply
zelphirkalt 3 hours ago
Name as discussed earlier here on Hackernews :) Glad they went with that name.
reply
gsich 2 hours ago
no poc. go away.
reply
stuxf 2 hours ago
would you rather we publish a PoC for a vulnerability that doesn't even have a patch yet? e.g self-hosted GitLab still hasn't shipped a newer version of Ruby that's patched...

would be wildly irresponsible

reply
oguz-ismail2 9 minutes ago
>we

I doubt you have a PoC at all

reply
spikewall 2 hours ago
took glm a bit over 20 minutes to write one, based on the report.
reply
wiether 4 minutes ago
Get ready to upgrade your GitLab instance...
reply
lousken 3 hours ago
Scheiße2Shell?
reply
tvvocold 2 hours ago
One Shell a Day, Ops Run Away.
reply
realsdx 9 minutes ago
Another day, another RCE!
reply
rs_rs_rs_rs_rs 3 hours ago
For once a bug name that's cool.
reply
stuxf 3 hours ago
we were thinking of naming it ruby off rails haha, but this title ties into how this vulnerability works which was super cool
reply
rs_rs_rs_rs_rs 2 hours ago
And the fact that you can almost read it ruby 2 hell
reply
lost_pointer_an 5 minutes ago
[dead]
reply
FreeBurn 2 hours ago
[flagged]
reply
sgt 2 hours ago
Django next? Although it's unlikely, Django is known to be above average in terms of security by now.
reply
Gigachad 2 hours ago
The bug here is in the C code for Ruby. Python is also written in C and just as likely to have memory bugs.
reply
pjmlp 2 hours ago
CPython.
reply
imtringued 2 hours ago
The days of people feeling secure because they don't make egregious mistakes are unfortunately over. Now the rule is: You are vulnerable, you just don't know how.
reply
DarkNova6 2 hours ago
Above average doesn’t cut it these days. And doesn’t Python have some of the strongest exposures to C libraries?

Well…

reply
sgt 48 minutes ago
Uh oh. I guess it's being hammered with people with Red Team access right now.
reply