Security-Typed Programming within Dependently-Typed Programming - - PowerPoint PPT Presentation

security typed programming within dependently typed
SMART_READER_LITE
LIVE PREVIEW

Security-Typed Programming within Dependently-Typed Programming - - PowerPoint PPT Presentation

Security-Typed Programming within Dependently-Typed Programming Dan Licata Joint work with Jamie Morgenstern Carnegie Mellon University Security-Typed Programming Access control: who gets access to what? read a file play a song make an


slide-1
SLIDE 1

Security-Typed Programming within Dependently-Typed Programming

Dan Licata Joint work with Jamie Morgenstern Carnegie Mellon University

slide-2
SLIDE 2

Security-Typed Programming

Access control: who gets access to what? read a file play a song make an FFI call Information flow: what can they do with it? post the file contents on a blog copy the mp3 save the result in a database

2

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-3
SLIDE 3

Security-Typed Programming

Access control: who gets access to what? read a file play a song make an FFI call Information flow: what do they do with it? post the file contents on a blog copy the mp3 save the result in a database

3

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-4
SLIDE 4

Access Control

4

Read “/alice/secret.txt” Access control list (ACL) for /alice/secret.txt Alice Desktop

Alice: rwad Bob: rw Admin: rlidwka

(slide by Kumar Avijit)

Dan Licata and Jamie Morgenstern Security-Typed Programming within DTP Security-Typed Programming within DTP

slide-5
SLIDE 5

Access Control

4

Read “/alice/secret.txt” Access control list (ACL) for /alice/secret.txt Alice Desktop Enforcement: Authentication + ACL lookup

Alice: rwad Bob: rw Admin: rlidwka

(slide by Kumar Avijit)

Dan Licata and Jamie Morgenstern Security-Typed Programming within DTP Security-Typed Programming within DTP

slide-6
SLIDE 6

5

Decentralized Access Control

  • All students of

members can read papers

  • CMU is a member
  • Alice is a student
  • Charlie is a student

Alice CMU Digital library

(slide by Kumar Avijit) Read “paper.pdf”

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-7
SLIDE 7

5

Decentralized Access Control

  • All students of

members can read papers

  • CMU is a member
  • Alice is a student
  • Charlie is a student

Alice CMU Digital library

(slide by Kumar Avijit) Read “paper.pdf”

Need a mechanism to specify and enforce decentralized policies...

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-8
SLIDE 8

6

Authorization Logic

  • All students of

members can read papers

  • CMU is a member
  • Alice is a student
  • Charlie is a student

CMU Digital library

ACM says ∀ s:principal, ∀ i:principal, ∀ p:paper, (member(i) ⋀ i says student(s)) ⊃ MayRead(s, p) CMU says student(Alice)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-9
SLIDE 9

7

Proof Carrying Authorization

  • All students of

members can read papers

  • CMU is a member
  • Alice is a student
  • Charlie is a student

Alice CMU Digital library

(slide by Kumar Avijit) Read “paper.pdf” [Appel+Felten]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-10
SLIDE 10

7

Proof Carrying Authorization

  • All students of

members can read papers

  • CMU is a member
  • Alice is a student
  • Charlie is a student

Alice CMU Digital library

(slide by Kumar Avijit) Read “paper.pdf” p : mayread(Alice,paper.pdf) [Appel+Felten]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-11
SLIDE 11

8

Proof Carrying Authorization

Alice

(slide by Kumar Avijit) Read “paper.pdf” p : mayread(Alice,paper.pdf)

Evidence OK? (Access granted) (Runtime error) Digital library Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-12
SLIDE 12

8

Proof Carrying Authorization

Alice

(slide by Kumar Avijit) Read “paper.pdf” p : mayread(Alice,paper.pdf)

Evidence OK? (Access granted) (Runtime error) Digital library

Can we ensure that runtime errors won’t happen?

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-13
SLIDE 13

An API for PCA

read : file → prin → proof → contents

9

e.g. read(paper.pdf,Alice,p)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-14
SLIDE 14

An API for PCA

read : file → prin → proof → contents

9

p might not be a well-formed proof

e.g. read(paper.pdf,Alice,p)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-15
SLIDE 15

An API for PCA

read : file → prin → proof → contents

9

p might not be a well-formed proof p might not be a proof of the right theorem!

e.g. read(paper.pdf,Alice,p)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-16
SLIDE 16

Dependent Types!

