Verifying security invariants in ExpressOS Haohui Mai, Edgar Pek, - - PowerPoint PPT Presentation

verifying security invariants in expressos
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Verifying security invariants in ExpressOS

Haohui Mai, Edgar Pek, Hui Xue, Samuel T. King, P . Madhusudan University of Illinois at Urbana-Champaign

slide-2
SLIDE 2

Mobiles devices are powerful

slide-3
SLIDE 3

Security of mobile devices is important

  • High value targets on mobile devices
slide-4
SLIDE 4

Security of mobile devices is important

  • High value targets on mobile devices
 

 

        



                               
slide-5
SLIDE 5

Security of mobile devices is important

  • High value targets on mobile devices
 

 

        



                               
slide-6
SLIDE 6

Security of mobile devices is important

  • High value targets on mobile devices
 

 

        



                               
slide-7
SLIDE 7

Security of mobile devices is important

  • High value targets on mobile devices
 

 

        



                               

?

slide-8
SLIDE 8

Motivating example

                       
slide-9
SLIDE 9

Motivating example

                       
slide-10
SLIDE 10

Motivating example

  • Isolate the application’s

persistent storage from

  • other applications
  • components of the

system

                       

Device driver File system

Kernel

slide-11
SLIDE 11

Motivating example

  • Isolate the application’s

persistent storage from

  • other applications
  • components of the

system

                       

Device driver File system

Kernel

  • Immediately meaningful
slide-12
SLIDE 12

ROOTED

slide-13
SLIDE 13                                                                

Wide attack surfaces

                       

Device driver File system

Kernel

slide-14
SLIDE 14                                                                

Wide attack surfaces

                       

Device driver File system

Kernel

slide-15
SLIDE 15                                                                

Wide attack surfaces

                       

Device driver File system

Kernel

slide-16
SLIDE 16                                                                

Wide attack surfaces

                       

Device driver File system

Kernel

slide-17
SLIDE 17                                                                

Wide attack surfaces

                       

Device driver File system

Kernel

slide-18
SLIDE 18

Microkernel is not enough

Hardware Microkernel FS ... Driver Application Net Pager Application

slide-19
SLIDE 19

Microkernel is not enough

  • Low-level

abstractions

  • v.s. application

semantics

Hardware Microkernel FS ... Driver Application Net Pager Application

slide-20
SLIDE 20

Microkernel is not enough

  • Low-level

abstractions

  • v.s. application

semantics

  • Shared services

Hardware Microkernel FS ... Driver Application Net Pager Application

slide-21
SLIDE 21

ExpressOS: a high assurance OS that runs Android apps

slide-22
SLIDE 22
  • Capture application-level security

requirements as security invariants

ExpressOS: a high assurance OS that runs Android apps

slide-23
SLIDE 23
  • Capture application-level security

requirements as security invariants

  • Verify security invariants directly
  • NOT from full functional correctness

ExpressOS: a high assurance OS that runs Android apps

slide-24
SLIDE 24
  • Capture application-level security

requirements as security invariants

  • Verify security invariants directly
  • NOT from full functional correctness
  • Formally verified security guarantees with

reasonable verification effort

ExpressOS: a high assurance OS that runs Android apps

slide-25
SLIDE 25
  • Introduction
  • Verifying security invariants
  • Experience
  • Conclusion
slide-26
SLIDE 26

Design tailored for verification

Hardware Android apps Android apps Drivers Storage Window mgnt. Network

...

ExpressOS Android syscalls Runtime L4

slide-27
SLIDE 27

Design tailored for verification

  • Understand application

semantics

  • Provides Android/Linux-like

syscalls

Hardware Android apps Android apps Drivers Storage Window mgnt. Network

...

ExpressOS Android syscalls Runtime L4

slide-28
SLIDE 28

Design tailored for verification

  • Understand application

semantics

  • Provides Android/Linux-like

syscalls

  • Bugs in unverified

