Automating Formal Proofs for Reactive Systems
Daniel Ricketts, Valentin Robert, Dongseok Jang, Sorin Lerner
University of California, San Diego University of Washington Zachary βDangerβ Tatlock
Automating Formal Proofs for Reactive Systems Daniel Ricketts , - - PowerPoint PPT Presentation
Automating Formal Proofs for Reactive Systems Daniel Ricketts , Valentin Robert, Zachary Danger Tatlock Dongseok Jang, Sorin Lerner University of California, San Diego University of Washington Proof Assistant Based Verification Proof
Daniel Ricketts, Valentin Robert, Dongseok Jang, Sorin Lerner
University of California, San Diego University of Washington Zachary βDangerβ Tatlock
[Yang et al. PLDI 11]
Testing tool for C compilers
Compiler Bugs Found
[Yang et al. PLDI 11]
Testing tool for C compilers
Compiler Bugs Found GCC 122
[Yang et al. PLDI 11]
Testing tool for C compilers
Compiler Bugs Found GCC 122 Clang/LLVM 181
[Yang et al. PLDI 11]
Testing tool for C compilers
Compiler Bugs Found GCC 122 Clang/LLVM 181 CompCert ?
[Yang et al. PLDI 11]
Testing tool for C compilers
Compiler Bugs Found GCC 122 Clang/LLVM 181 CompCert
[Yang et al. PLDI 11]
Testing tool for C compilers
Compiler Bugs Found GCC 122 Clang/LLVM 181 CompCert
[Yang et al. PLDI 11]
Testing tool for C compilers
[Le et al. PLDI 14]
Proof Assistant
Proof Assistant
Coq Theorem Prover
Code
Proof Assistant
Code
Proof Assistant
in language supporting reasoning
Code Spec
Proof Assistant
Code Spec
Proof Assistant
logical properties characterizing correctness
Code Spec
Proof Assistant Grads
Code Spec
Proof Assistant Grads
interactively show code satisfies specification
Code Spec
Proof Assistant Grads
ML x86
Code Spec
Proof Assistant Grads
ML x86 compile down to machine code
Code Spec
Proof Assistant
Extremely strong guarantees about actual system!
Grads
ML x86
Verified Compiler: CompCert
[Leroy POPL 06]
Verified Compiler: CompCert Verified OS micro-kernel: seL4
[Leroy POPL 06] [Klein et al. SOSP 09]
Verified Compiler: CompCert Verified OS micro-kernel: seL4 Verified Web browser: Quark
[Leroy POPL 06] [Klein et al. SOSP 09] [Jang et al. Security 12]
Code Spec Proof
Code Spec Proof
Code Spec Proof
Code Spec Proof
Code Spec Proof
Requires expertise in proof assistants Code Spec Proof
Requires expertise in proof assistants Extremely brittle, maintenance burden Code Spec Proof
Code Spec Proof
Code Spec
(no manual proofs)
Code1 Spec1 Proof1
Code1 Spec1 Proof1 Code2 Spec2 Proof2
Code1 Spec1 Proof1 Code2 Spec2 Proof2 Code3 Spec3 Proof3
Code1 Spec1 Proof1 Code2 Spec2 Proof2 Code3 Spec3 Proof3
Similar properties
Code1 Spec1 Proof1 Code2 Spec2 Proof2 Code3 Spec3 Proof3
Similar properties Similar architecture
Code1 Spec1 Proof1 Code2 Spec2 Proof2 Code3 Spec3 Proof3
Similar properties Similar architecture Similar reasoning
Code1 Spec1 Proof1 Code2 Spec2 Proof2 Code3 Spec3 Proof3
Similar properties
DSL for Specs
Code1 Spec1 Proof1 Code2 Spec2 Proof2 Code3 Spec3 Proof3
Similar properties
DSL for Specs
Similar architecture Similar reasoning
Code1 Spec1 Proof1 Code2 Spec2 Proof2 Code3 Spec3 Proof3
Similar properties Similar architecture
DSL for Specs DSL for Code
Code1 Spec1 Proof1 Code2 Spec2 Proof2 Code3 Spec3 Proof3
Similar properties Similar architecture
DSL for Specs DSL for Code
Similar reasoning
Code1 Spec1 Proof1 Code2 Spec2 Proof2 Code3 Spec3 Proof3
Similar properties Similar architecture Similar reasoning
DSL for Specs DSL for Code Proof Automation
DSL for Specs DSL for Code Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3
DSL for Specs DSL for Code Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3
DSL for Specs DSL for Code Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3 Proof1 Proof2 Proof3
Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3 Proof1 Proof2 Proof3 DSL for Specs DSL for Code
Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3 Proof1 Proof2 Proof3 DSL for Specs DSL for Code
Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3 Proof1 Proof2 Proof3 DSL for Specs DSL for Code REFLEX
Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3 Proof1 Proof2 Proof3 DSL for Specs DSL for Code REFLEX
No manual proofs,
Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3 Proof1 Proof2 Proof3 DSL for Specs DSL for Code REFLEX
No manual proofs, yet proof assistant guarantee.
Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3 Proof1 Proof2 Proof3 DSL for Specs DSL for Code REFLEX
No manual proofs, yet proof assistant guarantee. Automation incomplete,
Proof Automation Code1 Spec1 Code2 Spec2 Code3 Spec3 Proof1 Proof2 Proof3 DSL for Specs DSL for Code REFLEX
No manual proofs, yet proof assistant guarantee. Automation incomplete, but verified browser, ssh, web server.
Reactive system
Reactive system
Continuously read messages from components and send messages to components
Reactive system
Kernel
Kernel Tab3
Tab2
gmail
Tab1
Kernel Tab3
Tab2
gmail
Tab1
Cookie Manager
Cookie Manager
Kernel Tab3
Tab2
gmail
Tab1
Cookie Manager
Cookie Manager
Kernel Tab3
Tab2
gmail
Tab1
Cookie Manager
Cookie Manager
(1) Tabs request resources (e.g. cookies)
Kernel Tab3
Tab2
gmail
Tab1
Cookie Manager
Cookie Manager
(2) Kernel grants access subject to access controls (e.g. domain checks) (1) Tabs request resources (e.g. cookies)
Components = Tab | CookieMgr | ...
Types of components
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ...
Types of messages
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers:
How the kernel responds to messages from components
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c):
When tab t sends the kernel a CookieSet message with payload c
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain)
Get existing cookie manager with domain of t or spawn a new one
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Send the cookie c to the found cookie manager
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
More handlers
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
Specify allowed behaviors
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
Specify allowed behaviors wrt sequence of system calls
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
Specify allowed behaviors wrt sequence of system calls
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ... When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
Time
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
β¦
Time
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
β¦
Time
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
[Tab t] sends CookieSet(c)
β¦
Time
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
Time
β¦
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
Recv(Tab, CookieSet(c))
Time
β¦
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
Recv(Tab, CookieSet(c)) cp <- find CookieMgr(t.domain)
Time
β¦
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
Recv(Tab, CookieSet(c))
Time
β¦
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
Recv(Tab, CookieSet(c)) Spawn CookieMgr(t.domain)
Time
β¦
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
Recv(Tab, CookieSet(c)) Spawn CookieMgr(t.domain) send(cp, CookieSet(c))
Time
β¦
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
Recv(Tab, CookieSet(c)) Spawn CookieMgr(t.domain)
Time
β¦
When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Specify allowed behaviors wrt sequence of system calls
The system calls so far
Recv(Tab, CookieSet(c)) Spawn CookieMgr(t.domain) Send(cp, CookieSet(c))
Time
β¦
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ... When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c))
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
Specify cookie integrity
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c,
For any domain d and cookie c
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Send(CookieMgr(d), CookieSet(c))]
The kernel sends the cookie manager for domain d a cookie c
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, Enables [Send(CookieMgr(d), CookieSet(c))]
Only if
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Recv(Tab(d), CookieSet(c))] Enables [Send(CookieMgr(d), CookieSet(c))]
The kernel already received a cookie c from a tab of domain d
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Recv(Tab(d), CookieSet(c))] Enables [Send(CookieMgr(d), CookieSet(c))] A Enables B
iff every sys call B is preceded by sys call A
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Recv(Tab(d), CookieSet(c))] Enables [Send(CookieMgr(d), CookieSet(c))]
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Recv(Tab(d), CookieSet(c))] Enables [Send(CookieMgr(d), CookieSet(c))]
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Recv(Tab(d), CookieSet(c))] Enables [Send(CookieMgr(d), CookieSet(c))]
REFLEX Benefits:
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Recv(Tab(d), CookieSet(c))] Enables [Send(CookieMgr(d), CookieSet(c))]
REFLEX Benefits: Proofs fully automated
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Recv(Tab(d), CookieSet(c))] Enables [Send(CookieMgr(d), CookieSet(c))]
REFLEX Benefits: Proofs fully automated No lemmas
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Recv(Tab(d), CookieSet(c))] Enables [Send(CookieMgr(d), CookieSet(c))]
REFLEX Benefits: Proofs fully automated No lemmas No invariants
Components = Tab | CookieMgr | ... Messages = CookieSet | CookieGet | ... Handlers: When [Tab t] sends CookieSet(c): cp <- find CookieMgr(t.domain) send(cp, CookieSet(c)) When [Tab t] sends CookieGet(c): ...
forall d c, [Recv(Tab(d), CookieSet(c))] Enables [Send(CookieMgr(d), CookieSet(c))]
REFLEX Benefits: Proofs fully automated No lemmas No invariants No manual proofs
Prove kernel code satisfies properties
Prove kernel code satisfies properties
by induction on sys call sequences kernel can produce
Prove kernel code satisfies properties
by induction on sys call sequences kernel can produce
Prove kernel code satisfies properties
by induction on sys call sequences kernel can produce
Handler
Prove kernel code satisfies properties
by induction on sys call sequences kernel can produce
Handler
Handler
Prove kernel code satisfies properties
by induction on sys call sequences kernel can produce
Handler
Handler
Handler
Prove kernel code satisfies properties
by induction on sys call sequences kernel can produce
Handler
Handler
Handler Handlers create structure for induction
Prove kernel code satisfies properties
by induction on sys call sequences kernel can produce
β
Induction hypothesis: property holds up to this point
Prove kernel code satisfies properties
by induction on sys call sequences kernel can produce
β
Run a single handler
Prove kernel code satisfies properties
Induction hypothesis: property holds up to this point
by induction on sys call sequences kernel can produce
β
Proof obligation: does property still hold?
Prove kernel code satisfies properties
Induction hypothesis: property holds up to this point
by induction on sys call sequences kernel can produce
β
Prove kernel code satisfies properties
Induction hypothesis: property holds up to this point Proof obligation: does property still hold?
by induction on sys call sequences kernel can produce
Case analysis on handler
β
Prove kernel code satisfies properties
Induction hypothesis: property holds up to this point Proof obligation: does property still hold?
by induction on sys call sequences kernel can produce
Case analysis on handler Symbolically run all paths
β
Case analysis on handler Symbolically run all paths Prove automatically
Prove kernel code satisfies properties
Induction hypothesis: property holds up to this point Proof obligation: does property still hold?
by induction on sys call sequences kernel can produce
Single domain insights:
Single domain insights:
Small number of carefully designed property primitives
Single domain insights:
Small number of carefully designed property primitives Loop free handlers allowed symbolic eval of all paths
Single domain insights:
Small number of carefully designed property primitives Loop free handlers allowed symbolic eval of all paths Domain-specific heuristics for non-local reasoning
Web browser SSH server Web server
Web browser SSH server Web server
Auto verified 33 properties (80% in < 2 minutes)
Web browser SSH server Web server Domains do not interfere, Cookie integrity, β¦ No PTY access before authentication, At most 3 authentication attempts, β¦ Clients only spawned after successful login, File requests guarded by access control, β¦
Auto verified 33 properties (80% in < 2 minutes)
Web browser SSH server Web server Domains do not interfere, Cookie integrity, β¦ No PTY access before authentication, At most 3 authentication attempts, β¦ Clients only spawned after successful login, File requests guarded by access control, β¦
Auto verified 33 properties (80% in < 2 minutes) Able to automate proofs of non- interference
Web browser SSH server Web server Domains do not interfere, Cookie integrity, β¦ No PTY access before authentication, At most 3 authentication attempts, β¦ Clients only spawned after successful login, File requests guarded by access control, β¦
Auto verified 33 properties (80% in < 2 minutes)
Web browser SSH server Web server Domains do not interfere, Cookie integrity, β¦ No PTY access before authentication, At most 3 authentication attempts, β¦ Clients only spawned after successful login, File requests guarded by access control, β¦
Auto verified 33 properties (80% in < 2 minutes) Able to automate proofs of non-local properties
7500 lines of Coq
7500 lines of Coq
Web browser SSH server Web server
7500 lines of Coq
5500 lines of Coq
Web browser SSH server Web server
7500 lines of Coq
5500 lines of Coq
Single reactive system
Web browser SSH server Web server
7500 lines of Coq
5500 lines of Coq
Single reactive system Many reactive systems
Web browser SSH server Web server
Benchmark Language Lines of Code/Spec Browser REFLEX 81 37 C++, Python 970,240
REFLEX 64 22 C, Python 89,567
REFLEX 56 29 Python 386
Benchmark Language Lines of Code/Spec Browser REFLEX 81 37 C++, Python 970,240
REFLEX 64 22 C, Python 89,567
REFLEX 56 29 Python 386
Benchmark Language Lines of Code/Spec Browser REFLEX 81 37 C++, Python 970,240
REFLEX 64 22 C, Python 89,567
REFLEX 56 29 Python 386
OpenSSH
Expressiveness: Incompleteness:
Expressiveness:
Strict subset of temporal logic + non-interference
Incompleteness:
Expressiveness:
Strict subset of temporal logic + non-interference Loop free handlers
Incompleteness:
Expressiveness:
Strict subset of temporal logic + non-interference Loop free handlers No user-defined unbounded data structures
Incompleteness:
Expressiveness:
Strict subset of temporal logic + non-interference Loop free handlers No user-defined unbounded data structures
Incompleteness:
Unable to infer some inductive invariants
Expressiveness:
Strict subset of temporal logic + non-interference Loop free handlers No user-defined unbounded data structures
Incompleteness:
Unable to infer some inductive invariants Low level incompleteness in automation tactics
TODO: Browser/SSH video
TODO: Browser/SSH video
Automation Expressiveness
Proof assistant based verification
Automation Expressiveness Coq
Proof assistant based verification
Automation Expressiveness Ynot Coq
Proof assistant based verification
Automation Expressiveness Bedrock Ynot Coq
Proof assistant based verification
Automation Expressiveness Bedrock Ynot Coq Reflex
Proof assistant based verification
Reflex
Reflex
DSL expressive enough for entire domain
Reflex
DSL expressive enough for entire domain Automation eliminates manual proof burden
Reflex
DSL expressive enough for entire domain Automation eliminates manual proof burden http://goto.ucsd.edu/reflex/
Reflex
DSL expressive enough for entire domain Automation eliminates manual proof burden http://goto.ucsd.edu/reflex/