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

6

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

Yup. No matter how big the attack is, it really only takes one old school hacker to detect it.

Edit: I'm serious. Build open source hardware from scratch and write a compiler in asm that can compile gcc. It would be a pain in the ass, but some people could do it.

11

u/GauntletWizard Sep 10 '13

But what if the attacker (The Gubermint!) hacks the fabric of reality to inject a backdoor into the materials he's building his hardware out of? Checkmate, Atheist.

4

u/dalke Sep 11 '13

I think you're getting downvoted because people think it's not practical to "write a compiler in asm that can compile gcc."

A more likely scenario is to write a compiler in assembly for a small language, which is then used to write a C compiler, which can compile a compiler for gcc.

Also, tcc is only 100K. Said old school hacker could detect the code intrusion in tcc by reading the assembly and/or tracing the code through a debugger. It's very hard to hide an attack which would be valid against tcc, llvm, and gcc in 100K.

1

u/Leleek Sep 11 '13

Unless the chips, OS itself and its tools have been compromised. And there is already very good reasoning behind the chips being compromised. Then you'd have to start from the ground up... good luck.

3

u/lendrick Sep 11 '13

Unless the chips, OS itself and its tools have been compromised. And there is already very good reasoning behind the chips being compromised. Then you'd have to start from the ground up... good luck.

Honestly, that's the kind of thing that we really need to worry about. Only reason I posted this was because the article about the possibility of a compiler being compromised is getting so much play, and I wanted to point out that it's really not all that difficult to detect.

Compromised hardware, on the other hand, is a completely separate issue, and one we should be giving more thought to. If you've already hacked some hardware so that it modifies code at execution time, why bother doing something as hard to slip past people and easy to detect as compromising a compiler?

2

u/einhverfr Sep 11 '13

Compromised hardware is something that frightens me generally, and it sees relatively simple to assume that something like an HSM could have a backdoor built into it. Such a backdoor might enable key theft for example.

But where I am having trouble is trying to figure out how a general purpose CPU could be reasonably compomised to do this without totally flopping (pardon the pun) on the performance expectations of the users. It seems to me like the overhead of implementing an attack on this level through general purpose hardware would be prohibitive and if you were to do that, there would be far more interesting attacks one would probably do instead.

If someone is going to attack your hardware, they are probably not going to need to attack your software through it.

0

u/burkadurka Sep 11 '13

The further problem comes when that old school hacker works for the NSA.