read : (f : file) (k : prin) (p : proof(mayread(k,f)) → contents

10

p is well-formed by typing theorem is explicit in p’s type

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-17
SLIDE 17

Dependent PCA

PCML5 [Avijit+Harper] Aura [Jia,Vaughn,Zdancewik,et al.] Fine [Swamy et. al]

11

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-18
SLIDE 18

Dependent PCA

PCML5 [Avijit+Harper] Aura [Jia,Vaughn,Zdancewik,et al.] Fine [Swamy et. al]

11

12,000 lines of Coq

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-19
SLIDE 19

Dependent PCA

PCML5 [Avijit+Harper] Aura [Jia,Vaughn,Zdancewik,et al.] Fine [Swamy et. al]

11

12,000 lines of Coq 20,000 lines of F#

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-20
SLIDE 20

12

Can we do security-typed programming within an existing dependently-typed language ?

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-21
SLIDE 21

Security-typed Programming in Agda

1.Representing an authorization logic 2.Compile-time and run-time theorem proving 3.Stateful and dynamic policies

13

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-22
SLIDE 22

1.Representing an authorization logic 2.Compile-time and run-time theorem proving 3.Stateful and dynamic policies

14

Security-typed Programming in Agda

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-23
SLIDE 23

BL0

15

[Garg+Pfenning]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-24
SLIDE 24

BL0

15

[Garg+Pfenning]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-25
SLIDE 25

BL0

15

[Garg+Pfenning]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-26
SLIDE 26

BL0

15

[Garg+Pfenning]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-27
SLIDE 27

Outline

1.Representing an authorization logic 2.Compile-time and run-time theorem proving 3.Stateful and dynamic policies

16

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-28
SLIDE 28

Theorem Prover

read(paper.pdf,Alice,p)

17

can be big and difficult to write out

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-29
SLIDE 29

Theorem Prover

read(paper.pdf,Alice,p)

17

We implemented a theorem prover: prove : (Θ : Ctx) (A : Prop) → Maybe (Θ ⊢ A)

can be big and difficult to write out

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-30
SLIDE 30

Theorem Prover

read(paper.pdf,Alice,p)

17

We implemented a theorem prover: prove : (Θ : Ctx) (A : Prop) → Maybe (Θ ⊢ A)

can be big and difficult to write out

(n : nat)

search depth

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-31
SLIDE 31

Run-time Proving

18

tryRead : (Γ : Ctx) (p : prin)(f : file) → Maybe(string) tryRead Γ p f = case (prove 15 Γ Mayread(f,p)) of None => None Some proof => Some (read p f proof)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-32
SLIDE 32

Run-time Proving

18

tryRead : (Γ : Ctx) (p : prin)(f : file) → Maybe(string) tryRead Γ p f = case (prove 15 Γ Mayread(f,p)) of None => None Some proof => Some (read p f proof) prove is fancy version of “look up in ACL”

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-33
SLIDE 33

Run-time Proving

18

tryRead : (Γ : Ctx) (p : prin)(f : file) → Maybe(string) tryRead Γ p f = case (prove 15 Γ Mayread(f,p)) of None => None Some proof => Some (read p f proof) prove is fancy version of “look up in ACL” prove : (n:nat) (Θ : Ctx) (A : Prop) → Maybe (Θ ⊢ A)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-34
SLIDE 34

Compile-time Proving

19

Γpol a static (known at compile-time) policy: Γpol = CMU says student(Alice) :: ACM says ∀ s:principal, ∀ i:principal, ∀ p:paper, (member(i) ⋀ i says student(s)) ⊃ MayRead(s, p) :: ...

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-35
SLIDE 35

proof? : Maybe (Γpol ⊢ Mayread(Alice, paper.pdf)) proof? = prove 15 Γpol (Mayread(Alice, paper.pdf))

20

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-36
SLIDE 36

proof? : Maybe (Γpol ⊢ Mayread(Alice, paper.pdf)) proof? = prove 15 Γpol (Mayread(Alice, paper.pdf))

20

Computes (defintional equality) to either None or Some(p)

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-37
SLIDE 37

proof? : Maybe (Γpol ⊢ Mayread(Alice, paper.pdf)) proof? = prove 15 Γpol (Mayread(Alice, paper.pdf))

20

Computes (defintional equality) to either None or Some(p)

theProof : Γpol ⊢ Mayread(Alice, paper.pdf) theProof = getSome proof?

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-38
SLIDE 38

proof? : Maybe (Γpol ⊢ Mayread(Alice, paper.pdf)) proof? = prove 15 Γpol (Mayread(Alice, paper.pdf))

20

Computes (defintional equality) to either None or Some(p) Checks at compile-time that the theorem prover returned a proof

theProof : Γpol ⊢ Mayread(Alice, paper.pdf) theProof = getSome proof?

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-39
SLIDE 39

21

Checks at compile-time that the theorem prover returned a proof

theProof : Γpol ⊢ Mayread(Alice, paper.pdf) theProof = getSome proof?

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-40
SLIDE 40

Theorem Prover

22

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-41
SLIDE 41

Theorem Prover

23

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-42
SLIDE 42

Theorem Prover

23

Currently pretty slow: Agda’s fault or ours?

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-43
SLIDE 43

Theorem Prover

24

stuck : (reader : Principal) → (MayRead reader paper.pdf :: []) ⊢ MayRead reader paper.pdf stuck reader = getSome (prove 10)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-44
SLIDE 44

Theorem Prover

24

stuck : (reader : Principal) → (MayRead reader paper.pdf :: []) ⊢ MayRead reader paper.pdf stuck reader = getSome (prove 10)

gets stuck at termEq(reader,reader)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-45
SLIDE 45

Theorem Prover

24

stuck : (reader : Principal) → (MayRead reader paper.pdf :: []) ⊢ MayRead reader paper.pdf stuck reader = getSome (prove 10)

gets stuck at termEq(reader,reader)

Solution: reflection?

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-46
SLIDE 46

Outline

1.Representing an authorization logic 2.Compile-time and run-time theorem proving 3.Stateful and dynamic policies

25

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-47
SLIDE 47

Read with policy

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f)) → string

