information flow - cs.cornell.edu

60
CS 5430: Information Flow Static Enforcement Fred B. Schneider Samuel B Eckert Professor of Computer Science Department of Computer Science Cornell University Ithaca, New York 14853 U.S.A.

Upload: others

Post on 29-May-2022

9 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Information Flow - cs.cornell.edu

CS 5430:Information Flow

Static Enforcement

Fred B. SchneiderSamuel B Eckert Professor of Computer Science

Department of Computer ScienceCornell University

Ithaca, New York 14853U.S.A.

Page 2: Information Flow - cs.cornell.edu

Access Control

Access control associates restrictions with:– Containers

§ access control lists, capabilities– Values

§ information flow control

Example: x:=y;...z:=x– container: value in y can be leaked by reading z– value: restrictions on z include all restrictions on y

... no need to trust clients who access y.

1

Page 3: Information Flow - cs.cornell.edu

Flow-based Access Control (FBAC)

● Labels propagate with flow.● Labels restrict allowed info flow.

Flow-Label Invariant (FLI):v → w ⟹ Γ(v) ⊑ Γ(w)

v → w: v flows to w. NB really →* for flow in S.Γ(v): label assoc with v --- gives restrictions on use of v⊑ reflexiveandtransitiverelationonasetℒ oflabels.

λ< ⊑ λ=:λ= includes all restrictions in λ<2

Page 4: Information Flow - cs.cornell.edu

An application of FBAC

v → w ⟹ Γ(v) ⊑ Γ(w)

3

B:L D:L

C:HL⊑ H

system

A:H ℒ = { L, H }

Page 5: Information Flow - cs.cornell.edu

An application of FBAC

v → w ⟹ Γ(v) ⊑ Γ())= Γ(v) ⋢ Γ(w) ⟹ ¬(v → w)

4

B:L D:L

C:HL⊑ HH⋢ L

system

A:H ℒ = { L, H }

Page 6: Information Flow - cs.cornell.edu

An application of FBAC

v → w ⟹ Γ(v) ⊑ Γ())= Γ(v) ⋢ Γ(w) ⟹ ¬(v → w)

5

B:L D:L

C:HL⊑ HH⋢ L

system

A:H ℒ = { L, H }

Page 7: Information Flow - cs.cornell.edu

An application of FBAC

v → w ⟹ Γ(v) ⊑ Γ(w)= Γ(v) ⋢ Γ(w) ⟹ ¬(v → w)

6

B:L D:L

C:HL⊑ HH⋢ L

system

A:H ℒ = { L, H }

Page 8: Information Flow - cs.cornell.edu

An application of FBAC

v → w ⟹ Γ(v) ⊑ Γ(w)= Γ(v) ⋢ Γ(w) ⟹ ¬(v → w)● Confidentiality: L: public and H: secret● Integrity: L: trusted and H: untrusted

7

B:L D:L

C:HL⊑ HH⋢ L

system

A:H ℒ = { L, H }

Page 9: Information Flow - cs.cornell.edu

FBAC in General

Possible source/destination of flows:– ports– people– variables

8

Page 10: Information Flow - cs.cornell.edu

FBAC in Programs

Example: x:=y;...z:=x– y → x, x → z– Γ(y) ⊑ Γ(x), Γ(x) ⊑ Γ(z).

§ Conclude: yà z and λ(y) ⊑ λ(z)§ Nb. → is not necessarily transitiave. No harm here

if it isn’t.

9

Page 11: Information Flow - cs.cornell.edu

FBAC in Programs

Example: x:=y;...z:=x– y → x, x → z– Γ(y) ⊑ Γ(x), Γ(x) ⊑ Γ(z).

§ Conclude: If yà z then Γ(y) ⊑ Γ(z) alsomust hold.§ Nb. → is not necessarily transitive.

10

Page 12: Information Flow - cs.cornell.edu

Agenda

● Formalize Flow: v → v’– Examples for intuition – Formal definitions

● Derive policies FBAC enforces:– Confidentiality– Integrity

● Means of enforcement– Static– Dynamic

11

Page 13: Information Flow - cs.cornell.edu

v → v’? Direct Flows in Programs

x:=ymod2 yà xx:=y*0¬ (yà x)z:=y+2;x:=z yà xz:=y+2;x:=z-y¬ (yà x)

12

