Slashdot Mirror


Imparting Malware Resistance With a Randomizing Compiler

First time accepted submitter wheelbarrio (1784594) writes with this news from the Economist: "Inspired by the natural resistance offered to pathogens by genetically diverse host populations, Dr Michael Franz at UCI suggests that common software be similarly hardened against attack by generating a unique executable for each install. It sounds like a cute idea, although the article doesn't provide examples of what kinds of diversity are possible whilst maintaining the program logic, nor what kind of attacks would be prevented with this approach." This might reduce the value of MD5 sums, though.

31 of 125 comments (clear)

  1. Cute but dumb by oldhack · · Score: 5, Insightful

    You think you have buggy software now, this idea will multiply a single bug into a dozen.

    --
    Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
    1. Re:Cute but dumb by tepples · · Score: 5, Insightful

      If bugs are detected earlier, they can be fixed earlier. Randomizing can turn a latent bug into an incredibly obvious bug.

    2. Re:Cute but dumb by Anonymous Coward · · Score: 2, Insightful

      And would make that buggy software nearly impossible to patch.
      Every time there's a security vulnerability found, you'd essentially have to reinstall the whole application.

      Knock on wood, but I've not had enough bad experiences with malware to think the tradeoff is worth it.

    3. Re:Cute but dumb by oldhack · · Score: 3, Informative

      And broken clocks tells the right time twice a day. How often do you expect the randomization could/would help rather than hinder bug zapping?

      Bug reporting itself would become a much bigger problem due to the greater difficulty in reproducing them.

      --
      Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
    4. Re:Cute but dumb by tepples · · Score: 4, Insightful

      Each bug report would include the the key used to randomize a particular build.

    5. Re:Cute but dumb by mrchaotica · · Score: 2

      If that were possible, then malware could do the same thing (because we all know the random seed isn't going to be stored securely by average users).

      --

      "[Regarding the 'cloud,'] ownership was what made America different than Russia." -- Woz

  2. Would cause major debugging headaches by cant_get_a_good_nick · · Score: 4, Insightful

    Can you imagine parsing a stack trace or equivalent from one of these? Each stack is different.

    Ignoring the fact that Heisenbugs would be much more prevalent.

    Part of programming is paring of states. The computer is an (effectively) infinite-state machine. When you add bounds and checks you're reducing the number of states. This would add a great deal, making bugs more prevalent. Since a lot of attacks are based on bugs, this may increase the likelihood of some attacks.

    1. Re:Would cause major debugging headaches by Anonymous Coward · · Score: 5, Funny

      Ahh, but don't forget the benefits! If random bugs could appear or disappear on installs, think of how much tech support time you can save by just saying "Re-install it and you'll be fine."

      Half the time that's what they do now anyways, now you can replace ALL the calls with that!

    2. Re:Would cause major debugging headaches by Anonymous Coward · · Score: 5, Interesting

      The randomizing compiler could easily be designed to base it's randomizations on a seed, and then include that seed in the obj headers and stack dump trace library of the libc it links against. Then the bug would be just as reproducable as with a standard compiler.

    3. Re:Would cause major debugging headaches by PRMan · · Score: 3, Interesting

      I once thought about writing a virus as an academic exercise (I have never actually written a virus). This was how I was going to evade signature detection. If my virus put random numbers of NOOPs in the code when it rewrote itself and moved the jumps accordingly, it would be very difficult to make a signature for.

      --
      Peter predicted that you would "deliberately forget" creation 2000 years ago...
    4. Re:Would cause major debugging headaches by oldhack · · Score: 2

      Ah, the perceptive reader notes that two can play this game. :)

      --
      Fuck systemd. Fuck Redhat. Fuck Soylent, too. Wait, scratch the last one.
    5. Re:Would cause major debugging headaches by TheRaven64 · · Score: 2
      This is the case for the multicompiler. It uses the -frandom-seed argument that is already used by gcc and clang to seed various other nondeterministic processes. This sentence in the summary annoyed me a lot:

      although the article doesn't provide examples of what kinds of diversity are possible whilst maintaining the program logic, nor what kind of attacks would be prevented with this approach."

      I don't know if TFA actually didn't, but the UCI group has published some papers on the multicompiler work, including this one from CGO last year. The main goal for this is to provide defence against return-oriented programming (ROP) attacks, where you chain together 'gadgets' (small chunks of code that do a little bit of computation and then return). One of the things that they do is insert NOPs to reduce the number of gadgets. This is an x86-specific thing, because the variable-length instructions mean that a single binary sequence can be several different instruction sequences depending on the byte offset where you start reading it. They also try to ensure that gadgets are in different places in every program build. This means that a ROP exploit has to be tailored to the target - you can't just have one byte string that, when pushed onto the stack, will exploit everyone.

      Oh, and for anyone who says 'ASLR solves this!', take a look at the Blind ROP paper from Stanford.

      We're currently investigating incorporating the multicompiler into the FreeBSD package build infrastructure.

      --
      I am TheRaven on Soylent News
  3. ....why? by Anonymous Coward · · Score: 5, Insightful

    ..would a professor of CompSci think this is a good idea, despite the hundreds of problems it *causes* with existing practices and procedures?

    Oh, wait.. maybe because the idea is patented and he'll get paid a lot.
    http://www.google.com/patents/US8239836

  4. So we're stuck with the source then? by NotInHere · · Score: 4, Insightful

    So we should use something like ABS with that randomisation enabled? Or should we trust to download distinct blobs for every download? For the latter, nice try NSA, but I don't want you to be abled to incorporate spyware into my download and not be noticed.
    Its already a pity software gets signed only by so few entities (usually one at a time, at least for deb). Perhaps I know that the blob came from Debian, but I can't verify whether it is the version the public gets, or the special version with some ... extra features. The blobs should be signed by more entities, so then all would have to be NSLed.

  5. Copying the Bad Guys by alphaminus · · Score: 3, Informative

    Some malware already does this, which definitely helps it evade heuristic scans. Sounds worth exploring, but i bet it will make the AV they force me to run at work that much more frustratingly restrictive.

  6. Gentoo by Bert64 · · Score: 5, Funny

    You can already do this with Gentoo, you're highly unlikely to use the same combination of compiler, kernel, assembler, libraries, use flags, compiler flags etc as anyone else...

    --
    http://spamdecoy.net - free throwaway anonymous email - avoid spam!
  7. Increased resistance, just not the right kind. by king+neckbeard · · Score: 2

    This technique would probably be more effective for making detection resistant malware than protecting against malware. The software would still function almost the same, so if it is still interacted with in the same manner, it could still be vulnerable to the same exploit. It also makes it much more difficult to verify the software is valid, meaning that it actually INCREASES the risk factor for malware on account of being a perfect recipe for trojans.

    The real solution to the problem he is trying to solve is not having a monoculture. This does nothing to solve it. If you have different code bases for operating systems, browsers, etc., the ability to infect all of them may be hampered. That's the same advantage of humans and dogs and snakes not being susceptible to the same pathogens. His form of diversty is more of an environmental one, so it's like different potatoes in a bag looking different despite the fact that they are almost certainly clones of each other. That does nothing against a blight.

    --
    This is my signature. There are many like it, but this one is mine.
  8. Trusting trust by tepples · · Score: 3, Informative

    The problem with any nondeterministic compiler is that it prevents use of diverse double-compiling, a method to detect the sort of compiler backdoor described by Ken Thompson in "Reflections on Trusting Trust". You'd have to bootstrap the compiler with nondeterminism turned off (and with GUIDs, timestamps, and multithreaded allocation of symbols for anonymous objects turned off too) in order for the DDC bootstrap construction to converge.

    In any case, I've implemented a technique like this on the Nintendo Entertainment System. I wrote a preprocessor that shuffles the order of functions in the file, the order of opcodes within a function that don't depend on each other's results, and the order of global variables (or the order of fields in an object). One reason I implemented it was to use one variable as another's canary to make buffer overflows easier to detect in an assembly language program. The other is watermarking the binary so that I can tell who leaked a particular copy of the beta version to the public. If you're interested, you can find my shuffle tool in the source code of Concentration Room.

  9. Anti Cheat Maybe by medv4380 · · Score: 2

    It would probably cause more problems than it's worth, but it might be able to render some form of cheating worthless. If each program had a different layout then knowing what address you needed to hook into to cheat could be a problem. I don't see how it could cause more problems than anti-cheat software already does.

  10. ASLR by MathFox · · Score: 2

    If you think a bit further... An operating system could load an executable at a different address every time it is used, without recompilation!

    --
    extern warranty;
    main()
    {
    (void)warranty;
    }
  11. The beef by jones_supa · · Score: 2

    Okay, this technology is described in depth in a 2013 paper called librando: Transparent Code Randomization for Just-in-Time Compilers. There might be even newer information available somewhere, if Mr. Franz or his colleagues have continued the research.

  12. the crutch of determinism by epine · · Score: 4, Interesting

    I must respectfully disagree with you on every point you raise.

    A randomised stack would cause certain types of bugs to manifest themselves much earlier in the development process. Nothing decreases the cost of a bug hunt more than proximity to the actual coding event.

    Such an environment rewards programmers who invest more to validate their loops and bounds more rigorously in the first place. Nothing reduces the cost of a bug more than not coding it in the first place.

    There's nothing that stops the debugging team from debugging against a canonical build, if they wish to do so. If they have a bug that the canonical build won't manifest, they wouldn't even have known about the bug without this technique added to the repertoire. If many such bugs become known early in the development process—bugs that manifest on some randomised builds, but not on the canonical debug build—you're got an excellent warning klaxon telling you what you need to know—your coding or management standards suck. Debugging suck, if instigated soon enough to matter, returns 100x ROI as compared to debugging code.

    Certainly the number of critical vulnerabilities that exist against some compiled binary can only increase in number. So what? The attacker most likely doesn't know in advance which version any particular target will run. The attacker must now develop ten or one hundred exploits where previously one sufficed (or one exploit twice as large and ten times more clever).

    If the program code mutated on every execution, you would have some valid points. That would be stupid beyond all comprehension. An attacker could just keep running your program until it comes up cherries.

    The developer controls the determinism model. It's an asset in the war. There can be more when it helps our own cause, and less when it assists our adversaries.

    Determinism should be not reduced to a crutch for failing to code correctly in the first place. Get over it. Learn how. Live in an environment that punishes mistakes early and often.

    1. Re:the crutch of determinism by Zeek40 · · Score: 3, Insightful
      You respectfully disagree with his points without actually providing any reason why, and while nick's post makes complete sense, your statements seem to have a ton of unexplained assumptions built in.
      1. What kinds of bugs do you think would manifest earlier using this technique, and why do you think that earlier manifestation of that class of bugs will outweigh the tremendous burden of chasing down all the heisenbugs that only occur on some small percentage of randomized builds?
      2. How does such an environment reward programmers who invest more time in validation? More time spent in validation will result in better code regardless of whether you're using a randomized or non-randomized build. More time spent in validation is a cost you're paying, not some free thing provided by the randomized build process.
      3. I don't know what this sentence means: "Debugging suck, if instigated soon enough to matter, returns 100x ROI as compared to debugging code." If what instigated soon enough?
      4. "Determinism should not be reduced to a crutch for failing to code correctly" - What does this even mean? An algorithm is either deterministic or non-deterministic. If your build system is changing a deterministic algorithm into a non-deterministic algorithm, your build system is broken. If your algorithm was non-deterministic to begin with, a randomized build is not going to make it any easier to track down why the algorithm is not behaving as desired.

      All in all, your post reads like a smug "Code better, noob!" while completely ignoring the tremendous extra costs that are going to be necessary to properly test hundreds of thousands of randomized builds for consistency.

  13. Overengineered for it's eventual use.. by hamster_nz · · Score: 2

    Why bother with this at the compiler level?

    Just find 10,000 instruciton pairs that can be reordered as they have no interdependancies, and reorder each of the pairs at random during the install phase. That gives you 2^10,000 unique executibles, but all the debugging symbols and so on will remain the same.

    I guess that doesn't help you against stack-smashing and so on. But will allow you to fingerprint who leaked your binary onto bittorrent - which would be its eventual use.

    1. Re:Overengineered for it's eventual use.. by hamster_nz · · Score: 2

      It isn't that hard.... there are plenty of low hanging fruit - the classic easy case is the NOPs that are used to align jump destinations. Just find :

          [NON PC RELATIVE INSTRUCTION]
          NOP
          NOP
      and replace it with

          NOP
          [NON PC RELATIVE INSTRUCTION]
          NOP

      You could even patch the PC relative offset if you wanted to...

  14. Explain Like I'm Five by vux984 · · Score: 5, Insightful

    The problem with this in "Explain like I'm Five" terms:

    You can have no idea what the program you are running does.

    You cannot trust it. You cannot know it hasn't been tampered with. You cannot know a given copy works the same as another copy. You cannot know your executable has no back doors.

    On the security minded front we have a trend towards striving for deterministic build capability; so that we have some confidence and method of validating that a source code to executable transformation hasn't been tampered with, that the binaries you just downloaded were actually generated from the source code in a verifiable way.

    Another technique I'm seeing in secure conscious areas is executable whitelisting, where IT hashes and whitelists executables, and stuff not on the whitelist is flagged and/or rejected.

    Now this guy comes along and runs headlong in the other direction suggesting every executable should be different. And I'm not sure I see any real benefit, nevermind a benefit that offsets the losses outlined above.

    1. Re:Explain Like I'm Five by vux984 · · Score: 4, Interesting

      It's simple. You use signed source code instead of signed binaries.

      That doesn't really help.

      If every executable is different, then I have no information about the binaries i downloaded. I have to download the source, verify that its the 'audited trusted source' by checking its hash and signatures, and then I have to compile it myself. Most people don't want to compile all their own code.

      It is good enough that OpenBSD released the source code, trusted auditing group audited the source code, and trusted build validation group verifies that the binaries on the OpenBSD site were generated from the audited source. I can just download the binaries check the hash/signatures and I'm good to go.

      And in the case of a corporate IT department, you use the randomizing compiler to build the binary that you push out to your clients. It may be the same throughout your company, but it will be different from anything anyone outside would have access to, which is probably good enough.

      The technique can be expanded to the home market; whereby joe-sixpack is running executable whitelist-reputation subscription software that will flag anything on his system that isn't "known good". Antivirus software is starting to head in this direction -- where it maintains databases of 'known good' executables; you've probably even seen them say "this executable is not known... submit it for analysis" -- take that system to its logical conclusion; and we could see community sites maintain executable whitelists that are as effective as adware blockers. (And they'd have no qualms about flagging "technically not illegal malware but nobody actually wants to run this shit" (e.g. toolbar search redirections through popup advertisting portals that the AV guys are currently too scared to just block outright.)

      Community managed executable whitelists with operating system level enforcement support could potentially make a serious dent in malware on the average uninformed users computer. It would help close a lot of attack vectors. More effective I think than 'randomizing' variable layout at in the compiled executable.

      Also re:
      Then you use a compiler and linker that does some simple things like randomly ordering variables and functions in the executable and on the stack.

      Stronger ASLR and DEP type features in the OS to do executable layout randomization at runtime I think represents a better approach to this than randomization at compile time.

  15. Already done... by Em+Adespoton · · Score: 2

    This is what polymorphic software does, and I think you'll find it on pretty much every computer that's part of a botnet.

    By this measure, botnet software should be really difficult to detect and compromise -- and yet it isn't.

    Also, it's worth noting that while government-sponsored and targeted attacks would be more difficult using this method, most malware depends on whatever the current security flaws are and/or human failure to initially get its foot in the door.

    And the logic path wouldn't be changing, even if the compiled structure was randomized.

    Plus, I think you'll find that many AM scanners these days include "doesn't follow the structure of a standard compiler" as one of the major red flags in looking for malware.

  16. University of California requires patents ... by perpenso · · Score: 3, Informative

    ..would a professor of CompSci think this is a good idea, despite the hundreds of problems it *causes* with existing practices and procedures? Oh, wait.. maybe because the idea is patented and he'll get paid a lot.
    http://www.google.com/patents/...

    As an employee of the University of California a professor is *required* to report any discovery or method that *might* be patentable to the University.

    The University takes it from there, it has an office that researches viability, handles the process and then licenses the patents to "industry". With respect to licensing small local companies are given a better deal than larger internationals. As for the licensing fees collected, 50% goes to the University, 25% to the department (UC Irvine's Computer Science department in this case) and 25% to the employee(s).

    At least that is how it was a few years ago when I was a grad student at UC.

  17. So you are arguing to leave bugs in place ? by perpenso · · Score: 4, Interesting

    What kinds of bugs do you think would manifest earlier using this technique ...

    The GP mentioned a randomized stack. An uninitialized variable would be one, something that often accidentally has a value that does no harm (a zero possibly).

    ... and why do you think that earlier manifestation of that class of bugs will outweigh the tremendous burden of chasing down all the heisenbugs that only occur on some small percentage of randomized builds?

    You do realize that your argument for the status quo and not dealing with the "heisenbugs" is essentially arguing to leave a coding bug in place? Recompiling will not necessarily introduce new bugs, rather change the behavior of existing bugs.

    I've seen many of the sort of bugs this recompiling technique may expose, I spent some years porting software between different architectures. Not only did we have different compilers but we had different target CPUs. It was a friggin awesome environment for exposing unnoticed bugs. Software that had run reliably under internal testing for weeks on its original platform failed immediately when run on a second platform. And it kept failing immediately after several crashing bugs were fixed. The original developers, who were actually quite skilled, looked at several of the bugs eventually found and wondered how the program ever ran at all. I've seen this repeated on multiple teams at multiple companies over the years.

    Also developers working on one platform eventually learned to visit a colleague working on the "other" platform when they had a bug that was hard to reproduce. There was a good chance that a hard to manifest bug on one platform would be easier to reproduce on the other.

    There is nothing like cross platform development to help shake out bugs.

    This recompilation idea would seem to offer some of these same benefits. Yes it complicates reproducibility of crashes in the field but if one can get a recompilation seed with that crash dump/log its more like of dealing with an extra step not some impossible hurdle.

    Plus recompiling with a different seed each time the developer does a test run at their workstation could help find bugs in the first place, reducing the occurrences of these pesky crashes in the field.

    I'm not saying these proposed recompilations in the field are definitely a good idea, just that the negatives seem to be exaggerated. It looks like something interesting, worth looking into a bit more.

  18. Re:Formal verification costs money by TheRaven64 · · Score: 2

    The cost of formal verification has dropped a lot over the last few years, but it's still a couple of orders of magnitude more expensive than a good testing regime. You also run into issues with Goedel's incompleteness theorem: you can't write a specification of a program that accounts for all possible bugs that is less complex than the program itself, and so it is often harder to write a bug-free specification than to write a bug-free program.

    --
    I am TheRaven on Soylent News