SlideShare a Scribd company logo
Reflections on Trusting Trust for Go
1. Turing Award Lecture (1984)
Given by: Ken Thompson
https://www.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf
2. Fully Countering Trust through Diverse Double Compiling (2009)
By: David A. Wheeler
http://www.dwheeler.com/trusting-trust/dissertation/wheeler-trusting-trust-ddc.pdf
1
GopherconSG (4 May 2018) By: Yeo Kheng Meng (yeokm1@gmail.com)
https://github.com/yeokm1/reflections-on-trusting-trust-go
2
Compiler BinaryCode
Why Reflections on Trusting Trust?
3
• Ken Thompson (left) and Dennis Ritchie
• 1983 Turing award for their work on Unix
• Thompson presented “Reflections on Trusting Trust” in his acceptance speech
4
5
The problem
• How do we know a program is safe?
• Inspect the program’s source code.
• But isn’t the program source code compiled by a compiler?
• Inspect the compiler’s source code, eg. Golang Compiler
• https://github.com/golang/go
• But isn’t the compiler compiled by another compiler?
• Self-hosting compilers compile themselves
• -> Eg. Go compiler compiles Go compiler
• So how? How deep do we go down the rabbit hole? 6
Real-life compiler attacks
• Xcodeghost (found Sept 2015)
• Malicious Xcode compiler hosted on Chinese websites
• Injects spyware into output binary
• Win32/Induc.A virus and its successors (found 2009)
• Infects Delphi compiler to inject malicious code into output binary
• Create a botnet
• Further infects other Delphi compilers
7
Xcodeghost image: https://nakedsecurity.sophos.com/2015/11/09/apples-xcodeghost-malware-still-in-the-machine/
Attack Objectives
1. Create a malicious compiler to target a program eg: login program
2. Not leave a trace in compiler source
3. Subvert verification
8
Presentation Outline
1. Self-reproducing program (Quine)
2. Compiler knowledge propagation (Bootstrapping)
3. Attack on the login program
4. Initial Conclusion
5. Mitigation strategy?
9
Stage 1: Self-reproducing program (Quine)
A source program that when compiled and executed,
will produce as output an exact copy of its source.
10
Stage 2: Compiler knowledge propagation
•Pass knowledge down compiler iterations
11
My ”clean” compiler
• ”compiler.go”
1. Reads input source file
2. Prints source file contents to stdout
3. Passes source file to Golang compiler
12
13
My Compiler
Binary
My Complier
Source Code
Golang
Compiler
Hello World
Source Code
Hello World
Binary
Hello World
(Fetch)
Source Code
Compiler source
that compiles
“fetch”
Compiler
can compile
fetch
Compiler
source that
uses “fetch”
Latest
compilerHello World
(Fetch)
Binary 1
Hello World
(Fetch)
Binary 2
Compiler Knowledge Propagation Summary
What we have learned so far?
• A program can output another program even itself.
• Compiler bootstrapping
14
Stage 3: Adding an undetectable backdoor to a login program
15
16
Malicious
Compiler
binary
Malicious
Compiler
Source Code
Golang
Compiler
Clean Compiler
Source Code
Login
Source Code
Malicious
Login
Binary 1
Adding backdoor to login program
Still
Malicious
compiler
Malicious
Login
Binary 2
Verifying the compiler binary
• Expected SHA-256 of Go 1.10.1 darwin/amd64 compiler
• 53b31f87d27bfa88c90789654c9dbec8297a6b157f61076037a85bf0c2687b1d
17
Stage 4: Subverting verification
• Can we prevent the user from detecting the bugged compiler?
18
19
Hacking the SHA256 Program
Thompson’s conclusion
• “You can’t trust code that you did not totally create yourself”
• “No amount of source-level verification or scrutiny will protect you
from using untrusted code.”
• “We can go lower to avoid detection like assembler, loader or
microcode”
• -> You always have to trust somebody
20
Possible defence?
21
“Fully Countering Trusting Trust through Diverse Double-Compiling (DDC) -
Countering Trojan Horse attacks on Compilers”
2009 PhD dissertation by David A. Wheeler
George Mason University
http://www.dwheeler.com/trusting-trust/dissertation/wheeler-trusting-trust-ddc.pdf
22
Diverse Double Compiling (DDC)
• Objective
• To detect the trusting-trust attack of a malicious C Compiler
• Requirements
• Use another compiler in the verification process
• Source code of compiler under test needs to be available
23
DDC Process
• Assume we are have GCC and Tiny C (TCC) compilers
• We suspect GCC is malicious and want to test it
• Compiler-under-test : GCC
• Independent-compiler: TCC
• Independent-compiler can be:
• Small: just enough code to compile compiler-under-test
• Generate inefficient code
24
DDC Process
25
TCCSourceGCC
Self-regeneration
test (Control)
Should be identical
GCC (c. GCC, c. GCC) GCC (c. GCC, c. TCC)
Compiler-under-test: GCC
Independent-compiler: TCC
GCC (c. TCC)GCC (c. GCC)
GCC
SourceGCC
SourceGCC
SourceGCC
Why DDC works?
• TCC can be malicious but unlikely to be malicious in a way that affects GCC
• Hacker must compromise both GCC and TCC to hack each other
• Easier to review smaller verifying-compiler source code and binary
26
DDC Scaling
27
TCCSourceGCC
Self-regeneration
test (Control)
Should be identical
GCC (c. GCC, c. GCC) GCC (c. GCC, c. TCC) GCC (c. GCC, c. Intel)
Compiler-under-test: GCC
Independent-compilers: TCC, Intel
GCC (c. TCC) GCC (c. Intel)
Intel
GCC (c. GCC)
GCC
• Hacker must compromise GCC, TCC and Intel to hack all other compilers to be successful
• O(n2) problem for hackers, O(n) for defenders
SourceGCC
But there are only 3 Go Compilers…
28
1. Google Go Toolchain (gc)
2. Gccgo
• GCC Frontend
• Written in C++
3. Llgo
• LLVM Frontend
Possible Solution?
29
History of Go compiler implementation
30
Released: 19 August 2015
https://golang.org/doc/go1.5#introduction
Go Compiler bootstrapping using Go 1.4
31
Released: 10 December 2014
https://golang.org/doc/install/source#go14
Possible Solution Summary
1. Rebuild Go 1.4 with any C Compiler
2. Build newer version of Go with Go 1.4
• (Malicious) C compiler unlikely to affect Go Compiler
32
C Compiler
Go 1.10 (c. Go 1.4)
Go 1.4 (c. C Comp.)
SourceGo 1.4
SourceGo 1.10
Do you still trust your compiler?
33
By: Yeo Kheng Meng (yeokm1@gmail.com)
https://github.com/yeokm1/reflections-of-trusting-trust-go

