Formal verification
- f low-level
Formal verification of low-level execution platforms Roberto - - PowerPoint PPT Presentation
Roberto Guanciale Estonian Winter School Day 01 Formal verification of low-level execution platforms Roberto Guanciale Assistant professor Computer Security Department of Theoretical Computer Science @KTH Research interest in Formal
Assistant professor Computer Security Department of Theoretical Computer Science @KTH Research interest in Formal Verification Enthusiast software developer
A B
500 000 Lines of Code 1 Buffer Overflow Introduced 2012 Discovered 2014
Host 1
Hardware OS Apps
Host 1
Hardware OS Apps
Host 1
Hardware OS Apps
Host 1
Hardware OS Apps
Host 1
Hardware OS Apps
Host 1
Hardware OS Apps Hypervisor Crypto Service
Models Assumptions Verifjcation
∀ s. secure(s)
Models Assumptions Verifjcation CPU MEMORY
Models Assumptions Verifjcation Hypervisor CPU MEMORY
OS
Models Assumptions Verifjcation Hypervisor CPU MEMORY
OS
1) Formal verification 2) CPU models and proof strategy 3) Verification of memory virtualization 4) When the models are incorrect
{P} C {Q} : when the precondition P is met, executing the program C establishes the postcondition Q.
{P} C {Q} : when the precondition P is met, executing the program C establishes the postcondition Q.
{P} C {Q} : when the precondition P is met, executing the program C establishes the postcondition Q. Java Modeling Language (JML)
int SQRT(x) { int r = 0; while (r*r<=x) r++; return r; }
Find the weakest precondition that guarantees that executing the program C establishes the postcondition Q. Then prove P => WP
Find the weakest precondition that guarantees that executing the program C establishes the postcondition Q x:= exp {Q(x)} WP = Q(exp) Example x:= 5 {Q(x) = x > y} WP = Q(5) = 5 > y
Find the weakest precondition that guarantees that executing the program C establishes the postcondition Q. x:= exp {Q(x)} WP = Q(exp) Example x:= y+1 {Q(x) = x > y} WP = Q(y+1) = y+1 > y
Find the weakest precondition that guarantees that executing the program C establishes the postcondition Q. WP (C1; C2, Q) = WP(C1; WP(C2, Q)) Example 1) WP(y:=x+y, y>5) = x+y > 5 2) WP(x:=z+1, x+y > 5) = z+1+y>5
x:=z+1 y:=x+y Q = y > 5
Find the weakest precondition that guarantees that executing the program C establishes the postcondition Q. WP (IF C THEN C1 ELSE C2, Q) = Example x>y => WP(z=x, z >= x /\ z >= y) eq x>y => x >= x /\ x >= y x<=y => WP(z=y, z >= x /\ z >= y) eq x<=y => y >= x /\ y >= y
if (x>y) then z = x else z=y Q: z >= x /\ z >= y
Implementation model Java Classes DFA Specification model Interfaces NFA
Implementation model trace traces Specification model
Implementation model trace traces Specification model
Implementation model trace traces Specification model Trace Inclusion
Implementation model Specification model Trace Inclusion Contract verification Then
Relation
Relation Trace Inclusion Contract verification Property transfer
Relation Trace Inclusion Contract verification Property transfer
Relation Trace Inclusion
K1 and K2 are secret variables (e.g. keys) P1 and P2 are public variables The attacker can invoke the function F F should not leak the value of Ks
int F (P1) { P2 := K1; }
K1 and K2 are secret variables (e.g. keys) P1 and P2 are public variables The attacker can invoke the function F F should not leak the value of Ks
int F (P1) { P2 := K1; }
K1 and K2 are secret variables (e.g. keys) P1 and P2 are public variables The attacker can invoke the function F F should not leak the value of Ks
int F (P1) { P2 := P1; }
K1 and K2 are secret variables (e.g. keys) P1 and P2 are public variables The attacker can invoke the function F F should not leak the value of Ks
int F (P1) { P2 := P1+K1; }
K1 and K2 are secret variables (e.g. keys) P1 and P2 are public variables The attacker can invoke the function F F should not leak the value of Ks
int F (P1) { if (K1 < 10) P2 := P1; }
K1 and K2 are secret variables (e.g. keys) P1 and P2 are public variables The attacker can invoke the function F F should not leak the value of Ks
int F (P1) { if (P1 < 10) P2 := P1; K2 := K1 + P1; }
K1 and K2 are secret variables (e.g. keys) P1 and P2 are public variables
int S() { P := RND()*2; } K:0 P:1 P:0 P:2 P:4 K:1 P:1 P:0 P:2 P:4
int S() { P := RND()*2; } int I() { P := K*2; } K:0 P:1 P:0 P:2 P:4 K:1 P:1 P:0 P:2 P:4
int S() { P := RND()*2; } int I() { P := K*2; } K:0 P:1 P:0 P:2 P:4 K:1 P:1 P:0 P:2 P:4 K:0 P:1 P:0 P:2 P:4
int S() { P := RND()*2; } int I() { P := K*2; } K:0 P:1 P:0 P:2 P:4 K:1 P:1 P:0 P:2 P:4 K:0 P:1 P:0 P:2 P:4 K:1 P:1 P:0 P:2 P:4
Relation Trace Inclusion
Fully automated (propositional logic)
Automated, but not necessarily terminating (first order logic)
With automation, but mainly interactive (higher-order logic)
Isabelle
HOL4
A generic interactive proof assistant
Interactive:
more than just yes/no, you can interactively guide the system
Proof assistant:
helps to explore, find, and maintain proofs
Widely used systems, Active development, Reasonably easy to use
Internal Logic and object logic (HOL)
You can find me at robertog@kth.se http://prosper.sics.se/