Gradual Information Flow Typing Tim Disney Cormac Flanagan - - PowerPoint PPT Presentation

gradual information flow typing
SMART_READER_LITE
LIVE PREVIEW

Gradual Information Flow Typing Tim Disney Cormac Flanagan - - PowerPoint PPT Presentation

Gradual Information Flow Typing Tim Disney Cormac Flanagan University of California Santa Cruz January 29th, 2011 - STOP 2011 Combining gradual typing with information flow Gradual Information + Typing Flow = More secure software


slide-1
SLIDE 1

Gradual Information Flow Typing

Tim Disney Cormac Flanagan University of California Santa Cruz January 29th, 2011 - STOP 2011

slide-2
SLIDE 2

Combining gradual typing with information flow

Information Flow Gradual Typing

+ = More secure software

slide-3
SLIDE 3

Perfect world Security designed upfront

slide-4
SLIDE 4

Perfect world Security designed upfront Broken world Security bolted on after the fact vs.

slide-5
SLIDE 5

Requirements Design Implementation Verification Maintenance

slide-6
SLIDE 6

Finding security requirements upfront is often not economically feasible

slide-7
SLIDE 7

Perfect world Broken world

slide-8
SLIDE 8

Perfect world Broken world

Do not want

slide-9
SLIDE 9

Perfect world Broken world

Do not want Does not exist

slide-10
SLIDE 10

Real world Security evolves with program Perfect world Broken world

Do not want Does not exist

slide-11
SLIDE 11

Confidentiality: keeping sensitive data private & Integrity: protect against untrusted data

Information Flow

slide-12
SLIDE 12

Confidentiality: keeping sensitive data private & Integrity: protect against untrusted data

Information Flow

For this talk we focus on confidentiality

slide-13
SLIDE 13

Labels L (public) H (private)

Information Flow

slide-14
SLIDE 14

Labels L (public) H (private) Labeled Values 42L 58,000H “hello”L

Information Flow

slide-15
SLIDE 15

Dynamically typed program Statically typed program

Siek and Taha (2006), Findler and Felleisen (2002), Wadler and Findler (2009), Ahmed et al. (2011), etc.

Gradual Typing

slide-16
SLIDE 16

Dynamically typed program Statically typed program

Siek and Taha (2006), Findler and Felleisen (2002), Wadler and Findler (2009), Ahmed et al. (2011), etc.

Gradual Typing

Dynamically typed modules Statically typed modules Program

Casts

Mixed static/dynamic

fail with blame

slide-17
SLIDE 17

Dynamically typed program Statically typed program

Siek and Taha (2006), Findler and Felleisen (2002), Wadler and Findler (2009), Ahmed et al. (2011), etc.

Gradual Typing

Dynamically typed modules Statically typed modules Program

Casts

Mixed static/dynamic

fail with blame

slide-18
SLIDE 18

Static security types No security checks Dynamic security checks

Gradual Security

slide-19
SLIDE 19

Static security types No security checks Dynamic security checks Dynamic security modules Static security modules Program

Casts

Mixed static/ dynamic security

fail with blame

Gradual Security

slide-20
SLIDE 20

Static security types No security checks Dynamic security checks Dynamic security modules Static security modules Program

Casts

Mixed static/ dynamic security

fail with blame

Gradual Security

rev 0

slide-21
SLIDE 21

Static security types No security checks Dynamic security checks Dynamic security modules Static security modules Program

Casts

Mixed static/ dynamic security

fail with blame

Gradual Security

rev 0 rev 1

slide-22
SLIDE 22

Static security types No security checks Dynamic security checks Dynamic security modules Static security modules Program

Casts

Mixed static/ dynamic security

fail with blame

Gradual Security

rev 0 rev 1 rev 2

slide-23
SLIDE 23

Static security types No security checks Dynamic security checks Dynamic security modules Static security modules Program

Casts

Mixed static/ dynamic security

fail with blame

Gradual Security

rev 0 rev 1 rev 2 rev 3

slide-24
SLIDE 24

A language for gradual information flow

slide-25
SLIDE 25

The language

Types (a, b): Labeled Types (A, B):

Int, Bool, A → B

Values (r): Labeled Values (v): 42H, (λx:A. t)L

IntL, BoolL, (A → B)H

slide-26
SLIDE 26

The language

Private types: potentially private

IntH = {0L, 0H, 1L, 1H, . . .}

slide-27
SLIDE 27

The language

Private types: potentially private

IntH = {0L, 0H, 1L, 1H, . . .}

