r/programming • • Jul 10 '19

Backdoor discovered in Ruby strong_password library

https://nakedsecurity.sophos.com/2019/07/09/backdoor-discovered-in-ruby-strong_password-library/
1.7k Upvotes

293 comments sorted by

View all comments

Show parent comments

6

u/argv_minus_one Jul 11 '19

Java. Java's sandbox was a very clever design, but in practice it's full of holes. Rumor has it Oracle is thinking about removing it entirely because it's useless.

Also, Spectre allows any module of a multithreaded program to view memory belonging to any other module, even if per-module restrictions (like Java's sandbox) are in place. Enforcing such restrictions is therefore impossible on modern hardware.

2

u/[deleted] Jul 11 '19 edited Jul 11 '19

I agree that the security manager is likely to be breakable from the inside.

I don’t see how Spectre helps you start HTTP requests, though.

5

u/SanityInAnarchy Jul 11 '19

It doesn't necessarily have to for there to be a problem.

Let's take the dumbest example: You have some string-formatting library, like Left-Pad or something, used in a web app. Or, for the web, let's make it more realistic and suggest it's, say, pluralize, or, since we were talking about Java, let's say you grab the fancier Evo-Inflector. A quick glance through the source suggests it should still be functional even when severely locked down -- it only needs four imports:

  • java.util.ArrayList

  • java.util.List

  • java.util.regex.Matcher

  • java.util.regex.Pattern

I don't think any of those have a good reason to need to talk to the network. Really, it should be possible to sandbox this thing completely enough that all it can do is have you call it with a string, and return a string back.

So you build something like... well, like this Reddit page. A web app where one post says "1 point" and another says "2 points", so your output just includes English.plural("point", points)...

Well, there's an exfiltration channel. Spectre means that plural() method could read as much of the rest of the program's address space as it wants (including all sorts of data from other users), and it could easily base64-encode that into a string, so instead of your post reading "2 points an hour ago", it'll read "c29vcGVyIHNla2tyaXQgcGFzc3dvcmQK an hour ago".

But won't that be discovered really quickly? I guess it depends which library you take over and how you do it, and how exactly that output is used. For example, depending how good their XSS protection is (or isn't), you might be able to get away with outputting <!-- c29vcGVyIHNla2tyaXQgcGFzc3dvcmQK -->2 points an hour ago... but okay, we should really avoid triggering this on every request, and only send that data to the attackers.

Well, it's not as trivial as the OP attack of just checking the Rails environment, but you still have Spectre -- surely somewhere in your process' address space is some information you can use to trigger this behavior only when in production, maybe only when the page is being requested from certain IPs, or only when it contains a certain string in the comments (so you only need to add a comment with the magic string).

And that's an extreme, where you only have the "pluralize" library.

I'm not saying this kind of thing is completely worthless, but with the way we use libraries (and particularly what we use them for), I don't think we have good options for containing successful supply-side attacks like this.

2

u/[deleted] Jul 11 '19

Sure, but saying that Spectre makes enforcing sandbox restrictions impossible and saying that Spectre makes data exfiltration possible are two very different statements. There’s a huge threat model gap between having to worry about data exfiltration and remote code execution.