Verifying security invariants in ExpressOS
Haohui Mai, Edgar Pek, Hui Xue, Samuel T. King, P . Madhusudan University of Illinois at Urbana-Champaign
Verifying security invariants in ExpressOS Haohui Mai, Edgar Pek, - - PowerPoint PPT Presentation
Verifying security invariants in ExpressOS Haohui Mai, Edgar Pek, Hui Xue, Samuel T. King, P . Madhusudan University of Illinois at Urbana-Champaign Mobiles devices are powerful Security of mobile devices is important High value
Haohui Mai, Edgar Pek, Hui Xue, Samuel T. King, P . Madhusudan University of Illinois at Urbana-Champaign
persistent storage from
system
Device driver File system
Kernel
persistent storage from
system
Device driver File system
Kernel
Device driver File system
Kernel
Device driver File system
Kernel
Device driver File system
Kernel
Device driver File system
Kernel
Device driver File system
Kernel
Hardware Microkernel FS ... Driver Application Net Pager Application
abstractions
semantics
Hardware Microkernel FS ... Driver Application Net Pager Application
abstractions
semantics
Hardware Microkernel FS ... Driver Application Net Pager Application
requirements as security invariants
requirements as security invariants
requirements as security invariants
reasonable verification effort
Hardware Android apps Android apps Drivers Storage Window mgnt. Network
...
ExpressOS Android syscalls Runtime L4
semantics
syscalls
Hardware Android apps Android apps Drivers Storage Window mgnt. Network
...
ExpressOS Android syscalls Runtime L4
semantics
syscalls
components cannot subvert the security invariants
Hardware Android apps Android apps Drivers Storage Window mgnt. Network
...
ExpressOS Android syscalls Runtime L4
be isolated from other applications and the system
Device driver File system
Kernel
Device driver File system
ExpressOS kernel
provides file APIs to applications
Device driver File system
ExpressOS kernel
provides file APIs to applications
and integrity using HMAC and encryption
are used correctly
Device driver File system
ExpressOS kernel
provides file APIs to applications
and integrity using HMAC and encryption
are used correctly
algorithms
algorithms
algorithms
algorithms
Code Contracts Dafny Power Restricted
(abstract interpretation)
Expressive
(SMT solvers like Z3)
Annota
burden
Low
(~0.01 lines per LOC)
High
(5~6 lines per LOC)
x Too much work
Code Contracts Dafny Power Restricted
(abstract interpretation)
Expressive
(SMT solvers like Z3)
Annota
burden
Low
(~0.01 lines per LOC)
High
(5~6 lines per LOC)
x Too much work
x Incomplete
Code Contracts Dafny Power Restricted
(abstract interpretation)
Expressive
(SMT solvers like Z3)
Annota
burden
Low
(~0.01 lines per LOC)
High
(5~6 lines per LOC)
x Too much work
x Incomplete
✓ Practical
Code Contracts Dafny Power Restricted
(abstract interpretation)
Expressive
(SMT solvers like Z3)
Annota
burden
Low
(~0.01 lines per LOC)
High
(5~6 lines per LOC)
class%Foo%{ %%int%m; %%void%Increment()%{ %%%%++m; %%} }
class%Foo%{ %%int%m; %%void%Increment()%{ %%%%++m; %%} }
Assertion Contract.Assert(...);
class%Foo%{ %%int%m; %%void%Increment()%{ %%%%++m; %%} }
Assertion Contract.Assert(...); Post-condition Contract.Ensures(m == Contract.Old(m) + 1); Pre-condition Contract.Requires(m > 0);
var%Head:%Foo; void%IncAll()%{ %%var%p%:=%Head; %%while%(p%!=%null)%{ %%%%p.Increment();%p%:=%p.Next; %%} }
var%Head:%Foo; void%IncAll()%{ %%var%p%:=%Head; %%while%(p%!=%null)%{ %%%%p.Increment();%p%:=%p.Next; %%} }
assert ∀x, x∈C → x ≠ null ∧ x.m == old(x.m) + 1;
var%Head:%Foo; void%IncAll()%{ %%var%p%:=%Head; %%while%(p%!=%null)%{ %%%%p.Increment();%p%:=%p.Next; %%} }
assert ∀x, x∈C → x ≠ null ∧ x.m == old(x.m) + 1;
Ghost code code for verification only
var%Head:%Foo; void%IncAll()%{ %%var%p%:=%Head; %%while%(p%!=%null)%{ %%%%p.Increment();%p%:=%p.Next; %%} }
ghost var C :seq<Foo>; assert ∀x, x∈C → x ≠ null ∧ x.m == old(x.m) + 1; ghost var i := 0; i := i + 1; invariant C[i] == p ∧ p.Next == C[i+1]; ....
Ghost code code for verification only
class%FilePage%{ enum%State%{%Empty,% Authentic,%Decrypted,% Encrypted%} [Ghost]%State%S; void%Decrypt(...)%{ %%Contract.Requires(S%==% State.Authentic); %%Contract.Ensures(S%==% State.Decrypted);%... } ...
the state of the page
specification
class%FilePage%{ enum%State%{%Empty,% Authentic,%Decrypted,% Encrypted%} [Ghost]%State%S; void%Decrypt(...)%{ %%Contract.Requires(S%==% State.Authentic); %%Contract.Ensures(S%==% State.Decrypted);%... } ...
the state of the page
specification
model the state transitions
class%FilePage%{ enum%State%{%Empty,% Authentic,%Decrypted,% Encrypted%} [Ghost]%State%S; void%Decrypt(...)%{ %%Contract.Requires(S%==% State.Authentic); %%Contract.Ensures(S%==% State.Decrypted);%... } ...
class%FilePage%{ %%... %%void%Flush(...)%{ %%%%Contract.Requires(S%==% State.Encrypted); %%%... %%} }
before sending it to FS / drivers
and bring it into the application’s memory only if the application has proper accesses to the file.
pager
at the point of assertions
pager
?
at the point of assertions
paging in different execution contexts
pager
?
pager
properties always hold for the object
pager
properties always hold for the object
pager
It can only contain files that the pager has access to (i.e.,
properties always hold for the object
pager
It can only contain files that the pager has access to (i.e.,
properties always hold for the object
pager
locally
It can only contain files that the pager has access to (i.e.,
uint%HandlePageFault(Process% p,%Pointer%addr,%...)%{ ... var%r%=%p.Space.Find(addr); ... if%(r.File%!=%null)%{ %%var%r%=%r.File.Read(...); %%... } }
uint%HandlePageFault(Process% p,%Pointer%addr,%...)%{ ... var%r%=%p.Space.Find(addr); ... if%(r.File%!=%null)%{ %%var%r%=%r.File.Read(...); %%... } }
Security Invariant Contract.Assert(r.File. GhostOwner == p);
uint%HandlePageFault(Process% p,%Pointer%addr,%...)%{ ... var%r%=%p.Space.Find(addr); ... if%(r.File%!=%null)%{ %%var%r%=%r.File.Read(...); %%... } }
Security Invariant Contract.Assert(r.File. GhostOwner == p); ensures r≠null→r.ObjInvariant() ∧ r.GhostOwner == GhostOwner;
uint%HandlePageFault(Process% p,%Pointer%addr,%...)%{ ... var%r%=%p.Space.Find(addr); ... if%(r.File%!=%null)%{ %%var%r%=%r.File.Read(...); %%... } }
Security Invariant Contract.Assert(r.File. GhostOwner == p); ensures r≠null→r.ObjInvariant() ∧ r.GhostOwner == GhostOwner;
File≠null→File.GhostOwner == GhostOwner ... r.File.GhostOwner == r.GhostOwner == space.GhostOwner == p Space.GhostOwner == this
class%AddressSpace%{ %%var%GhostOwner:%Process; %%var%Head:%MemoryRegion; %%... %%method%Find(address:% Pointer) %%returns%(ret:%MemoryRegion) %%requires%ObjInvariant(); %%ensures%ObjInvariant(); }
ensures r≠null→r.ObjInvariant() ∧ r.GhostOwner == GhostOwner;
class%AddressSpace%{ %%var%GhostOwner:%Process; %%var%Head:%MemoryRegion; %%... %%method%Find(address:% Pointer) %%returns%(ret:%MemoryRegion) %%requires%ObjInvariant(); %%ensures%ObjInvariant(); }
ensures r≠null→r.ObjInvariant() ∧ r.GhostOwner == GhostOwner;
ghost variables Assume() Dafny C# + code contracts
... [Ghost]%Foo%GhostOwner; Find(...)%{ ... Assume(...); ... }
invariants
invariants
(isolation & end-to- end mechanisms)
invariants
(isolation & end-to- end mechanisms)
(object invariants vs async contexts)
invariants
(isolation & end-to- end mechanisms)
(object invariants vs async contexts)
Line of code Full system 13M Linux kernel 1M ExpressOS 15,932 Annotation 438
concepts of ownerships
implement system services
microkernel server
Android web browser and this presentation
Hardware Android apps Android apps Drivers Storage Window mgnt. Network
...
ExpressOS Android syscalls Runtime L4
vulnerabilities from CVE (from Jun, 2011~Jun, 2012)
Android
(95%) of them
Num Prevented Core kernel 9 9 Library of apps 102 102 Services 240 226 Applications 32 27
1250 2500 3750 5000 A m a z
A n d r
d C r a i g s l i s t E b a y F a c e b
G
l e W i k i p e d i a W
d p r e s s Y a h
Android-x86 L4Android ExpressOS
Android applications
Android applications
Android applications
Android applications
Android applications
assurance in real-world systems
Source code available at: https://github.com/ExpressOS/expressos