Live data from Hacker News

Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

quitesimple.org

61–70 of 84 posts

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#61
post #37

Earlier quoted context omitted.

The size of the distributed binary gets very large because you're shipping a lot of code that ends up getting eliminated by the linker. Also if you want to do any kind of LTO, then I don't see how you do it in your model. (which is significant for the larger applications like Chrome that have the likely attack surface). Not every binary on the system actually needs this either. Finally, the main problem with this ide…

Randomizing the link order per release does not solve anything, for this to really work as an mitigation layer, you need to have few different randomly linked versions and randomly give these to the end users. Just randomizing the build does not solve anything as there still is exactly one layout that everyone uses. On another note: automating this on gentoo is cool exercise, but almost certainly if you just build ev…

> Randomizing the link order per release does not solve anything, for this to really work as an mitigation layer, you need to have few different randomly linked versions and randomly give these to the end users. Just randomizing the build does not solve anything as there still is exactly one layout that everyone uses.

First, it does. At scale, the probability of everyone running the exact version of every piece of software is 0. If you want, go take a look and see how many users are running a given version of Android.

Also, did you miss when I wrote

> Taking this a step further, create link N randomly sorted copies per version and randomly distribute those

I agree, doing it per version is only just a small amount of coverage. We're in agreement that generating N randomized copies and distributing those evenly is a stronger position because it makes the cost MN where you have M releases that are still running and N variants per release.

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#62
How does this work with dynamic libraries (shared objects). In Windows land, you get a .lib with a .dll and afaik that has hardcoded function addresses. You statically link the "import library" .lib with your exe, so if you randomize the function addresses and rebuild just the .dll later, it blows up (you need to rebuild all exes as well).

Is dynamic linking in Unix world truly runtime-only (a-la "GetLibrary" / "GetProcAddress")?

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#65
Lack of reproducible builds seems like a big cost here.

I wonder if there's a way to do just-in-time random relinking such that the performance cost is low, but the security benefit is still strong.

Just-in-time gets you reproducible builds, and also addresses the "local attackers who can read the binary or library" problem.

There would be a performance cost in terms of startup time, but since the number of possible permutations is a factorial function of the number of possible linking orders, it seems like even a very coarse-grained random relinking can go a long way.

You could accomplish this by doing static analysis of a binary to generate a file full of hints for ways to rewrite the binary such that its behavior is provably equivalent to the original. Then there could be a wrapper (perhaps at the shell or OS level) which uses the hints to randomly relink on the fly just prior to execution.

Another advantage is that this approach should be feasible on an OS like Ubuntu where everything is precompiled.

However the static analysis part could be a little tricky? I'm not familiar with the state of the art in static analysis of compiled binaries.

Performance-sensitive users could be given a way to turn the feature off, in cases where fast startup time was more important than security.

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#66

Earlier quoted context omitted.

These days my 5950X can get through some of the big scary packages quite rapidly. Firefox is done in about 8 minutes, a new point release of Rust seems to take about 15. I still haven’t decided whether or not I should be embarrassed that I mainly bought a 16-core CPU to run Gentoo.

Don't be embarrassed, its what computers are for! I've done the same thing recently too. It honestly feels like a better use of a high-core desktop CPU than have it sit idle 99% of the time.

I wonder which is more wasteful - compiling these packages for the nth time vs mining cryptocurrency...

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#67
post #63

Why not prevent control transfer to the ROP gadget?

Because we are unable to do that, and we've tried for decades.

There are all kinds of things we're doing (e.g. rewriting things in memory-safe languages) to make it less likely for an attacker to become able to control a jump to somewhere, however, we don't expect to fully succeed any time soon, and this is defense in depth against cases when attackers once again do find a way to control transfer to some arbitrary gadget.

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#68

Lack of reproducible builds seems like a big cost here. I wonder if there's a way to do just-in-time random relinking such that the performance cost is low, but the security benefit is still strong. Just-in-time gets you reproducible builds, and also addresses the "local attackers who can read the binary or library" problem. There would be a performance cost in terms of startup time, but since the number of possible…

Do reproducible builds even matter if you're building/linking and executing a binary on the same system?

The biggest benefit seems to be in making it infeasible/dangerous for a malicious actor to distribute binary versions containing different behavior from the published source.

On a local machine, when and with what would you compare your binaries?

Re: Fun with Gentoo: Why don't we just shuffle those ROP gadgets away?

#69
post #14
post #8

I like this idea. I have an idea for something that would be cool, if impractical: Imagine a GCC wrapper that doesn't actually link, but produces a bundle that performs the linking in randomized order in realtime and then runs. I think that you could do this quite well on NixOS, and I'm now intrigued to try to rig up a proof-of-concept when I can find the time. Side-effect: Does not work for libraries without a signi…

That'd make process startup EXTREMELY slow

Not that bad if you link with a custom mold fork.
Post reply on HN