Trusting Trust: A Compiler Backdoor Demo in Go

github.com/vivi365/trustingtrust-go

A demonstration of the Trusting Trust Attack, i.e. compiler backdoor, originally described by Ken Thompson in his 1984 Turing Award lecture.

The Attack

A compromised compiler can inject malicious code into binaries during compilation, even when the source code is clean. The attack persists through bootstrapping: when you compile a new version of the compiler from source, the malicious compiler infects the new version. This means the compromise survives compiler updates, making it difficult to detect and remove.

The Demo

My implementation targets the Go compiler, demonstrating how a backdoored toolchain can:

  • Inject malicious code into seemingly benign programs (like a login system)
  • Persist across compiler rebuilds through bootstrapping
  • Operate invisibly, leaving source code untouched

The demo is packaged in a Docker container for easy reproduction and includes a detailed technical explanation of the attack mechanism and potential defenses like reproducible builds and diverse double-compilation.

This was created for the Ethical Hacking course (FEP3370) at KTH, building upon prior work by yrjan’s untrustworthy_go project.