TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

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

130 pointsby crtxcrover 2 years ago

14 comments

atlgatorover 2 years ago
I remember my Gentoo days freshman year in college. I spent more time compiling updates than actually using the computer.
评论 #34538954 未加载
评论 #34539305 未加载
评论 #34539160 未加载
评论 #34539718 未加载
评论 #34540242 未加载
评论 #34538847 未加载
评论 #34539064 未加载
评论 #34540218 未加载
评论 #34615517 未加载
评论 #34543943 未加载
jchwover 2 years ago
I like this idea. I have an idea for something that would be cool, if impractical: Imagine a GCC wrapper that <i>doesn&#x27;t</i> actually link, but produces a bundle that performs the linking in randomized order in realtime and then runs.<p>I think that you could do this quite well on NixOS, and I&#x27;m now intrigued to try to rig up a proof-of-concept when I can find the time.<p>Side-effect: Does not work for libraries without a significantly more complex wrapper that certainly could not work for all libraries. Though, you <i>could</i> re-order the objects within a static library fairly easily.
评论 #34534903 未加载
vlovich123over 2 years ago
I wonder if just shuffling it on every release (even minor) isn’t sufficient (and actually even publishing that order). That doesn’t have full security benefit (attackers have a finite set of options) but keeps reproducible builds and the ability to distribute pre-linked binaries while raising the attack complexity significantly since no two machines are likely running the exact same version. That means an exploit has to try several different versions. Taking this a step further, create link N randomly sorted copies per version and randomly distribute those. Now the space to search through is large and the probability of picking the correct gadget variant goes down with 1&#x2F;MN where there are M releases being attacked and N variants per release that might be installed (a targeted attack or an attack of a specific version only gets 1&#x2F;N). Additionally, deterministic builds maintain your ability to audit binaries and their providence fairly easily (only grows linearly) while the risk of noticing the attempt without a successful exploit is N-1&#x2F;N.<p>I’m not saying it’s perfect but it seems like a reasonable defense for binary distribution. As someone who used to run Gentoo, I’d say most people are in favor of the faster times to install a new package.<p>EDIT: extending this idea further, I wonder if compilers can’t offer a random seed to supply that causes a random layout of the sections within a built execution so that even statically linked binaries benefit from this.
评论 #34535721 未加载
评论 #34533695 未加载
评论 #34540746 未加载
somatover 2 years ago
Openbsd also puts a fair amount of work into removing ROP gadgets.<p>For example.<p><a href="https:&#x2F;&#x2F;marc.info&#x2F;?l=openbsd-cvs&amp;m=152824407931917" rel="nofollow">https:&#x2F;&#x2F;marc.info&#x2F;?l=openbsd-cvs&amp;m=152824407931917</a>
评论 #34534489 未加载
评论 #34534605 未加载
评论 #34540724 未加载
ShredKazooover 2 years ago
Lack of reproducible builds seems like a big cost here.<p>I wonder if there&#x27;s a way to do just-in-time random relinking such that the performance cost is low, but the security benefit is still strong.<p>Just-in-time gets you reproducible builds, and also addresses the &quot;local attackers who can read the binary or library&quot; problem.<p>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.<p>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.<p>Another advantage is that this approach should be feasible on an OS like Ubuntu where everything is precompiled.<p>However the static analysis part could be a little tricky? I&#x27;m not familiar with the state of the art in static analysis of compiled binaries.<p>Performance-sensitive users could be given a way to turn the feature off, in cases where fast startup time was more important than security.
评论 #34542453 未加载
phkahlerover 2 years ago
&gt;&gt; As a side-effect, reproducible builds, which this technique breaks, are less of a concern anyway (because you&#x27;ve compiled your system from source).<p>Reproducible builds verify the source code and build process (including options) were the same. Not sure how important each aspect is.<p>Also, if for some reason you rebuild a dependency, you&#x27;ll need to relink everything that depends on that. This could get messy, but it&#x27;s still interesting.
评论 #34534132 未加载
评论 #34532847 未加载
评论 #34533992 未加载
frankjrover 2 years ago
I&#x27;m guessing &quot;dev-libs&#x2F;openssl shuffleld&quot; should go into &quot;&#x2F;etc&#x2F;portage&#x2F;package.env&quot; instead (in the appendix).
评论 #34539976 未加载
lucideerover 2 years ago
&gt; <i>The potential issue comes from the assumption that all .o files will be given continuously in the command line. The assumption appear to hold, but could blow up down the road. But well, it&#x27;s hack.</i><p>Other than this issue (which may well be a large &#x2F; unsolvable one), I wonder what other disadvantages to this approach there might be. Does this hack have any potential for a Gentoo profile or mainlining?
matzfover 2 years ago
Don&#x27;t try this with C++, unless you&#x27;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.
评论 #34535463 未加载
评论 #34536459 未加载
gigel82over 2 years ago
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 &quot;import library&quot; .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).<p>Is dynamic linking in Unix world truly runtime-only (a-la &quot;GetLibrary&quot; &#x2F; &quot;GetProcAddress&quot;)?
评论 #34544332 未加载
hermitdevover 2 years ago
One gap to this approach: gcc can use argument files (pass a file that contains the actual arguments). I&#x27;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.
评论 #34539994 未加载
yazzkuover 2 years ago
Deep feels from that web design. Simple, aesthetic, functional.
ngneerover 2 years ago
Why not prevent control transfer to the ROP gadget?
评论 #34542110 未加载
kwhitefootover 2 years ago
ROP gadgets?
评论 #34535637 未加载