Public types: definitely public

IntL = {0L, 1L, 2L, . . .}

slide-28
SLIDE 28

The language

Private types: potentially private

IntH = {0L, 0H, 1L, 1H, . . .}

Public types: definitely public

IntL = {0L, 1L, 2L, . . .}

Subtypes

slide-29
SLIDE 29

The language

Default labels are permissive

slide-30
SLIDE 30

The language

Default labels are permissive

42 = 42L

slide-31
SLIDE 31

The language

Default labels are permissive

Int = IntH

42 = 42L

slide-32
SLIDE 32

The language

Default labels are permissive

Int = IntH

42 = 42L

slide-33
SLIDE 33

The language

Default labels are permissive

Int = IntH

42 = 42L

slide-34
SLIDE 34

Casting checks runtime labels

Syntax similar to “Blame For All” by Ahmed et al.

t: A ⇒p B

slide-35
SLIDE 35

Casting checks runtime labels

42L : IntH ⇒p IntL

42L

Syntax similar to “Blame For All” by Ahmed et al.

t: A ⇒p B

slide-36
SLIDE 36

Casting checks runtime labels

42L : IntH ⇒p IntL

42L

Syntax similar to “Blame For All” by Ahmed et al.

t: A ⇒p B

42H : IntH ⇒p IntL

blame p

slide-37
SLIDE 37

Higher-order casting: cast at fault

wrap fn

(fn): (IntL → IntH) ⇒p (IntL → IntL)

slide-38
SLIDE 38

Higher-order casting: cast at fault

wrap fn

(fn): (IntL → IntH) ⇒p (IntL → IntL)

43L

fn = λx:IntL. x + 1L

(wrap fn) 42L

slide-39
SLIDE 39

Higher-order casting: cast at fault

wrap fn

(fn): (IntL → IntH) ⇒p (IntL → IntL)

blame p

(wrap fn) 42L cast blamed

fn = λx:IntL. x + 1H

43L

fn = λx:IntL. x + 1L

(wrap fn) 42L

slide-40
SLIDE 40

Higher-order casting: context at fault

wrap fn

(fn): (IntL → IntL) ⇒p (IntH → IntL)

slide-41
SLIDE 41

Higher-order casting: context at fault

wrap fn

(wrap fn) 42L

24L

(fn): (IntL → IntL) ⇒p (IntH → IntL)

slide-42
SLIDE 42

Higher-order casting: context at fault

wrap fn

(wrap fn) 42L

24L

(wrap fn) 42H

blame p

context blamed (fn): (IntL → IntL) ⇒p (IntH → IntL)

slide-43
SLIDE 43

(58000L : IntL V IntH)

58000H

Labeling adds runtime labels

V

slide-44
SLIDE 44

(58000L : IntL V IntH)

58000H

Labeling adds runtime labels

V

disk read : (IntL → IntL) V (IntL → IntH)

wrap fn

slide-45
SLIDE 45

Evolution Example

slide-46
SLIDE 46

Rev 0 (no security)

let intToString : Int → Str = . . .

slide-47
SLIDE 47

Rev 0 (no security)

let intToString : Int → Str = . . . let age : Int = 42

slide-48
SLIDE 48

Rev 0 (no security)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000 // confidential!

slide-49
SLIDE 49

Rev 0 (no security)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000 let print : Str → Unit = λs:Str. . . .

// confidential!

slide-50
SLIDE 50

Rev 0 (no security)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000 let print : Str → Unit = λs:Str. . . . print(intToString(salary))

// confidential!

slide-51
SLIDE 51

Prints “58000”

Rev 0 (no security)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000 let print : Str → Unit = λs:Str. . . . print(intToString(salary))

// confidential!

slide-52
SLIDE 52

Prints “58000”

Rev 0 (no security)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000 let print : Str → Unit = λs:Str. . . . print(intToString(salary))

// confidential!

slide-53
SLIDE 53

Add dynamic enforcement

slide-54
SLIDE 54

Rev 1 (dynamic enforcement)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000: IntL V IntH let print : Str → Unit = λs:Str. . . . print(intToString(salary))

slide-55
SLIDE 55

Rev 1 (dynamic enforcement)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000: IntL V IntH let print : Str → Unit = λs:Str. . . . print(intToString(salary))

slide-56
SLIDE 56

Still prints “58000”H

Rev 1 (dynamic enforcement)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000: IntL V IntH let print : Str → Unit = λs:Str. . . . print(intToString(salary))

slide-57
SLIDE 57

Still prints “58000”H