Page 14: Information Flow - cs.cornell.edu

v → v’? Direct Flows in Programs

x:=ymod2 y → xx:=y*0¬ (y → x)z:=y+2;x:=z y → xz:=y+2;x:=z-y¬ (y → x)

... Illustrates intransitive flow

13

Page 15: Information Flow - cs.cornell.edu

v → v’? Indirect Flows in Programs

if y>0then x:=1else x:=2 y → x

while y>0do x:=x+1;y:=y-1end y → x

14

Page 16: Information Flow - cs.cornell.edu

Definitions for Flow

v → w?

Satisfied if there exist two executions– that differ only in the initial value of v –and-– terminate having different final values of w.

15

Page 17: Information Flow - cs.cornell.edu

v → w? Formal Definition

Letdom(m)=Dfor m∈Mem/ : Mem⟶ Mem ∪ {⊥}m =6 m7: (∀ v ∈ V: m(v) = m’(v) )

Define v → w:( ∃ m,m7: m ==> ? m7 ∧ S m ≠⊥ ∧ S m′ ≠⊥

∧ S m ≠ D S m7)

16

Page 18: Information Flow - cs.cornell.edu

FBAC in action

Partition the set of all program variables: V" and V#– V" = v Γ v = H} V# = v Γ v = L},– L ⊑ H.

For all v" ∈ V", v# ∈ V# FBAC requiresv" → v# ⇒ Γ v" ⊑ Γ v#

= v" → v# ⇒ H ⊑ L= v" → v# ⇒ false= ¬ (v" → v#)

17

Page 19: Information Flow - cs.cornell.edu

FBAC in action

¬ (v$ → v&)= ¬( ∃ m,m,: m =./ 0 m, ∧ S m ≠⊥ ∧ S m′ ≠⊥

∧ S m ≠ 6 S m,)= ( ∀ m,m,: m =./ 0 m, ∧ S m ≠⊥ ∧ S m′ ≠⊥

⇒ S m = 6 S m,)

Conclusion: Changes to v$ do not cause changes to v& in terminating executions.

– Confidentiality: H is secret; L is public– Integrity: H is untrusted; L is trusted.

18

Page 20: Information Flow - cs.cornell.edu

Non-interference

Generalize variables v", v# to sets V", V#.(∀ m,m): m =,-./ m) ∧ S m ≠⊥ ∧ S m′ ≠⊥

⇒ S m =.6 S m′)Changes to variables in V" do not affect the final values of variables in V#. Property (with terms often left implicit) is called :

– Termination insensitive non-interference (TINI)– Goguen-Meseguer non-interference– Relational non-interference (RNI)

19

Page 21: Information Flow - cs.cornell.edu

Additional Leaks: Termination

!" h > 0&'() *'!+( true 01 23!4 ()0(+2( 23!4

"!

Termination leaks value of h > 0.Value of h flows to termination: h →⊥

20

Page 22: Information Flow - cs.cornell.edu

v →⊥? Formal Definition

v →⊥:( ∃ m,m): m =+, - m)

∧ S m =⊥ ≠ ( S m) =⊥))

Define Γ ⊥ : Label needed by a principal in order to ascertain whether execution has terminated.Usually Γ ⊥ = L.

21

Page 23: Information Flow - cs.cornell.edu

Derive: Termination Sensitive NI 1/3

Flow-Label Invariant:(v → w ⟹ Γ(v) ⊑ Γ(w)) ∧ (v →⊥ ⟹ Γ(v) ⊑ Γ(⊥ ))

=(v → w ⟹ Γ(v) ⊑ Γ(w)) ∧ (v →⊥ ⟹ Γ(v) ⊑ L)=(Γ v = L)∨ (¬ v →⊥ ∧ v → w ⇒ Γ v ⊑ Γ w )

22

Page 24: Information Flow - cs.cornell.edu

Termination Sensitive NI 2/3

Γ v = L ∨ (¬ v →⊥ ∧ v → w ⇒ Γ v ⊑ Γ w )

¬ v →⊥ := ¬( ∃ m,m3: m =45 6 m3 ∧ S m =⊥ ≠ ( S m3 =⊥))= ( ∀ m,m3: m =45 6 m3 ⇒ S m =⊥ = ( S m3 =⊥))