26

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-48
SLIDE 48

Read with policy

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f)) → string

26

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-49
SLIDE 49

Read with policy

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f)) → string

26

represents the policy; where does it come from?

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-50
SLIDE 50

Read with policy

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f)) → string

26

represents the policy; where does it come from?

dynamic: not known until run-time stateful: can change during execution (chown)

Want policies to be:

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-51
SLIDE 51

Indexed Monad

27

Represent computations with a type ◯ Γ A Γ’

policy before policy after [cf. HTT]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-52
SLIDE 52

Indexed Monad

27

Represent computations with a type ◯ Γ A Γ’

policy before policy after

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f))→ ◯ Γ string Γ

[cf. HTT]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-53
SLIDE 53

Indexed Monad

27

Represent computations with a type ◯ Γ A Γ’

policy before policy after

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f))→ ◯ Γ string Γ chown : (f : file) (k1 k2 : prin) (p : (Γ,owns(k1,f)) ⊢ maychown(k1,f)) → ◯ (Γ,owns(k1,f)) string (Γ,owns(k2,f))

[cf. HTT]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-54
SLIDE 54

Indexed Monad

28

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f)) → ◯ Γ string Γ

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-55
SLIDE 55

Indexed Monad

28

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f)) → ◯ Γ string Γ

supposed to be running as k

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-56
SLIDE 56

Indexed Monad

29

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f) & as(k)) → ◯ Γ string Γ

running as k

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-57
SLIDE 57

Indexed Monad

29

read : (f : file) (k : prin) (p : Γ ⊢ mayread(k,f) & as(k)) → ◯ Γ string Γ

running as k

sudo : (f : file) (k1 k2 : prin) → Γ,as(k1) ⊢ maysu(k1,k2) → ◯ (Γ,as(k2)) C (Γ’,as(k2)) → ◯ (Γ,as(k1)) C (Γ’,as(k1))

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-58
SLIDE 58

More examples

file access control (more details) located computation combination with information flow conference management server with several phases (submission, reviewing, notification, …)

30

[ICFP’10, to appear]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-59
SLIDE 59

Sliding scale

31

Guess the policy Prove consequences statically Failures only at edges Do all proving at run-time Type system ensures you make the right run-time checks and handle failures

static dynamic

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-60
SLIDE 60

Summary

Can do security-typed programming within a DTPL

32

Indexed inductive definition to represent proofs Theorem prover to discharge proof obligations, run at compile-time (getSome) and run-time Indexed monad to manage stateful+dynamic policies

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-61
SLIDE 61

Feature Requests

How could a DTPL better support this application?

33

Speed (theorem prover) Reflection (prover works well at extremes but not in the middle) Binding+scope (logic)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-62
SLIDE 62

Thanks for listening!

34

paper + code at http://www.cs.cmu.edu/~drl

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern