You inspect a program’s source code line by line. The dangerous code is not there. You rebuild it from that clean source. The dangerous behavior comes back anyway.
That was the unsettling idea Ken Thompson used for his 1983 Turing Award lecture, later published in 1984 as Reflections on Trusting Trust. Thompson was already famous for creating Unix with Dennis Ritchie and for building the B programming language. But this short lecture did something different: it attacked a comforting assumption programmers often make about source code.
If the source is clean, we tend to think the program built from it must be clean too. Thompson showed why that conclusion can fail when the tool doing the building is itself untrusted.
The trick begins with a compiler that can remember
A compiler is a program that turns source code into executable code. Compilers are often written in the same language they compile, which creates a useful but strange loop: a compiler can compile a new version of itself.
Thompson began with a harmless example. He described how a compiler could be taught a new language rule, then carry knowledge of that rule forward when compiling later versions of itself. Once the compiled compiler contained the knowledge, the explicit training step no longer had to remain in the source.
The point was not the language feature itself. The point was that behavior could survive through the compiled binary even after the source that originally introduced it had changed.
Then the remembered behavior becomes hostile
Thompson’s next step was deliberately malicious. He described a compiler that recognized when it was compiling the Unix login program and inserted code that would accept a particular known password in addition to the legitimate password. In the published lecture, Thompson said he had planted such a bug in a compiler.
If the malicious rule remained visibly written in the compiler source, a reviewer could eventually find it. So the final step was more disturbing: make the compiler recognize when it was compiling a compiler, and cause the resulting compiler binary to carry forward both hidden behaviors.
After that bootstrap step, the incriminating source could be removed. A clean-looking compiler source, compiled by the already modified compiler binary, would produce another modified compiler. That new compiler could again alter the login program and again reproduce the hidden behavior when rebuilding itself.
The backdoor was no longer located where a normal source review expected to find it.
What Thompson actually demonstrated
This is often summarized as “you cannot trust compilers,” but that is too broad. Thompson’s demonstration was about a chain of trust. Reading source code can tell you what the source says. It does not automatically prove that the binary running on the machine corresponds exactly to that source, because some other program translated one into the other.
Thompson also emphasized that the same idea was not limited to C compilers. In principle, the vulnerable layer could be an assembler, loader, firmware tool or another program that transforms programs. The lower the compromised layer sits, the harder it can be to inspect the final system using tools that may depend on that same layer.
He also acknowledged that the underlying possibility predated his lecture, citing an earlier U.S. Air Force critique of Multics security. His contribution was to make the problem vivid with a compact, reproducible idea that programmers could immediately understand.
The modern lesson is software supply-chain trust
Today’s build pipelines are much larger than the compiler alone. A release can depend on package managers, build runners, container images, code generators, signing systems and third-party libraries. Thompson’s example does not mean every layer is secretly hostile. It means source review is only one piece of assurance.
The useful question is: what had to be trusted before this binary appeared?
That question leads to practices such as reproducible builds, independent build environments, signed artifacts, provenance records and stronger separation between development and release infrastructure. Researchers have also explored direct responses to the “trusting trust” problem. David A. Wheeler’s diverse double-compiling work showed a way to compare independently produced compiler results and test whether a compiler binary corresponds to its claimed source under stated assumptions.
A warning about invisible dependencies
Thompson’s lecture remains memorable because it turns a normal engineering habit against itself. Programmers like abstraction. We rely on tools so we do not have to inspect every machine instruction. That is essential for productive software development.
But abstraction always creates a dependency. The moment a team says “the compiler handles that,” “the package manager verifies that,” or “the build server produces that,” it has placed some trust outside the source file currently being reviewed.
The practical response is not paranoia and it is not an attempt to personally rebuild the entire computing stack from first principles. It is to make trust visible: know which tools are in the chain, reduce unnecessary dependencies, verify important artifacts through independent paths when the stakes justify it, and avoid treating readable source code as the final proof of what a machine will execute.
Thompson’s unsettling result was not that source code stopped mattering. It was that source code is one layer of evidence, not the whole chain.
Sources
- Ken Thompson — Reflections on Trusting Trust, Communications of the ACM
- ACM Classic mirror — Reflections on Trusting Trust
- Computer History Museum — Ken Thompson
- Bell Labs archive — Kenneth Thompson biography
- David A. Wheeler — Fully Countering Trusting Trust through Diverse Double-Compiling
- Featured photograph — Ken Thompson, A.C. Diller, CC BY-SA 4.0 via Wikimedia Commons

Leave a Reply