¬ v → w :{since S m ≠⊥⇒ S m′ ≠⊥ }= ¬( ∃ m,m3: m =45 6 m3 ∧ S m ≠⊥ ∧ ( S m ≠ C S m3))= ( ∀ m,m3: m =45 6 m3 ∧ S m ≠⊥ ⇒ ( S m = C S m3))

23

Page 25: Information Flow - cs.cornell.edu

Termination Sensitive NI 3/3

Define: TSNI( ∀ m,m%: m =() *+ m% ⇒

( S m =⊥ = ( S m% =⊥))∧ ( S m ≠⊥ ⇒ ( S m = *2 S m%)))

24

Page 26: Information Flow - cs.cornell.edu

Other Generalizations of v → w

Let dom(m)=Dfor m∈Mem/ : Mem⟶ Mem∗ ∪ {⊥}m =7 m8: (∀ v ∈ V: m(v) = m’(v) )(m<m=…m? … ) ≈7 (m<

8A=8 …AB

8):(m<|D m=|D …m?|D … ) =∗ (m<

8 |D A=8 |D …AB

8|D)where: =∗ isequalityofde-stutteredsequences.

Define v → w:( ∃ m,m8: m =VW X m8 ∧ S m ≠⊥ ∧ S m′ ≠⊥

∧ ¬ ( S m ≈ ^ S m8))

25

Page 27: Information Flow - cs.cornell.edu

Enforcement of FBAC

FLI potentially imposes restrictions on statements.● Static Enforcement

– Compiler ensures program is type correct.– Type correct programs will satisfy restrictions.

● Dynamic Enforcement– Insert run-time checks that halt program execution

about to violate restrictions.– Change labels to satisfy restrictions as program

execution proceeds.

26

Page 28: Information Flow - cs.cornell.edu

Toy Language

27

e::=x|n|e1+e2|...c::=x:=e

|if ethen c1else c2fi|while edo cend|c1;c2

Page 29: Information Flow - cs.cornell.edu

Restrictions for:Assignment x:=e

vàw ⟹ Γ(v) ⊑ Γ(w)

x:=ycauses yà x§ requires Γ(y) ⊑ Γ(x)

x:=y+z causes yà x and zà x§ requires: Γ(y+z) ⊑ Γ(x)§ implied by: Γ(y) ⊔ Γ(z) ⊑ Γ(x)

28

Page 30: Information Flow - cs.cornell.edu

Restrictions for:Assignment x:=E

x:=Ecauses Eà xdefine Eà x:(∀ v∈ E:và x)define Γ(E): (⊔ Γ(v) ∈ E)

where λ ⊔ λ2 is smallest label satisfyingλ ⊑ λ ⊔ λ2 and λ2 ⊑ λ ⊔ λ2

x:=Ecauses Eà x– requires (⊔ Γ(v) ∈ E) ⊑ Γ(x)

29

Page 31: Information Flow - cs.cornell.edu

Restrictions for:Assignment x:=E

x:=Ecauses Eà xdefine Eà x:(∀ v∈ E:và x)define Γ(E): (⊔ Γ(v) ∈ E)

where λ ⊔ λ2 is smallest label satisfyingλ ⊑ λ ⊔ λ2 and λ2 ⊑ λ ⊔ λ2

x:=Ecauses Eà x– requires (⊔ Γ(v) ∈ E) ⊑ Γ(x)

30

Page 32: Information Flow - cs.cornell.edu

Restrictions for:If Statements

#$ y > 0 ()*+ x ≔ 1 */0* x ≔ 2 $#

● y > 0 → pc, pc → x, y > 0 → x– Requires: Γ y > 0 ⊑ Γ(x)

31

Page 33: Information Flow - cs.cornell.edu

Restrictions for:If Statements

#$ y > 0 ()*+ x ≔ 1 */0* x ≔ 2 $#

● y > 0 → pc, pc → x, y > 0 → x– Requires: Γ y > 0 ⊑ Γ(x)

32

Page 34: Information Flow - cs.cornell.edu

Restrictions for:If Statements

#$ y > 0 ()*+ x ≔ 1 */0* x ≔ 2 $#

y > 0 → pc, pc → x,

33

Page 35: Information Flow - cs.cornell.edu

Restrictions for:If Statements

#$ y > 0 ()*+ x ≔ 1 */0* x ≔ 2 $#