More Related Content

PDF
Continuous Integration on my work
PPTX
Auckland Docker Meetup (July 2015) - DockerCon2015 lightningtalk
PDF
OpenAPI and gRPC Side by-Side
PPTX
Values & Culture of Continuous Deliver
PDF
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
PDF
Professional iOS development
PPTX
Continous Delivery and Continous Integration at IKERLAN
PPTX
Develop At The Speed Of Thought
Continuous Integration on my work
Auckland Docker Meetup (July 2015) - DockerCon2015 lightningtalk
OpenAPI and gRPC Side by-Side
Values & Culture of Continuous Deliver
Improving Code Quality In Medical Software Through Code Reviews - Vincit Teat...
Professional iOS development
Continous Delivery and Continous Integration at IKERLAN
Develop At The Speed Of Thought

What's hot (11)

PDF
TopazWroclove2013
PPTX
FISL 2010: CruiseControl: the open source that changed the way we develop sof...
PDF
The parallel universes of DevOps and cloud developers (GlueCon)
PDF
Lecture 12
PPTX
EclipseOMRBuildingBlocks4Polyglot_TURBO18
PPTX
Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...
PDF
Data science, DevOps, and drinks: The perfect combination
PDF
Software Engineering Culture - Improve Code Quality
PDF
Kotlin for Android
PDF
Linux Kernel - Let's Contribute!
PPTX
TYPO3 & Composer
TopazWroclove2013
FISL 2010: CruiseControl: the open source that changed the way we develop sof...
The parallel universes of DevOps and cloud developers (GlueCon)
Lecture 12
EclipseOMRBuildingBlocks4Polyglot_TURBO18
Software Craftsmanship for DevOps professionals - Umesh Kumar / Murughan Pala...
Data science, DevOps, and drinks: The perfect combination
Software Engineering Culture - Improve Code Quality
Kotlin for Android
Linux Kernel - Let's Contribute!
TYPO3 & Composer
Ad

