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 Supported by NSF CCF-0702381 and CNS-0716469 Security-Typed Programming Access control: who gets access


slide-1
SLIDE 1

Security-Typed Programming within Dependently-Typed Programming

Dan Licata Joint work with Jamie Morgenstern Carnegie Mellon University

Supported by NSF CCF-0702381 and CNS-0716469

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 can 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 secret.txt Access control list (ACL) for secret.txt Alice Server

Alice: r Bob: rw

(slide by Kumar Avijit)

Dan Licata and Jamie Morgenstern Security-Typed Programming within DTP

slide-5
SLIDE 5

Access Control

4

Read secret.txt Access control list (ACL) for secret.txt Alice Server Enforcement: Authentication + ACL lookup

Alice: r Bob: rw

(slide by Kumar Avijit)

Dan Licata and Jamie Morgenstern 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

Decentralized Access Control

  • All students of

members can read papers

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

CMU Digital library

(slide by Kumar Avijit)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

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

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

Read “paper.pdf” p : mayread(Alice,paper.pdf)

Proof OK? Access granted Runtime error Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-12
SLIDE 12

8

Proof Carrying Authorization

Alice

Read “paper.pdf” p : mayread(Alice,paper.pdf)

Proof OK? Access granted Runtime error Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

  • ACM

says ... Policy

slide-13
SLIDE 13

8

Proof Carrying Authorization

Alice

Read “paper.pdf” p : mayread(Alice,paper.pdf)

Proof OK? Access granted Runtime error Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern State

  • ACM

says ... Policy

slide-14
SLIDE 14

An API for PCA

9

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern Alice Digital library

Read “paper.pdf” p : mayread(Alice,paper.pdf)

slide-15
SLIDE 15

An API for PCA

read : prin → file → proof → contents

9

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern Alice Digital library

Read “paper.pdf” p : mayread(Alice,paper.pdf)

slide-16
SLIDE 16

An API for PCA

read : prin → file → proof → contents

9

read(Alice,paper.pdf,p)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern Alice Digital library

Read “paper.pdf” p : mayread(Alice,paper.pdf)

{

slide-17
SLIDE 17

An API for PCA

10

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

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Problems:

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

read : prin → file → proof → contents

slide-18
SLIDE 18

Dependent Types!

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

11

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

read : prin→ file → proof → contents

slide-19
SLIDE 19

Dependent Types!

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

11

typing ensures p is a well-formed proof theorem is explicit in p’s type

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

read : prin→ file → proof → contents

slide-20
SLIDE 20

Verification Spectrum

12

Predict the policy Prove consequences statically Failures only if prediction was wrong Do all proving at run-time

static dynamic

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-21
SLIDE 21

Verification Spectrum

12

Predict the policy Prove consequences statically Failures only if prediction was wrong Do all proving at run-time

static dynamic

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Reuse proofs for several API calls

slide-22
SLIDE 22

PCML5 [Avijit,Datta,Harper, TLDI’10] Aura [Jia,Vaughan,Zdancewic,et al., ICFP’08 ] Fine [Swamy,Chen,Chugh, ESOP’10] F7 [Gordon,Bengston,Bhargavan,Fournet,Maffeis, CSF’08] …

13

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Dependent PCA

Several new languages:

slide-23
SLIDE 23

14

This paper: We can do security-typed programming within an existing dependently-typed language

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-24
SLIDE 24

PCML5 [Avijit,Datta,Harper, TLDI’10] Aura [Jia,Vaughan,Zdancewic,et al., ICFP’08 ] Fine [Swamy,Chen,Chugh, ESOP’10] F7 [Gordon,Bengston,Bhargavan,Fournet,Maffeis, CSF’08] …

15

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Our library

Supports programming as in

slide-25
SLIDE 25

Aglet: Security-typed Programming in Agda

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-26
SLIDE 26

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

17

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Aglet: Security-typed Programming in Agda

slide-27
SLIDE 27

Dependent Types!

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

18

typing ensures p is a well-formed proof theorem is explicit in p’s type

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

read : file → prin → proof → contents

slide-28
SLIDE 28

19

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Representing BL0

[Garg+Pfenning]

says(Prin CMU, student(Prin Alice)) CMU says student(Alice)

slide-29
SLIDE 29

19

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Representing BL0

[Garg+Pfenning]

data Propo where says : Principal → Propo → Propo ...

says(Prin CMU, student(Prin Alice)) CMU says student(Alice)

slide-30
SLIDE 30

20

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Representing BL0

Sequent as indexed inductive definition: Γ ⊢ A data _⊢_ : Ctx → Propo → Type

[Garg+Pfenning]

slide-31
SLIDE 31

20

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Representing BL0

Sequent as indexed inductive definition: Γ ⊢ A data _⊢_ : Ctx → Propo → Type

[Garg+Pfenning]

Classifying only well-formed derivations: Γ ⊢ A

D D : Γ ⊢ A

slide-32
SLIDE 32

20

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Representing BL0

Sequent as indexed inductive definition: Γ ⊢ A data _⊢_ : Ctx → Propo → Type Inference rules as datatype constructors: Γ, A ⊢ B Γ ⊢ A ⊃ B ⊃R : ∀ {Γ A B} → (A :: Γ) ⊢ B → Γ ⊢ (A ⊃ B)

[Garg+Pfenning]

Classifying only well-formed derivations: Γ ⊢ A

D D : Γ ⊢ A

slide-33
SLIDE 33

20

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Representing BL0

Sequent as indexed inductive definition: Γ ⊢ A data _⊢_ : Ctx → Propo → Type Inference rules as datatype constructors: Γ, A ⊢ B Γ ⊢ A ⊃ B ⊃R : ∀ {Γ A B} → (A :: Γ) ⊢ B → Γ ⊢ (A ⊃ B)

dependent de Bruijn indices [Garg+Pfenning]

Classifying only well-formed derivations: Γ ⊢ A

D D : Γ ⊢ A

slide-34
SLIDE 34

BL0

21

[Garg+Pfenning]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Logic with says modality: CMU says student(Alice)

Ω ; Δ ; Γ → A

k

individuals: x : τ claims: k claims A truth: A true principal we’re reasoning as

slide-35
SLIDE 35

22

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-36
SLIDE 36

22

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-37
SLIDE 37

Outline

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

23

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-38
SLIDE 38

Theorem Prover

24

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

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-39
SLIDE 39

Theorem Prover

24

We implemented a certified theorem prover: prove : (Θ : Ctx) (A : Propo) → Maybe (Θ ⊢ A) (n : nat)

search depth

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-40
SLIDE 40

Theorem Prover

24

We implemented a certified theorem prover: prove : (Θ : Ctx) (A : Propo) → Maybe (Θ ⊢ A) (n : nat)

search depth

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

data Propo where says : Principal → Propo → Propo ... Important that Propos are inductive!

slide-41
SLIDE 41

Verification Spectrum

25

Do all proving at run-time

static dynamic

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Predict the policy Prove consequences statically Failures only if prediction was wrong

slide-42
SLIDE 42

Verification Spectrum

25

Do all proving at run-time

static dynamic

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Predict the policy Prove consequences statically Failures only if prediction was wrong

slide-43
SLIDE 43

Run-time Proving

26

tryRead : Ctx → Prin → File → Maybe(String) tryRead Γ k f = case (prove 15 Γ Mayread(f,p)) of None → None Some proof → Some (read k f proof) prove : (n:nat) (Θ : Ctx) (A : Prop) → Maybe (Θ ⊢ A)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-44
SLIDE 44

Run-time Proving

26

tryRead : Ctx → Prin → File → Maybe(String) tryRead Γ k f = case (prove 15 Γ Mayread(f,p)) of None → None Some proof → Some (read k f proof) use prove like “look up in ACL” prove : (n:nat) (Θ : Ctx) (A : Prop) → Maybe (Θ ⊢ A)

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-45
SLIDE 45

Verification Spectrum

27

Do all proving at run-time

static dynamic

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Predict the policy Prove consequences statically Failures only if prediction was wrong

slide-46
SLIDE 46

Verification Spectrum

27

Do all proving at run-time

static dynamic

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

Predict the policy Prove consequences statically Failures only if prediction was wrong

slide-47
SLIDE 47

Compile-time Proving

28

For Γpol a static (known at compile-time) policy: Γpol = CMU says student(Alice) :: ACM says A :: … For a call read(Alice, paper.pdf, ) can verify at compile-time that can be filled in

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

? ?

slide-48
SLIDE 48

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

29

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern ACM says...

Γpol =

slide-49
SLIDE 49

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

29

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

proof? computes to either None or Some(pf)

ACM says...

Γpol =

slide-50
SLIDE 50

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

29

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

proof? computes to either None or Some(pf) run at compile-time and get value out

ACM says...

Γpol =

slide-51
SLIDE 51

30

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

ML/Haskell: valOf : Maybe A → A run-time error if it’s None

slide-52
SLIDE 52

30

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

ML/Haskell: valOf : Maybe A → A run-time error if it’s None Agda: valOf : (s : Maybe A) → → A

  • nly well-typed if s is equal to Some(pf)

?

slide-53
SLIDE 53

31

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

IsSome : ∀ {A} → Maybe A → Type IsSome (Some _) = Unit IsSome None = Void

slide-54
SLIDE 54

31

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

IsSome : ∀ {A} → Maybe A → Type IsSome (Some _) = Unit IsSome None = Void valOf : ∀ {A} → (s : Maybe A) → IsSome s → A valOf (Some x) _ = x valOf None (v ) = ?

slide-55
SLIDE 55

31

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

IsSome : ∀ {A} → Maybe A → Type IsSome (Some _) = Unit IsSome None = Void valOf : ∀ {A} → (s : Maybe A) → IsSome s → A valOf (Some x) _ = x valOf None (v ) = ? : IsSome None

slide-56
SLIDE 56

31

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

IsSome : ∀ {A} → Maybe A → Type IsSome (Some _) = Unit IsSome None = Void valOf : ∀ {A} → (s : Maybe A) → IsSome s → A valOf (Some x) _ = x valOf None (v ) = ? : Void

slide-57
SLIDE 57

31

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

IsSome : ∀ {A} → Maybe A → Type IsSome (Some _) = Unit IsSome None = Void valOf : ∀ {A} → (s : Maybe A) → IsSome s → A valOf (Some x) _ = x valOf None (v ) = : Void impossibe v

slide-58
SLIDE 58

32

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

valOf : ∀ {A} → (s : Maybe A) → IsSome s → A theProof : Γpol ⊢ Mayread(Alice, paper.pdf) theProof = valOf proof? <> Given proof? : Maybe (Γpol ⊢ Mayread(Alice, paper.pdf))

slide-59
SLIDE 59

32

Compile-time Proving

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

valOf : ∀ {A} → (s : Maybe A) → IsSome s → A theProof : Γpol ⊢ Mayread(Alice, paper.pdf) theProof = valOf proof? <> Given proof? : Maybe (Γpol ⊢ Mayread(Alice, paper.pdf))

Agda type error if theorem prover fails

slide-60
SLIDE 60

Outline

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

33

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-61
SLIDE 61

Read with policy

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

34

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-62
SLIDE 62

Read with policy

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

34

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-63
SLIDE 63

Read with policy

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

34

represents the policy; where does it come from?

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-64
SLIDE 64

Read with policy

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

34

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-65
SLIDE 65

Indexed Monad

35

Represent computations with a type ◯ Γ A Γ’

policy before policy after [cf. HTT]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-66
SLIDE 66

Indexed Monad

35

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-67
SLIDE 67

Indexed Monad

35

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-68
SLIDE 68

Indexed Monad

36

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

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-69
SLIDE 69

Indexed Monad

36

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

need to track who you’re running as [AH07]

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-70
SLIDE 70

Indexed Monad

37

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-71
SLIDE 71

Indexed Monad

37

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-72
SLIDE 72

More examples

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

38

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-73
SLIDE 73

Summary

Can do security-typed programming within DTP

39

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

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-74
SLIDE 74

Feature Requests

How could a DTPL better support this application?

40

Speed or interface to theorem provers 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-75
SLIDE 75

Feature Requests

How could a DTPL better support this application?

40

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

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

term repr. / [Brady et al.] [Kariso]

slide-76
SLIDE 76

Feature Requests

How could a DTPL better support this application?

40

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

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

term repr. / [Brady et al.] [Kariso] quoteGoal

slide-77
SLIDE 77

Feature Requests

How could a DTPL better support this application?

40

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

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

term repr. / [Brady et al.] [Kariso] quoteGoal Dan’s thesis, coming next month

slide-78
SLIDE 78

Thanks for listening!

41

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

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern

slide-79
SLIDE 79

Summary

Can do security-typed programming within DTP

42

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

Security-Typed Programming within DTP Dan Licata and Jamie Morgenstern