Unleash Your Potential - Namagunga Girls Coding Club
DEF CON 27 - ANISH ATHALYE - Strong Isolation
1. Want strong isolation?
Just reset your processor.
How we can build more secure systems by applying
the age-old wisdom of “turning it off and on again”
Anish Athalye, Adam Belay, Frans Kaashoek, Robert Morris, Nickolai Zeldovich
5. Can we make the PC secure instead?
5
• Endless bugs:
• Application bugs
• OS bugs (kernels > 20M LOC)
• Micro-architectural CPU bugs (Spectre, Meltdown, Foreshadow, Zombieload)
• Hardware bugs (Rowhammer, RAMBleed)
13. Sharing results in isolation bugs
• Some past wallet bugs
• Bad argument validation in syscalls
• Bad configuration of MPU
[Riscure @ Black Hat 2018; Ledger Blog;
Trezor Blog]
13
USB
SoC:
CPU+RAM,
Flash,
Peripherals
Buttons
Display
24. Purging state in a CPU, final attempt
24
reset!
+
mov r0, #0
mov r1, #0
mov r2, #0
...
// do things that end up
// clearing internal state
...
These instructions affect
micro-architectural state
}
Check against CPU implementation
25. How do we know that reset is correct?
25
Arbitrary state
Reset / purge
Purged state
26. How do we know that reset is correct?
26
State (secret = 0)
Reset / purge
(Same) purged state
State (secret = 1)
27. Tool: Satisfiability Modulo Theories (SMT)
27
(x AND y) OR (NOT z) SAT: {x = False, y = False, z = False}
(x AND y) AND ((NOT x) AND z) UNSAT
SAT solvers
SMT: SAT on steroids
x: Int, y: Int
x + y < 1 AND x + 1 = 3 AND y > 0
x: BitVec(8)
x > 0 AND x + 1 < 0
UNSAT
SAT: {x = 127}
28. SMT solvers as theorem provers
28
Theorem: forall x, P(x)
SAT => theorem is false
A counterexample to our
theorem: an x where NOT (P(x))
UNSAT => theorem is proven
A proof that our theorem holds: because
there is no x that makes NOT (P(x)) true,
P(x) must hold for all x
NOT (P(x))
Mechanical translation to SMT formula:
strip foralls, negate proposition
29. SMT solvers as theorem provers
29
Theorem: forall x y : Real,
min(x, y) <= (x + y)/2 <= max(x, y)
NOT [ min(x, y) <= (x + y)/2 <= max(x, y) ]
>>> from z3 import *
>>> x = Real('x'); y = Real('y'); s = Solver()
>>> Min = z3.If(x < y, x, y)
>>> Max = z3.If(x < y, y, x)
>>> avg = (x + y)/2
>>> theorem = And(Min <= avg, avg <= Max)
>>> s.add(Not(theorem))
>>> s.check()
unsat
36. Converting CPU implementation to SMT
36
Python / Z3 SMT model:
Describes 1 cycle of CPU execution
Verilog implementation:
Gate-level design of CPU
mechanical
translation