Similar to Reflections on Trusting Trust for Go (20)

PPTX
Reflections on Trusting Trust
PPTX
Comparing C and Go
PDF
Mender.io | Develop embedded applications faster | Comparing C and Golang
PDF
IRJET- An Efficient Hardware-Oriented Runtime Approach for Stack-Based Softwa...
PPTX
The GO Language : From Beginners to Gophers
PDF
Introduction to Go
PDF
Why and what is go
PDF
Go 1.10 Release Party - PDX Go
PDF
Golang
PPTX
Ready, set, go! An introduction to the Go programming language
PDF
Golang workshop
PDF
On the Edge Systems Administration with Golang
PDF
An Introduction to Go
PDF
Why Go Lang?
PDF
Why you should care about Go (Golang)
PPTX
Lab1GoBasicswithgo_foundationofgolang.pptx
PDF
Welcome to Go
PDF
Finding a useful outlet for my many Adventures in go
PDF
Develop Android/iOS app using golang
PDF
Security of Go Modules and Vulnerability Scanning in GoCenter and VS Code
Reflections on Trusting Trust
Comparing C and Go
Mender.io | Develop embedded applications faster | Comparing C and Golang
IRJET- An Efficient Hardware-Oriented Runtime Approach for Stack-Based Softwa...
The GO Language : From Beginners to Gophers
Introduction to Go
Why and what is go
Go 1.10 Release Party - PDX Go
Golang
Ready, set, go! An introduction to the Go programming language
Golang workshop
On the Edge Systems Administration with Golang
An Introduction to Go
Why Go Lang?
Why you should care about Go (Golang)
Lab1GoBasicswithgo_foundationofgolang.pptx
Welcome to Go
Finding a useful outlet for my many Adventures in go
Develop Android/iOS app using golang
Security of Go Modules and Vulnerability Scanning in GoCenter and VS Code
Ad

More from yeokm1 (20)

PPTX
I became a Private Pilot and this is my story
PPTX
What's inside a Cessna 172 and flying a light plane
PPTX
Speaking at Tech meetups/conferences for Junior Devs
PPTX
Meltdown and Spectre
PPTX
Gentoo on a 486
PPTX
BLE Localiser (Full) for iOS Dev Scout
PPTX
BLE Localiser for iOS Conf SG 2017
PPTX
Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiter
PPTX
PCB Business Card (Singapore Power)
PPTX
SP Auto Door Unlocker
PPTX
SP IoT Doorbell
PPTX
Distance Machine Locker
PPTX
A Science Project: Building a sound card based on the Covox Speech Thing
PPTX
A Science Project: Swift Serial Chat
PPTX
The slide rule
PPT
Windows 3.1 (WFW) on vintage and modern hardware
PPTX
Repair Kopitiam Circuit Breaker Training
PPTX
A2: Analog Malicious Hardware
PPTX
Getting Started with Raspberry Pi
PPTX
My Life as a Maker
I became a Private Pilot and this is my story
What's inside a Cessna 172 and flying a light plane
Speaking at Tech meetups/conferences for Junior Devs
Meltdown and Spectre
Gentoo on a 486
BLE Localiser (Full) for iOS Dev Scout
BLE Localiser for iOS Conf SG 2017
Repair Kopitiam Specialty Tools (Part 2): Short Circuit Limiter
PCB Business Card (Singapore Power)
SP Auto Door Unlocker
SP IoT Doorbell
Distance Machine Locker
A Science Project: Building a sound card based on the Covox Speech Thing
A Science Project: Swift Serial Chat
The slide rule
Windows 3.1 (WFW) on vintage and modern hardware
Repair Kopitiam Circuit Breaker Training
A2: Analog Malicious Hardware
Getting Started with Raspberry Pi
My Life as a Maker

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Zenith AI: Advanced Artificial Intelligence
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
STKI Israel Market Study 2025 version august
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PPTX
The various Industrial Revolutions .pptx
PDF
Getting Started with Data Integration: FME Form 101
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...
NewMind AI Weekly Chronicles - August'25-Week II
A comparative study of natural language inference in Swahili using monolingua...
Univ-Connecticut-ChatGPT-Presentaion.pdf
A contest of sentiment analysis: k-nearest neighbor versus neural network
Zenith AI: Advanced Artificial Intelligence
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
A novel scalable deep ensemble learning framework for big data classification...
STKI Israel Market Study 2025 version august
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Web App vs Mobile App What Should You Build First.pdf
Group 1 Presentation -Planning and Decision Making .pptx
1 - Historical Antecedents, Social Consideration.pdf
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
O2C Customer Invoices to Receipt V15A.pptx
The various Industrial Revolutions .pptx
Getting Started with Data Integration: FME Form 101
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Developing a website for English-speaking practice to English as a foreign la...
2021 HotChips TSMC Packaging Technologies for Chiplets and 3D_0819 publish_pu...

