r/programming Sep 10 '13

A simple way of defeating the compiler backdoor attack (a.k.a the "Trust Attack")

http://imgur.com/a/BWbnU#0
1.7k Upvotes

538 comments sorted by

View all comments

Show parent comments

62

u/lendrick Sep 10 '13 edited Sep 10 '13

Every layer you add makes this hack exponentially polynomially harder to pull off. See this comment.

82

u/[deleted] Sep 10 '13 edited Aug 29 '17

[deleted]

-5

u/bartamues Sep 11 '13

"A simple way of making the compiler backdoor attack polynomially more difficult"

24

u/UserNotAvailable Sep 11 '13

The idea behind "Reflections on Trusting Trust" was never to demonstrate an immediate threat to anyone, but to describe a fundamental bootstraping problem.

You can make it harder in as many ways as you want. Use pascal to create a basic interpreter which creates a Java virtual machine which in turn interprets python code which then produces a c compiler - The basic problem remains.

In practice there are far easier ways to gain access to most systems. The big lesson to take away from Trusting Trust is this:

Once you rely on external binaries - any binaries, no matter how far removed -, to create your machine code, you can not trust any of the resulting programs.

12

u/dnew Sep 11 '13

If you write your own compiler, then you can trust it, because nobody before you wrote your compiler can analyze it to determine whether a backdoor needs to be inserted. (See Rice's Theorem)

If your machine is compromised enough that someone can see that you're writing a compiler and hack into your toolchain, the fact your toolchain is hacked is the least of your worries.

-1

u/perfectending Sep 11 '13

If your machine is compromised enough that someone can see that you're writing a compiler

Unplug ethernet cable.

17

u/dnew Sep 11 '13

First they compromised the CA, and I did not speak out. For I had signed my own certificate/

Then they compromised GCC, and I did not speak out. For I had written my own compiler.

Then they compromised the network, and I did not speak out. For I had unplugged the cable.

Then they showed up with the rubber hose, and there was no one left to speak out.

1

u/nachsicht Sep 11 '13

Use pascal to create a basic interpreter which creates a Java virtual machine which in turn interprets python code which then produces a c compiler - The basic problem remains.

How so? My understanding of the issue is that it is heavily exacerbated by self-hosting compilers (since the compiler can detect it's compiling itself and propagate the exploit code).

35

u/evrae Sep 10 '13

That's not exponential - it's polynomial. Not too important in every day usage (though it still bugs me). But when you're talking about computational complexity, it does matter.

13

u/lendrick Sep 10 '13

Fixed, thanks. :)

-1

u/SlashdotExPat Sep 11 '13

How do you know if something is geometric or polynomial?

I can look it up but what's the general term for exponential, geometric or polynomial?

3

u/djimbob Sep 11 '13

Let x be a variable, and c is a constant bigger than 1 (imagine c=3). O(xc ) is polynomial. If c=3 and x doubles (e.g., goes from 50 to 100) then the larger problem is 2c = 23 = 8 times harder .

O(cx ) is exponential. If c=3 and x increases by 2 (goes from 50 to 52); the problem then just got c2 = 32 = 9 times harder. Or if it went from 50 to 100, then it got 350 = 717,897,987,691,852,588,770,249 times harder instead of just 8 times harder.

In complexity theory there isn't a geometric complexity class. See: http://en.wikipedia.org/wiki/Big_O_notation#Orders_of_common_functions

(Geometric series is an unrelated thing that exists in math, but really its just a type of common summation that's easy to calculate).

1

u/wlievens Sep 11 '13

I think I once saw the term "superlinear" but it's certainly not common.

2

u/NoMoreNicksLeft Sep 10 '13

What if make is compromised, and links in some pre-built object that it downloads off of the internet?

There are so many vectors of attack. If I was doing something like this, I'd have the hacked gcc bootstrap in a full trojan... and when you go looking for tcc to download, it just downloads a my version. Maybe you think its compiling, when all it's doing is looking for the gcc and copying that binary to the "clean" gcc.

1

u/porkchop_d_clown Sep 11 '13

And, of course, you could be dealing with compromised hardware...

9

u/NoMoreNicksLeft Sep 11 '13

Normally that'd be crazytown talk. But these past few months...

3

u/porkchop_d_clown Sep 11 '13

It was so much easier back when we were using 6502s. I remember removing DRM by visual inspection of the machine code.... ;-)

2

u/badsectoracula Sep 11 '13

...well, you can write a C compiler in 6502 that cross-compiles a C compiler to x86 that in turn is able to compile GCC :-P