Recess
Sign in
← Back to feed
You're reading as a guest. Sign in to save posts, see what's new, and tune your feed.
Sign in
KEN THOMPSON COMPILER TRUST ATTACK · BITE · 2 MIN · INTERMEDIATE

Ken Thompson Used His Turing Lecture to Show You Cannot Trust Your Compiler

He hid a backdoor in the C compiler that reinstalled itself on every recompile. Even reading the source code wouldn't reveal it.

Ken Thompson, accepting the 1983 ACM Turing Award with Dennis Ritchie, used his 1984 lecture to make a single point: a determined attacker can corrupt a system in a way that no amount of source-code review will find. He titled the talk 'Reflections on Trusting Trust.'

The construction is recursive. Step one: write a backdoor into the login program — say, accept a hidden master password. Step two: modify the C compiler to recognize the login program when it sees it being compiled, and silently inject the backdoor into the output. Now you can clean up the login source. The binary still gets the backdoor.

Step three is the elegant part. Modify the compiler to also recognize itself. When it compiles its own source, it injects both pieces of code into the new compiler binary. Now you can clean up the compiler source too. The dirty compiler propagates through every future generation, even though every line of source on disk looks honest.

The attack survives a full audit. A reviewer reads the login source and sees nothing. They read the compiler source and see nothing. They rebuild the compiler and the new binary still recognizes the login program and still recognizes itself, because the compiler that built it was already infected. The flaw lives below the layer the reviewer can see.

Thompson's takeaway was a moral one. 'You can't trust code that you did not totally create yourself.' The lecture is now a standard reading in security courses, and the term 'trusting trust' has stuck. Every supply-chain attack since — XcodeGhost in 2015, the SolarWinds compromise in 2020 — is a long footnote on a 9-page paper from 1984.

#security#compilers#ken-thompson#supply-chain#computer-history
Sources
Communications of the ACMACM