r/programming • • 5d ago

Ruby2Shell

https://verialabs.com/ruby2shell/
178 Upvotes

44 comments sorted by

View all comments

53

u/RustOnTheEdge 5d ago

I really struggle how you can do remote code execution by writing a single, predetermined byte out of bounds. Can anyone explain that to me? I just don’t see how this is realistically exploitable?

24

u/He_Who_Browses_RDT 4d ago

I remember reading the "smashing the stack for fun and profit" in the 90's. I can still recommend it in 2026.

You'll get a better understanding of it.

6

u/RustOnTheEdge 4d ago

Thanks for the tip!

19

u/freddylmao 4d ago

You can control the length of the buffer. This means that this is a primitive for writing one byte at a time, from finish to start. It is likely difficult to set up a shell using this, unless you are keenly aware of the memory layout on the server. My guess is that you'd have to rely on some coincidence between the letters 'S' and 's' and some architecture's bytecode.

48

u/gwillen 4d ago

It's possible the exploitability is overstated. People are prone to that. It may be exploitable only under hypothetical or unrealistic conditions. You might be surprised, though.

46

u/GoldenShackles 4d ago

Unfortunately this is where AI excels. These types of issues used to be flagged as lower priority issues because on careful examination from expert devs, they couldn't see a way it could be exploited.

11

u/coriandor 4d ago

It's not one byte. It's one byte per ß. The writeup says the buffer is allocated as len + 20, so you need 21 ßs to overflow 1 byte. Make that "ß*100<payload>", and you've pushed your payload 80 bytes past the buffer.

2

u/fakehalo 4d ago

Its confusing, because looking at the code snippet itself it appears like the while(to<to_len) check iterating through each character would still only allow this the be a single byte overflowing the very last iteration.. since the *to++ is happening/incrementing 2 times each loop to keep the check (except for the very last one)

22

u/Skellicious 4d ago

Yeah I'm sceptical too. It's probably possible in some way or another, but it's also "CVE pending" so there's no score however flawed those scores may be.

But better give it a 2shell name for some attention before the risk factor is even evaluated.

5

u/red75prime 4d ago

We'll be publishing a proof of concept demonstrating remote code execution on stock Rails on 25 November 2026, or later if major vendors have not shipped a fix by then.

What are you skeptical about, specifically?

4

u/drdavidawheeler 3d ago

Hi, I work for the Open Source Security Foundation (OpenSSF) on security. It's *possible* it isn't really exploitable. However, that is *not* where I would place my bet. This kind of vulnerability (ability to write a single byte out of bounds at will) has turned into practical exploits before, so attackers already have patterns to learn from, and the best AI models are now *really* good at chaining together "minor defects" into a full remote code execution (RCE). I think the "right thing" to do now is to make it *easy* to update your software (including your dependencies) and make sure it passes a good test suite. If you get an update that says "please update for this vulnerability, I've already verified your thorough test suite passes", it's easy to accept. If you have to do a lot of manual analysis, you've already lost before you begin. There are going to be a LOT more vulnerabilities found in software. Now is the time to get ready for the updates.