y > 0 → pc, pc → x, y > 0 → xy > 0 → x requires Γ y > 0 ⊑ Γ(x)

34

Page 36: Information Flow - cs.cornell.edu

Restrictions for:If Statements

#$ y > 0 ()*+ x ≔ 1 */0* x ≔ 2 $#

35

234 = Γ 7 > 0= Γ 7 ⊔ Γ 0= Γ 7

Page 37: Information Flow - cs.cornell.edu

Restrictions for:If Statements

#$ B &'() x ≔ E (-.( … $#0 → 2, 4 → 2

requires: Γ 0 ⊑ Γ 2 , Γ 4 ⊑ Γ 2implied by:ctx = Γ 0ctx ⊔ Γ E ⊑ Γ x

36

Page 38: Information Flow - cs.cornell.edu

Restrictions for:If Statements

#$ B &'() x ≔ E (-.( … $#0 → 2, 4 → 2

requires: Γ 0 ⊑ Γ 2 , Γ 4 ⊑ Γ 2implied by:ctx = Γ 0ctx ⊔ Γ E ⊑ Γ x

37

Page 39: Information Flow - cs.cornell.edu

Restrictions for:If Statements

#$ B &'() x ≔ E (-.( … $#0 → 2, 4 → 2

requires: Γ 0 ⊑ Γ 2 , Γ 4 ⊑ Γ 2implied by:ctx = Γ 0ctx ⊔ Γ E ⊑ Γ x

38

Page 40: Information Flow - cs.cornell.edu

Restrictions for:Nested If Statements

if z>0then y:=23

ify>0then x:=1else u:=2

fielse

w:=3fi

39

Page 41: Information Flow - cs.cornell.edu

Restrictions for:Nested If Statements

if z>0then y:=23

ify>0then x:=1else u:=2

fielse

w:=3fi

40

ctx = Γ yctx = Γ y

Page 42: Information Flow - cs.cornell.edu

Restrictions for:Nested if Statements

if z>0then y:=23

ify>0then x:=1else u:=2

fielse

w:=3fi

41

ctx = Γ y ⊔ Γ z

ctx = Γ z

ctx = Γ y ⊔ Γ z

ctx = Γ z

Page 43: Information Flow - cs.cornell.edu

A Type System

● Fixed label assignment Γ● Goal:

– Type correctness implies Flow-Label invariant will hold throughout executions.

vàw ⟹ Γ(v) ⊑ Γ(w)– Flow-Label invariant implies RNI will hold

throughout executions.

42

Page 44: Information Flow - cs.cornell.edu

Type Systems: Big Picture

“Program S is type correct” is a theorem in a logic (say) secL.

– Logic is decidable.§ Compiler’s type checker “proves” these theorems.

– Logic is sound with respect to:“Program S satisfies FLI invariant”

43

Page 45: Information Flow - cs.cornell.edu

Formulas of secL

Formulas of secL are called judgements.Formulas of secL are given as sequents:– ", $%& ⊢ (&)*: , forexpressionExpr,label,", $%& ⊢ ; forstatementS

Inference rules give premises and conclusion

?@, ?A , … , ?CD

44

Page 46: Information Flow - cs.cornell.edu

Rules for Expressions

● Constant: !, #$% ⊢ ' ∶ )

● Variable: ! % *+!, #$% ⊢ % ∶+

● Expression: !, #$% ⊢ , ∶+ !, #$% ⊢ ,-∶+-!, #$% ⊢ ,.,- ∶+ ⊔ +-

45

Page 47: Information Flow - cs.cornell.edu

A Proof (1/3)

Given Γ x = L and Γ y = H:

Γ x = LΓ, ctx ⊢ x ∶ L

Γ y = HΓ, ctx ⊢ y ∶ H

Γ, ctx ⊢ x + y ∶ L ⊔ H

Conclusion: x+y :H

46

Page 48: Information Flow - cs.cornell.edu

A Proof (2/3)

Given Γ x = L and Γ y = H:

Γ x = LΓ, ctx ⊢ x ∶ L

Γ y = HΓ, ctx ⊢ y ∶ H

Γ, ctx ⊢ x + y ∶ L ⊔ H

Conclusion: x+y :H

47

Page 49: Information Flow - cs.cornell.edu

A Proof (3/3)

Given Γ x = L and Γ y = H:

Γ x = LΓ, ctx ⊢ x ∶ L

Γ y = HΓ, ctx ⊢ y ∶ H

Γ, ctx ⊢ x + y ∶ L ⊔ H

Conclusion: x+y :H(sinceL ⊔ H =H)

48

Page 50: Information Flow - cs.cornell.edu

Assignment Rule

x ≔ E– causes: E → x– requires: Γ E ⊑ Γ(x)

Assign:), +,- ⊢ /∶ 1 , 1 ⊔ +,- ⊑ ) -

),+,- ⊢ - ≔ /

49

Page 51: Information Flow - cs.cornell.edu

if Rule

Γ, ctx ⊢ e ∶ λ , Γ, λ ⊔ ctx ⊢ C. , Γ, λ ⊔ ctx ⊢ C/Γ, ctx ⊢ 01 e 2345 C. 4674 C/ 10

50

Page 52: Information Flow - cs.cornell.edu

if Rule Example Proof

1. Constant:

#, (& ⊔ ()*) ⊢ -:&

2. Assign:#, (& ⊔ ()*) ⊢ -:&, & ⊔(&⊔ ()*) ⊑ #(*)

#, &⊔ ()* ⊢ *≔-3. if

Γ, ctx ⊢ y>0 : L Γ, L ⊔ctx ⊢ x≔1 Γ, L ⊔ctx ⊢ x≔2Γ, ctx ⊢ if y>0 then x≔1 else x≔2 @i

51

Page 53: Information Flow - cs.cornell.edu

while Rule

while:Γ, ctx ⊢ e: λ Γ , λ ⊔ ctx ⊢ CΓ, ctx ⊢ 01234 e 56 c 475

52

Page 54: Information Flow - cs.cornell.edu

; (sequence) rule

Γ, ctx ⊢ C(, Γ, ctx ⊢ C)Γ, ctx ⊢ C( ; C)

53

Page 55: Information Flow - cs.cornell.edu

secL Type System Retrospective

● Soundness– Type correct programs satisfy

§ Flow-Label Invariant: vàw ⟹ Γ(v) ⊑ Γ(w)§ Relational non-interference (RNI)

– If program doesn’t satisfy§ Flow-Label invariant or§ RNIthen program won’t be type correct.

54

Page 56: Information Flow - cs.cornell.edu

secL Type System Retrospective

● (in)Completeness– The type system is incomplete.– If a program is not type correct then that program

might still satisfy Flow-Label invariant and RNI.

–",$%&⊢(∗*∶,, ,⊔.⊑" &",. ⊢ &≔(∗*

55

If Γ x = L …• Type checking fails• FBAC invariant valid• RNI satisfied.

Page 57: Information Flow - cs.cornell.edu

secL Type System Retrospective

● (in)Completeness– The type system is incomplete.– If a program is not type correct then that program

might still satisfy Flow-Label invariant and RNI.

–",$%&⊢(∗*∶,, ,⊔.⊑" &",. ⊢ &≔(∗*

56

If Γ x = L …• Type checking fails• FBAC invariant valid• RNI satisfied.

If Γ x = L …• Type checking fails• FLI invariant valid• RNI satisfied.

Page 58: Information Flow - cs.cornell.edu

Eliminate Incompleteness?

Sequence ruleΓ, ctx ⊢ C(, Γ, ctx ⊢ C)

Γ, ctx ⊢ C( ; C)Consider:

+, h > 0 0123 4; v6 ≔ 2 29:2 :;+< ,+● Satisfies RNI (=termination insensitive) if C diverges.● Sequence rule must predict that 4( diverges.

– Predicting divergence requires solving the halting problem.

57

Page 59: Information Flow - cs.cornell.edu

Program with Termination Channel

!"#$% v' > 0 *+ ,-#. %/*; v1 ≔ 2

● Program is secL type correct.● Program satisfies RNI.● Program does not satisfy termination sensitive

non interference (TSNI): v'→ ⊥

58

Page 60: Information Flow - cs.cornell.edu

Type system for TSNI

Prevent channel arising from infinite loops.– Allow only L terms in while guards.

§ Loop termination does not depend of H values.&,()* ⊢ ,:. &,()* ⊢ /&,()* ⊢ 01234 , 56 / 475

– Type correct programs now exhibit TSNI.– What about loops involving H terms?

59