Reflections on Trusting Trust for Go

  • 1. Reflections on Trusting Trust for Go 1. Turing Award Lecture (1984) Given by: Ken Thompson https://www.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf 2. Fully Countering Trust through Diverse Double Compiling (2009) By: David A. Wheeler http://www.dwheeler.com/trusting-trust/dissertation/wheeler-trusting-trust-ddc.pdf 1 GopherconSG (4 May 2018) By: Yeo Kheng Meng (yeokm1@gmail.com) https://github.com/yeokm1/reflections-on-trusting-trust-go
  • 3. Why Reflections on Trusting Trust? 3
  • 4. • Ken Thompson (left) and Dennis Ritchie • 1983 Turing award for their work on Unix • Thompson presented “Reflections on Trusting Trust” in his acceptance speech 4
  • 5. 5
  • 6. The problem • How do we know a program is safe? • Inspect the program’s source code. • But isn’t the program source code compiled by a compiler? • Inspect the compiler’s source code, eg. Golang Compiler • https://github.com/golang/go • But isn’t the compiler compiled by another compiler? • Self-hosting compilers compile themselves • -> Eg. Go compiler compiles Go compiler • So how? How deep do we go down the rabbit hole? 6
  • 7. Real-life compiler attacks • Xcodeghost (found Sept 2015) • Malicious Xcode compiler hosted on Chinese websites • Injects spyware into output binary • Win32/Induc.A virus and its successors (found 2009) • Infects Delphi compiler to inject malicious code into output binary • Create a botnet • Further infects other Delphi compilers 7 Xcodeghost image: https://nakedsecurity.sophos.com/2015/11/09/apples-xcodeghost-malware-still-in-the-machine/
  • 8. Attack Objectives 1. Create a malicious compiler to target a program eg: login program 2. Not leave a trace in compiler source 3. Subvert verification 8
  • 9. Presentation Outline 1. Self-reproducing program (Quine) 2. Compiler knowledge propagation (Bootstrapping) 3. Attack on the login program 4. Initial Conclusion 5. Mitigation strategy? 9
  • 10. Stage 1: Self-reproducing program (Quine) A source program that when compiled and executed, will produce as output an exact copy of its source. 10
  • 11. Stage 2: Compiler knowledge propagation •Pass knowledge down compiler iterations 11
  • 12. My ”clean” compiler • ”compiler.go” 1. Reads input source file 2. Prints source file contents to stdout 3. Passes source file to Golang compiler 12
  • 13. 13 My Compiler Binary My Complier Source Code Golang Compiler Hello World Source Code Hello World Binary Hello World (Fetch) Source Code Compiler source that compiles “fetch” Compiler can compile fetch Compiler source that uses “fetch” Latest compilerHello World (Fetch) Binary 1 Hello World (Fetch) Binary 2 Compiler Knowledge Propagation Summary
  • 14. What we have learned so far? • A program can output another program even itself. • Compiler bootstrapping 14
  • 15. Stage 3: Adding an undetectable backdoor to a login program 15
  • 16. 16 Malicious Compiler binary Malicious Compiler Source Code Golang Compiler Clean Compiler Source Code Login Source Code Malicious Login Binary 1 Adding backdoor to login program Still Malicious compiler Malicious Login Binary 2
  • 17. Verifying the compiler binary • Expected SHA-256 of Go 1.10.1 darwin/amd64 compiler • 53b31f87d27bfa88c90789654c9dbec8297a6b157f61076037a85bf0c2687b1d 17
  • 18. Stage 4: Subverting verification • Can we prevent the user from detecting the bugged compiler? 18
  • 20. Thompson’s conclusion • “You can’t trust code that you did not totally create yourself” • “No amount of source-level verification or scrutiny will protect you from using untrusted code.” • “We can go lower to avoid detection like assembler, loader or microcode” • -> You always have to trust somebody 20
  • 22. “Fully Countering Trusting Trust through Diverse Double-Compiling (DDC) - Countering Trojan Horse attacks on Compilers” 2009 PhD dissertation by David A. Wheeler George Mason University http://www.dwheeler.com/trusting-trust/dissertation/wheeler-trusting-trust-ddc.pdf 22
  • 23. Diverse Double Compiling (DDC) • Objective • To detect the trusting-trust attack of a malicious C Compiler • Requirements • Use another compiler in the verification process • Source code of compiler under test needs to be available 23
  • 24. DDC Process • Assume we are have GCC and Tiny C (TCC) compilers • We suspect GCC is malicious and want to test it • Compiler-under-test : GCC • Independent-compiler: TCC • Independent-compiler can be: • Small: just enough code to compile compiler-under-test • Generate inefficient code 24
  • 25. DDC Process 25 TCCSourceGCC Self-regeneration test (Control) Should be identical GCC (c. GCC, c. GCC) GCC (c. GCC, c. TCC) Compiler-under-test: GCC Independent-compiler: TCC GCC (c. TCC)GCC (c. GCC) GCC SourceGCC SourceGCC SourceGCC
  • 26. Why DDC works? • TCC can be malicious but unlikely to be malicious in a way that affects GCC • Hacker must compromise both GCC and TCC to hack each other • Easier to review smaller verifying-compiler source code and binary 26
  • 27. DDC Scaling 27 TCCSourceGCC Self-regeneration test (Control) Should be identical GCC (c. GCC, c. GCC) GCC (c. GCC, c. TCC) GCC (c. GCC, c. Intel) Compiler-under-test: GCC Independent-compilers: TCC, Intel GCC (c. TCC) GCC (c. Intel) Intel GCC (c. GCC) GCC • Hacker must compromise GCC, TCC and Intel to hack all other compilers to be successful • O(n2) problem for hackers, O(n) for defenders SourceGCC
  • 28. But there are only 3 Go Compilers… 28 1. Google Go Toolchain (gc) 2. Gccgo • GCC Frontend • Written in C++ 3. Llgo • LLVM Frontend
  • 30. History of Go compiler implementation 30 Released: 19 August 2015 https://golang.org/doc/go1.5#introduction
  • 31. Go Compiler bootstrapping using Go 1.4 31 Released: 10 December 2014 https://golang.org/doc/install/source#go14
  • 32. Possible Solution Summary 1. Rebuild Go 1.4 with any C Compiler 2. Build newer version of Go with Go 1.4 • (Malicious) C compiler unlikely to affect Go Compiler 32 C Compiler Go 1.10 (c. Go 1.4) Go 1.4 (c. C Comp.) SourceGo 1.4 SourceGo 1.10
  • 33. Do you still trust your compiler? 33 By: Yeo Kheng Meng (yeokm1@gmail.com) https://github.com/yeokm1/reflections-of-trusting-trust-go