Live data from Hacker News

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

quitesimple.org

11–20 of 84 posts

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

#11
post #7

Openbsd also puts a fair amount of work into removing ROP gadgets. For example. https://marc.info/?l=openbsd-cvs&m=152824407931917

Very cool, thank you for sharing! Not only does ROP facilitate traditional binary exploitation, but it’s also used in cutting-edge evasive techniques. By abusing ROP instead of direct calls, red teamers are able to heavily obfuscate activities from endpoint detection and response.

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

#12
post #7

Openbsd also puts a fair amount of work into removing ROP gadgets. For example. https://marc.info/?l=openbsd-cvs&m=152824407931917

Uh, yeah... The post opens with a mention of being inspired by OpenBSD and goes into some detail on differences between their approach and OpenBSD's throughout.

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

#13
One gap to this approach: gcc can use argument files (pass a file that contains the actual arguments). I've only really seen this with build systems that expect to work on large numbers of arguments that will not fit on the command line. Still, something to be aware of.

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

#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

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

#15
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

It's pretty much what OpenBSD is doing at bootup.

Truthfully though you're right, using typical linkers, this would be pretty slow; at least a few seconds for large binaries, to minutes for things as large as web browsers. However, for many binaries, linking can be done much faster; mold claims to be only 50% the runtime of using `cp` on the object files, which is fast enough to even re-link Firefox on-the-fly without it being unusable.

You could imagine writing a linker specifically for this case, that encodes information about the object files directly into the resulting bundle.

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

#16
post #3

>> As a side-effect, reproducible builds, which this technique breaks, are less of a concern anyway (because you've compiled your system from source). Reproducible builds verify the source code and build process (including options) were the same. Not sure how important each aspect is. Also, if for some reason you rebuild a dependency, you'll need to relink everything that depends on that. This could get messy, but it…

Isn’t it impossible to have truly from-scratch reproducible builds? IIRC, you have to trust the compiler which can’t be built from scratch.

You can bootstrap the compiler. It's a chore but not impossible. More usefully, you can check that your builds are identical to other people's, so at least your compiler isn't uniquely compromised.

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

#19
post #17

Don't try this with C++, unless you're certain that there are no interdependencies or side-effects in global variable initialisation. The link order (usually) affects the order in which initialisers are executed.

On the contrary: do do this and if you observe your program crashing due to linking order, fix the damn bug.

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

#20
post #19
post #17

Don't try this with C++, unless you're certain that there are no interdependencies or side-effects in global variable initialisation. The link order (usually) affects the order in which initialisers are executed.

On the contrary: do do this and if you observe your program crashing due to linking order, fix the damn bug.

Fair enough :) I just meant to point out what could go wrong.
Post reply on HN