components cannot subvert the security invariants

  • Microkernel
  • Type safety (C# + Dafny)

Hardware Android apps Android apps Drivers Storage Window mgnt. Network

...

ExpressOS Android syscalls Runtime L4

slide-29
SLIDE 29
  • Secure storage
  • Memory isolation

Security invariants

                       
  • UI isolation
  • Secure IPC
slide-30
SLIDE 30
  • Secure storage
  • Memory isolation

Security invariants

                       
  • UI isolation
  • Secure IPC
slide-31
SLIDE 31

Secure storage

  • The persistent storage
  • f an application should

be isolated from other applications and the system

                       

Device driver File system

Kernel

slide-32
SLIDE 32

Device driver File system

ExpressOS kernel

Secure storage

  • ExpressOS kernel

provides file APIs to applications

                       
slide-33
SLIDE 33

Device driver File system

ExpressOS kernel

Secure storage

  • ExpressOS kernel

provides file APIs to applications

  • Enforce confidentiality

and integrity using HMAC and encryption

  • Verify these primitives

are used correctly

                       
slide-34
SLIDE 34

Device driver File system

ExpressOS kernel

Secure storage

  • ExpressOS kernel

provides file APIs to applications

  • No trusts on FS / drivers
  • Enforce confidentiality

and integrity using HMAC and encryption

  • Verify these primitives

are used correctly

                       
slide-35
SLIDE 35

Assumptions

slide-36
SLIDE 36

Assumptions

  • The implementation of cryptographic

algorithms

slide-37
SLIDE 37

Assumptions

  • The implementation of cryptographic

algorithms

  • L4 and the language run-time
slide-38
SLIDE 38

Assumptions

  • The implementation of cryptographic

algorithms

  • L4 and the language run-time
  • Correct specifications
slide-39
SLIDE 39

Assumptions

  • The implementation of cryptographic

algorithms

  • L4 and the language run-time
  • Correct specifications
  • Do not cover covert channels
slide-40
SLIDE 40

Tools for verification

slide-41
SLIDE 41

Tools for verification

Code Contracts Dafny Power Restricted

(abstract interpretation)

Expressive

(SMT solvers like Z3)

Annota

  • tion

burden

Low

(~0.01 lines per LOC)

High

(5~6 lines per LOC)

slide-42
SLIDE 42

Tools for verification

  • Dafny only

x Too much work

Code Contracts Dafny Power Restricted

(abstract interpretation)

Expressive

(SMT solvers like Z3)

Annota

  • tion

burden

Low

(~0.01 lines per LOC)

High

(5~6 lines per LOC)

slide-43
SLIDE 43

Tools for verification

  • Dafny only

x Too much work

  • Code contract(CC) only

x Incomplete

Code Contracts Dafny Power Restricted

(abstract interpretation)

Expressive

(SMT solvers like Z3)

Annota

  • tion

burden

Low

(~0.01 lines per LOC)

High

(5~6 lines per LOC)

slide-44
SLIDE 44

Tools for verification

  • Dafny only

x Too much work

  • Code contract(CC) only

x Incomplete

  • Dafny + code contracts

✓ Practical

Code Contracts Dafny Power Restricted

(abstract interpretation)

Expressive

(SMT solvers like Z3)

Annota

  • tion

burden

Low

(~0.01 lines per LOC)

High

(5~6 lines per LOC)

slide-45
SLIDE 45

Example of code contracts

class%Foo%{ %%int%m; %%void%Increment()%{ %%%%++m; %%} }

slide-46
SLIDE 46

Example of code contracts

class%Foo%{ %%int%m; %%void%Increment()%{ %%%%++m; %%} }

Assertion Contract.Assert(...);

slide-47
SLIDE 47

Example of code contracts

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);

slide-48
SLIDE 48

Example of Dafny

var%Head:%Foo; void%IncAll()%{ %%var%p%:=%Head; %%while%(p%!=%null)%{ %%%%p.Increment();%p%:=%p.Next; %%} }

slide-49
SLIDE 49

Example of Dafny

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;