Rev 1 (dynamic enforcement)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000: IntL V IntH let print : Str → Unit = λs:Str. . . . print(intToString(salary))

slide-58
SLIDE 58

Rev 1 (dynamic enforcement)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000: IntL V IntH let print : Str → Unit = λs:Str. . . . let s = (s: StrH ⇒p StrL) in . . . print(intToString(salary))

slide-59
SLIDE 59

Rev 1 (dynamic enforcement)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000: IntL V IntH let print : Str → Unit = λs:Str. . . . let s = (s: StrH ⇒p StrL) in . . . print(intToString(salary))

slide-60
SLIDE 60

Fails and blames p since StrH can’t be cast to StrL

Rev 1 (dynamic enforcement)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000: IntL V IntH let print : Str → Unit = λs:Str. . . . let s = (s: StrH ⇒p StrL) in . . . print(intToString(salary))

slide-61
SLIDE 61

Fails and blames p since StrH can’t be cast to StrL

Rev 1 (dynamic enforcement)

let intToString : Int → Str = . . . let age : Int = 42 let salary : Int = 58000: IntL V IntH let print : Str → Unit = λs:Str. . . . let s = (s: StrH ⇒p StrL) in . . . print(intToString(salary))

slide-62
SLIDE 62

Add static enforcement

slide-63
SLIDE 63

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . print(intToString(salary))

slide-64
SLIDE 64

intToString causes compile error

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . print(intToString(salary))

slide-65
SLIDE 65

intToString causes compile error

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . print(intToString(salary))

slide-66
SLIDE 66

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . let intToStringL : IntL → IntL = intToString: (IntH → IntH) ⇒p (IntL → IntL) print(intToStringL(salary))

slide-67
SLIDE 67

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . let intToStringL : IntL → IntL = intToString: (IntH → IntH) ⇒p (IntL → IntL) print(intToStringL(salary))

slide-68
SLIDE 68

salary causes compile error

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . let intToStringL : IntL → IntL = intToString: (IntH → IntH) ⇒p (IntL → IntL) print(intToStringL(salary))

slide-69
SLIDE 69

salary causes compile error

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . let intToStringL : IntL → IntL = intToString: (IntH → IntH) ⇒p (IntL → IntL) print(intToStringL(salary))

slide-70
SLIDE 70

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . let intToStringL : IntL → IntL = intToString: (IntH → IntH) ⇒p (IntL → IntL) print(intToStringL(age))

slide-71
SLIDE 71

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . let intToStringL : IntL → IntL = intToString: (IntH → IntH) ⇒p (IntL → IntL) print(intToStringL(age))

slide-72
SLIDE 72

Compiles successfully

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . let intToStringL : IntL → IntL = intToString: (IntH → IntH) ⇒p (IntL → IntL) print(intToStringL(age))

slide-73
SLIDE 73

Compiles successfully

Rev 2 (static enforcement)

let intToString : IntH → StrH = . . . let age : IntL = 42 let salary : IntH = 58000: IntL V IntH let print : StrL → UnitL = λs:StrL. . . . let intToStringL : IntL → IntL = intToString: (IntH → IntH) ⇒p (IntL → IntL) print(intToStringL(age))

slide-74
SLIDE 74

Safety Theorems

slide-75
SLIDE 75

Theorem: Termination Insensitive Non-Interference Private inputs cannot affect public outputs

See paper for details

slide-76
SLIDE 76

Subtyping

L v H L v L H v H

slide-77
SLIDE 77

Subtyping

L v H L v L H v H

l v k Intl <: Intk

Subtype

slide-78
SLIDE 78

Subtyping

L v H L v L H v H

l v k Intl <: Intk

Subtype Positive Subtype

l v k Intl <:+ Intk

slide-79
SLIDE 79

Subtyping

L v H L v L H v H

l v k Intl <: Intk

Subtype Positive Subtype

l v k Intl <:+ Intk

Negative Subtype

k v l Intl <:− Intk

slide-80
SLIDE 80

Blame Theorem If two types are subtypes, casting cannot cause blame

slide-81
SLIDE 81

Blame Theorem

  • 1. If t: A ⇒p B and A <: B then never blames p or p
  • 2. If t: A ⇒p B and A <:+ B then never blames p
  • 3. If t: A ⇒p B and A <:− B then never blames p

If two types are subtypes, casting cannot cause blame

slide-82
SLIDE 82

Conclusion

  • Gradually evolve security
  • From dynamic info-flow to static info-flow
  • Provide language features to allow security

evolution