Live data from Hacker News

Is Ken Thompson's compiler hack still a threat?

programmers.stackexchange.com

11–20 of 29 posts

Re: Is Ken Thompson's compiler hack still a threat?

#11
post #10
post #5

A variation of the threat very much exists: Do you know (meaning, there are no unknown unknowns) that no piece, anywhere in your toolchain (OS, compiler, library, framework, buildtool, CI etc), contains malicious code? At the time Thompson made this comment, he talked about the C compiler because it was the one bit of shared code everything else depended on. Today, the attack surface is much, much larger. If I was ru…

Sure, but it sounds like you're talking about a standard hidden backdoor. This is a pretty straightforward and obvious threat. What Thompson describes is a whole lot more devious and difficult to detect.

The crude variation of the attack-vector I'm describing is a backdoor, that is correct - but that's also what Thompson is imagining his attack being used for.

Thompson's scenario is more devious, more difficult to detect, and a lot, lot harder to implements (near impossible, as some of the SO answers point out). But at that time, people didn't generally download millions of lines of code written by perfect strangers and incorporate them into their programs, so that was the only way to pull such a thing off.

Re: Is Ken Thompson's compiler hack still a threat?

#13
The paper on Trusting Trust is as much a thought experiment as anything. It's not really about compilers, and thinking of it as a "compiler hack" misses the point somewhat. The bigger point of that hack, is if a component of a system is integral and implicitly trusted, then compromising that component means that the entire system can no longer be trusted.

It seems sort of obvious when stated that way, but Ken's demonstration pointed out a few significant details. First, that such an attack didn't have to be large, only two or three changes to the compiler. Second, that such an attack was practical to implement instead of just theoretical. Third, that once a system is compromised, it couldn't even be relied upon to tell you that it was compromised (his follow-up included a third compiler tweak to alter the decompiler), which was probably the scariest point of all.

The type of attack that Ken described is still relevant, even if it's not the compiler that's the target. For example, if you could compromise Windows Update, you could do basically the exact same thing. That's why Windows Update requires crypto signatures.

Re: Is Ken Thompson's compiler hack still a threat?

#15
The other day, I was putting forth the idea that this threat vector exists in 3d printers. I don't know any obvious reason why I'm wrong on that.

edit: I hate having to ask, but instead of downvoting, are there actual reasons this fear is completely unwarranted?

Re: Is Ken Thompson's compiler hack still a threat?

#16
post #15

The other day, I was putting forth the idea that this threat vector exists in 3d printers. I don't know any obvious reason why I'm wrong on that. edit: I hate having to ask, but instead of downvoting, are there actual reasons this fear is completely unwarranted?

Did you mean that the compromised printer would be made to produce compromised output? If so, the downvotes may be because it's relatively easy to audit the output of a 3D printer, compared to the output of a compiler.

It's a common practice, for example, to x-ray a critical piece of structure to verify it's free of cracks. A similar inspection would generally show if the hidden internals of a printed object conform to the original design.

Auditing the output of a compiler, on the other hand, would be devilishly hard, multiplied by the fact that every program it has ever produced is suspect. Given that this might include your kernel, filesystem, network drivers, etc., it's hard to find an adequate 3D printer parallel. Yes, a bit of crucial structure might be compromised by a pwned printer, but it would probably be relatively easy to spot.

Re: Is Ken Thompson's compiler hack still a threat?

#18
post #13

The paper on Trusting Trust is as much a thought experiment as anything. It's not really about compilers, and thinking of it as a "compiler hack" misses the point somewhat. The bigger point of that hack, is if a component of a system is integral and implicitly trusted, then compromising that component means that the entire system can no longer be trusted. It seems sort of obvious when stated that way, but Ken's demon…

And the crypto sigs on WU don't matter because you can compromise the boot process.

Re: Is Ken Thompson's compiler hack still a threat?

#19
post #15

The other day, I was putting forth the idea that this threat vector exists in 3d printers. I don't know any obvious reason why I'm wrong on that. edit: I hate having to ask, but instead of downvoting, are there actual reasons this fear is completely unwarranted?

Did you mean that the compromised printer would be made to produce compromised output? If so, the downvotes may be because it's relatively easy to audit the output of a 3D printer, compared to the output of a compiler. It's a common practice, for example, to x-ray a critical piece of structure to verify it's free of cracks. A similar inspection would generally show if the hidden internals of a printed object conform…

So, the full argument my friends and I were having, was that it would be impossible for a government to enforce printers that could not do guns. My assertion was it was likely more doable than my friend would care to admit. My claim centered on this idea, as well as the identifying marks laserjets do on printouts and a belief that they already have scanners noticing when money is scanned. (No, I don't know the details on all of that, so I fully concede my argument is not air tight.)

Re: Is Ken Thompson's compiler hack still a threat?

#20
Basically a compiler "rootkit".

I found this comment interesting:

"At some point, aboveboard modifications to the compiler or login program might get to the point where they defeat the backdoor's compiler-recognizer/login-recognizer, and subsequent iterations would lose the backdoor. This is analogous to a random biological mutation granting immunity to certain diseases."

Post reply on HN