slide-50
SLIDE 50

Example of Dafny

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

slide-51
SLIDE 51

Example of Dafny

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

slide-52
SLIDE 52

Checking that all data is encrypted using ghost variables

class%FilePage%{ enum%State%{%Empty,% Authentic,%Decrypted,% Encrypted%} [Ghost]%State%S; void%Decrypt(...)%{ %%Contract.Requires(S%==% State.Authentic); %%Contract.Ensures(S%==% State.Decrypted);%... } ...

slide-53
SLIDE 53

Checking that all data is encrypted using ghost variables

  • Ghost variable S records

the state of the page

  • Parts of the

specification

class%FilePage%{ enum%State%{%Empty,% Authentic,%Decrypted,% Encrypted%} [Ghost]%State%S; void%Decrypt(...)%{ %%Contract.Requires(S%==% State.Authentic); %%Contract.Ensures(S%==% State.Decrypted);%... } ...

slide-54
SLIDE 54

Checking that all data is encrypted using ghost variables

  • Ghost variable S records

the state of the page

  • Parts of the

specification

  • Pre-/post-conditions

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);%... } ...

slide-55
SLIDE 55

Checking that all data is encrypted using ghost variables

class%FilePage%{ %%... %%void%Flush(...)%{ %%%%Contract.Requires(S%==% State.Encrypted); %%%... %%} }

  • Encrypt all data

before sending it to FS / drivers

slide-56
SLIDE 56

Memory isolation

  • The pager can read a file

and bring it into the application’s memory only if the application has proper accesses to the file.

slide-57
SLIDE 57

Challenge: asynchronous execution

slide-58
SLIDE 58

Challenge: asynchronous execution

  • pen/mmap
slide-59
SLIDE 59

Challenge: asynchronous execution

  • pen/mmap
slide-60
SLIDE 60

Challenge: asynchronous execution

  • pen/mmap
slide-61
SLIDE 61

Challenge: asynchronous execution

  • pen/mmap

pager

slide-62
SLIDE 62

Challenge: asynchronous execution

  • Insufficient information

at the point of assertions

  • pen/mmap

pager

?

slide-63
SLIDE 63

Challenge: asynchronous execution

  • Insufficient information

at the point of assertions

  • Permission checks and

paging in different execution contexts

  • pen/mmap

pager

?

slide-64
SLIDE 64

Solution: strengthen object invariants

  • pen/mmap

pager

slide-65
SLIDE 65

Solution: strengthen object invariants

  • Object invariants:

properties always hold for the object

  • pen/mmap

pager

slide-66
SLIDE 66

Solution: strengthen object invariants

  • Object invariants:

properties always hold for the object

  • pen/mmap

pager

It can only contain files that the pager has access to (i.e.,

  • pened by the same process)
slide-67
SLIDE 67

Solution: strengthen object invariants

  • Object invariants:

properties always hold for the object

  • pen/mmap

pager

It can only contain files that the pager has access to (i.e.,

  • pened by the same process)
slide-68
SLIDE 68

Solution: strengthen object invariants

  • Object invariants:

properties always hold for the object

  • pen/mmap

pager

  • Can be reasoned about

locally

It can only contain files that the pager has access to (i.e.,

  • pened by the same process)
slide-69
SLIDE 69

uint%HandlePageFault(Process% p,%Pointer%addr,%...)%{ ... var%r%=%p.Space.Find(addr); ... if%(r.File%!=%null)%{ %%var%r%=%r.File.Read(...); %%... } }

Pager in C#

slide-70
SLIDE 70

uint%HandlePageFault(Process% p,%Pointer%addr,%...)%{ ... var%r%=%p.Space.Find(addr); ... if%(r.File%!=%null)%{ %%var%r%=%r.File.Read(...); %%... } }

Pager in C#

Security Invariant Contract.Assert(r.File. GhostOwner == p);

slide-71
SLIDE 71

uint%HandlePageFault(Process% p,%Pointer%addr,%...)%{ ... var%r%=%p.Space.Find(addr); ... if%(r.File%!=%null)%{ %%var%r%=%r.File.Read(...); %%... } }

Pager in C#

Security Invariant Contract.Assert(r.File. GhostOwner == p); ensures r≠null→r.ObjInvariant() ∧ r.GhostOwner == GhostOwner;

slide-72
SLIDE 72

uint%HandlePageFault(Process% p,%Pointer%addr,%...)%{ ... var%r%=%p.Space.Find(addr); ... if%(r.File%!=%null)%{ %%var%r%=%r.File.Read(...); %%... } }

Pager in C#

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

slide-73
SLIDE 73

AddressSpace in Dafny

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;

slide-74
SLIDE 74

AddressSpace in Dafny

  • Heavy verification effort
  • 730 lines of code
  • ~200 lines of annotations

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;

slide-75
SLIDE 75

Combining Dafny & CC

ghost variables Assume() Dafny C# + code contracts

... [Ghost]%Foo%GhostOwner; Find(...)%{ ... Assume(...); ... }

slide-76
SLIDE 76

Experience

  • Focus on security

invariants

slide-77
SLIDE 77

Experience

  • Focus on security

invariants

  • Less components

(isolation & end-to- end mechanisms)

slide-78
SLIDE 78

Experience

  • Focus on security

invariants

  • Less components

(isolation & end-to- end mechanisms)

  • Simpler properties

(object invariants vs async contexts)

slide-79
SLIDE 79

Experience

  • Focus on security

invariants

  • Less components

(isolation & end-to- end mechanisms)

  • Simpler properties

(object invariants vs async contexts)

  • Code contracts + Dafny: 2.8% annotation overhead

Line of code Full system 13M Linux kernel 1M ExpressOS 15,932 Annotation 438

slide-80
SLIDE 80

Experience on verification

  • Code contracts are mostly sufficient
  • Plus ghost variables and the

concepts of ownerships

  • Dafny for the rest
slide-81
SLIDE 81

Implementation

  • Build on top of L4::Fiasco
  • Use L4Android to

implement system services

  • Turning Linux into a

microkernel server

  • Sufficient to run the

Android web browser and this presentation

Hardware Android apps Android apps Drivers Storage Window mgnt. Network

...

ExpressOS Android syscalls Runtime L4

slide-82
SLIDE 82

Security analysis

  • Studied 742

vulnerabilities from CVE (from Jun, 2011~Jun, 2012)

  • 383 of them affect

Android

  • ExpressOS prevents 364

(95%) of them

Num Prevented Core kernel 9 9 Library of apps 102 102 Services 240 226 Applications 32 27

slide-83
SLIDE 83

Page load latency

  • n web browsing

1250 2500 3750 5000 A m a z

  • n

A n d r

  • i

d C r a i g s l i s t E b a y F a c e b

  • k

G

  • g

l e W i k i p e d i a W

  • r

d p r e s s Y a h

  • Page load latency (ms)

Android-x86 L4Android ExpressOS

slide-84
SLIDE 84

Conclusion

  • ExpressOS: a high assurance OS that runs

Android applications

slide-85
SLIDE 85

Conclusion

  • ExpressOS: a high assurance OS that runs

Android applications

  • Define security invariants
slide-86
SLIDE 86

Conclusion

  • ExpressOS: a high assurance OS that runs

Android applications

  • Define security invariants
  • Isolate vulnerabilities of components
slide-87
SLIDE 87

Conclusion

  • ExpressOS: a high assurance OS that runs

Android applications

  • Define security invariants
  • Isolate vulnerabilities of components
  • Verify security invariants directly
slide-88
SLIDE 88

Conclusion

  • ExpressOS: a high assurance OS that runs

Android applications

  • Define security invariants
  • Isolate vulnerabilities of components
  • Verify security invariants directly
  • Practical approach to establish high

assurance in real-world systems

slide-89
SLIDE 89

Thank you!

Source code available at: https://github.com/ExpressOS/expressos