A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

53
A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow Torben Amtoft K , Josiah Dodds P , Zhi Zhang K , Andrew Appel P , Lennart Beringer P , John Hatcliff K , Xinming Ou K , Andrew Cousino K K = Kansas State University P = Princeton University Information Flow Static Analysis SMT Solver Foundational Checker SMT result checker Evidence

description

Information Flow Static Analysis. Foundational Checker. Evidence. SMT Solver. SMT result checker. A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow. Torben Amtoft K , Josiah Dodds P , Zhi Zhang K , Andrew Appel P , - PowerPoint PPT Presentation

Transcript of A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Page 1: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Torben AmtoftK, Josiah DoddsP, Zhi ZhangK, Andrew AppelP,Lennart BeringerP, John HatcliffK, Xinming OuK, Andrew CousinoK

K = Kansas State University P = Princeton University

Information Flow Static Analysis

SMT Solver

Foundational Checker

SMT result checker

Evidence

Page 2: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

2

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

SPARK annotations

#derives x from y

Formally verified static

analysis{}X[3]:=Y{}

Advanced rules for agreement

logic

{}X:=Y{}

Formally Verified agreement logic

analysis

Page 3: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

3

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

SPARK annotations

#derives x from y

Formally verified static

analysis{}X[3]:=Y{}

Advanced rules for agreement

logic

{}X:=Y{}

Formally Verified agreement logic

analysis

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

Amtoft, T., Banerjee, A.: Information flow analysis in logical form. In Giacobazzi, R., ed.:SAS 2004. Volume 3148 of LNCS., Springer (2004) 100–115

Page 4: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

4

Agreement Logic

means x has the same value when evaluated in and

ProgramProgram{x⋉}{y \} ⋉𝑧1 𝑧 2𝑦 1𝑦 2

𝑥1 𝑥2

𝑦 1

𝑥2

Proof!

Page 5: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

5

#derives x from y

Page 6: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

6

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

SPARK annotations

#derives x from y

Formally verified static

analysis{}X[3]:=Y{}

Advanced rules for agreement

logic

{}X:=Y{}

Formally Verified agreement logic

analysis

SPARK annotations

#derives x from y

Chapman, R., Hilton, A.: Enforcing security and safety models with an information flowanalysis tool. ACM SIGAda Ada Letters XXIV (2004) 39–46

Page 7: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

7

SPARK annotations

The SPARK programming language has annotations for information flow

The annotation #derives x from y means that only information from y might flow into x

SPARK has a static analysis to check this type of contract

These annotations are not always as expressive as programmers want

Page 8: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

8

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

SPARK annotations

#derives x from y

Formally verified static

analysis{}X[3]:=Y{}

Advanced rules for agreement

logic

{}X:=Y{}

Formally Verified agreement logic

analysis

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

SPARK annotations

#derives x from y

{}X[3]:=Y{}

Advanced rules for agreement

logic

Amtoft, T., Hatcliff, J., Rodriguez, E.: Precise and automated contract-based reasoning forverification and certification of information flow properties of programs with arrays. InGordon, A.D., ed.: ESOP’10. Volume 6012 of LNCS. (2010) 43–63

Page 9: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

9

Hoare-Style rules for agreement logic

inspired by SPARK annotations

verifies #derives x from y on the program

Page 10: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

10

Advanced rules for conditional information flow

More expressive rules

Rules for reasoning about specific array locations, rather than entire arrays at once

Page 11: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

11

Without conditional rules

More expressive rules

Rules for reasoning about specific array locations, rather than entire arrays at once

Page 12: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

12

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

SPARK annotations

#derives x from y

Formally verified static

analysis{}X[3]:=Y{}

Advanced rules for agreement

logic

{}X:=Y{}

Formally Verified agreement logic

analysis

Formally verified static

analysis

Leroy, X. 2003. Java bytecode verification: Algorithms and formalizations. Journal of Automated Reasoning 30, 235–269.

A.W. Appel. VeriSmall: Verified Smallfoot shape analysis. CPP 2011: First International Conference on Certified Programs and Proofs, (2011).

Leroy, X.: Formal certification of a compiler back-end or: programming a compiler with aproof assistant. POPL’06. (2006) 42–54

Y. Bertot. A Coq formalization of a type checker for object initialization in theJava virtual machine. CAV'01.

D. Aspinall, L. Beringer, M. Hofmann, H.-W. Loidl, and A. Momigliano. A programlogic for resource verification. TPHOLs 2004, volume 3223 ofLNCS, pages 34–49. Springer, 2004.

Page 13: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

13

ProofProof

Formally verified static analysisMany single-execution analyses

Formalizing the verifications require formalizing type-systems, operational semantics, and source languages

Soundness relates analyzer to operational semantics

Static Analysis Static AnalysisorWitness

Verified Results

Verified Results

Page 14: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

14

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

SPARK annotations

#derives x from y

Formally verified static

analysis{}X[3]:=Y{}

Advanced rules for agreement

logic

{}X:=Y{}

Formally Verified agreement logic

analysis

Static analysis for conditional

information flow

Page 15: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

15

𝑋⋉Agreement Logic

SPARK annotations

#derives x from y

Formally verified static

analysis{}X:=Y{}

Hoare-Style rules for

agreement logic

{}X:=Y{}

Formally Verified agreement logic

analysis

Page 16: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

16

Contributions

Implemented a static analysis with advanced rules for conditional information flow

Analysis generates witnesses to be formally verified in Coq

If the witness verifies, the result of the analysis is correct with respect to the operational semantics

Page 17: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

17

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

SPARK annotations

#derives x from y

Formally verified static

analysis{}X[3]:=Y{}

Advanced rules for agreement

logic

{}X:=Y{}

Formally Verified agreement logic

analysis

Page 18: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

18

\{𝑌 ⋉ \}X :=Y \{ 𝑋 ⋉ \}Agreement Logic

SPARK annotations

#derives x from y

Formally verified static

analysis{}X[3]:=Y{}

Advanced rules for agreement

logic

{}X:=Y{}

Formally Verified agreement logic

analysis

Page 19: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

19

Information Flow Static Analysis

SMT Solver

Foundational Checker

SMT result checker

Evidence

Michael Armand, Germain Faure, Benjamin Gregoire, Chantal Keller, Laurent Thíery & Benjamin Werner (2011): Verifying SAT and SMT in Coq for a fully automated decision procedure. In: PSATTT ’11

Page 20: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

20

Example Application Program

Page 21: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

21

Mailbox Example

if IN_1_RDY and not OUT_0_RDY then

DATA_1 := IN_1 DAT;

IN_1_RDY := false;

OUT_0_DAT := DATA_1;

OUT_0_RDY := true;

end if;

Page 22: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

22

Mailbox Example{IN_1_RDY OUT_0_RDY IN_1_DAT ⋉ IN_1_RDY OUT_0_RDY OUT_0_DAT ⋉ IN_1_RDY OUT_0_RDY }⋉ ⋉if IN_1_RDY and not OUT_0_RDY then

{IN_1_DAT }⋉DATA_1 := IN_1 DAT;{DATA_1 }⋉IN_1_RDY := false;{DATA_1 }⋉OUT_0_DAT := DATA_1;{OUT_0_DAT }⋉OUT_0_RDY := true;{OUT_0_DAT }⋉

end if;{OUT_0_DAT }⋉

Page 23: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

23

2-Assertions

⟦𝐸 ⟧𝑆1=⟦𝐸 ⟧S2𝑆1 ,𝑆2⊨E⋉

Page 24: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

24

2-Assertions

⟦𝐸 ⟧𝑆1=⟦𝐸 ⟧S2𝑆1 ,𝑆2⊨E⋉

Page 25: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

25

2-Assertions

⟦𝐸 ⟧𝑆1=⟦𝐸 ⟧S2𝑆1 ,𝑆2⊨E⋉

Page 26: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

26

2-Assertions

¬( ⟦𝐸 ⟧¿¿𝑆1∨ ⟦𝐸 ⟧S2)∨ ⟦𝐸 ⟧𝑆1= ⟦𝐸 ⟧S 2𝑆1 ,𝑆2⊨ϕ⇒E⋉ ¿

Page 27: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

27

2-Assertions

(¬ ⟦𝜙 ⟧¿¿𝑆1∨¬ ⟦𝜙 ⟧S 2)∨ ⟦𝐸 ⟧𝑆1= ⟦𝐸 ⟧S 2

𝑆1 ,𝑆2⊨ϕ⇒E⋉ ¿

Page 28: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

28

Triples

Holds when

Page 29: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

29

Hoare TripleFixpoint validHoareTriple (X: list SkalVar) C (asns: assns):= match asns with | Assns => (forall, lookupsComplete X -> (twoAssnsInterpretation ) -> Opsem C -> Opsem C -> (twoAssnsInterpretation )) | …

Page 30: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

30

(twoAssnsInterpretation ) ->Opsem C -> Opsem C ->(twoAssnsInterpretation ))

Page 31: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

31

Evidence

Evidence takes the form

If is well typed and the evidence statements are sound wrt. the operational semantics of our language we have a valid triple. Each form of evidence corresponds directly to a coq constructor.

Page 32: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

32

Rules❑

⊢ AssignE (Θ , 𝑥 , 𝐴 ):{Θ [ 𝐴𝑥 ]}𝑥≔𝐴 {Θ }

❑⊢ AssertE (𝐵 ) : {𝐵⇒Θ }Assert (𝐵) {Θ }

❑⊢Skip E (Θ ) : {Θ }Skip {Θ }

Page 33: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

33

Conditional rule⊢𝜂1 : {Θ1 }𝐶1 {𝜙 ′⇒𝐸⋉ }⊢𝜂2: {Θ2 }𝐶2 {𝜙 ′⇒𝐸  ⋉ }⊢𝜈 :𝜙𝐶

𝜙❑′

⊢CondE (𝜂1 ,𝜂2 ,𝜈 ,𝐵 ) : {𝐵⇒Θ1∧ (¬𝐵⇒Θ2 )∧ (𝜙⇒ 𝐵  ⋉ ) }𝐶 {𝜙 ′⇒𝐸  ⋉ }

Evidence exists for the triple if

Evidence exists for both branches of We have Necessary Precondition (NPC) evidence for and across

Page 34: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

34

Coq Evidence Type

Evidence is an inductive proposition:

Inductive TEvid (X: list SkalVar) : Command -> assns -> Prop :=| TSkipE ...| TAAssignE ...| TCondE ......

Page 35: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

35

Coq Evidence Type

| TAAssignE : forall Theta x A, TEvid X (Assign x (AExp A)) (Assns(TwoAssnsSubstA Theta x A) Theta)

⊢ AssignE (Θ , 𝑥 , 𝐴 ):{Θ [ 𝐴𝑥 ]}𝑥≔𝐴 {Θ }

Page 36: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

36

Evidence Soundness

(

)

Page 37: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

37

Soundness StatementTheorem soundness : forall X {C asns}, TEvid X C asns -> (validHoareTriple X C asns)

Paper proof is done. Coq proof is complete for all but the loop rules WhileE and ForPolyE

Page 38: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

38

Precondition Generator in Coq

Evidence is large

Move from generating a witness to implementing algorithm

ProofProof

38

Static Analysis Static AnalysisorWitness

Verified Results

Verified Results

Page 39: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

39

Future Work

Complete Coq proofs

Verify SMT results

Finish Coq precondition generator

Hook up to a certified compiler for an end-to-end system

Evaluate the tool on more real-world examples

Page 40: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

40

Questions

Page 41: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Assignment Rule

Example

{y#}x:=y{x#}

⊢ AssignE (𝑇 ,𝑥 , 𝐴) :{𝑇 [ 𝐴𝑥 ]}𝑥≔𝐴 {𝑇 }

Page 42: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Post-condition form

The post-condition of some rules takes the form

Post-conditions of this form specify the information-flow properties we are interested in

Page 43: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Post-condition form

Our algorithm generates triples of the form

The values of might flow into variable when the respective hold

We do this for each modified in C

Page 44: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Conditional

Page 45: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Conditional Example{secure#, secure => low#, !secure => hi#}if secure then {low} hi := lowelse {hi#} low := hifi{low#}

Page 46: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Checking the Evidence

We said earlier that is a proof that we have generated a valid triple if is typed correctly and if our evidence is proven sound.

To actually verify this we define evidence as a coq type and prove it sound with respect to the defined operational semantics

Page 47: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Coq Evidence

We use a deep embedding of the logic and programming language

The operational semantics of our core language are defined in coq

Page 48: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Two assertions ()

Inductive twoSatisfies(s1 s2:State): TwoAssn -> Prop :=|TwoSatisfies: forall B E, BEval B s1 = Some true ->BEval B s2 = Some true -> (Eval E s1 = Eval E s2) -> twoSatisfies s1 s2 (B, E).

Page 49: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Precondition Generator in CoqFixpoint generatePrecondition

(c:Command) (post:TwoAssns) (X: list SkalVar): (TwoAssns * list SkalVar) := ...

Theorem generatePreconditionEvidence: forall C Y X Z post pre, (pre, X)=generatePrecondition C post Z ->

allVarsIn X Y = true-> TEvid Y C (Assns pre post).

Page 50: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Conclusions

Fully automated and formally verified information flow contract checker

Piece of an eventual end-to-end system

Page 51: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

End

Page 52: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Semantics𝑆⊨𝐵⇔ ⟦ 𝐵 ⟧𝑆=𝑡𝑟𝑢𝑒

𝑆1 ,𝑆2⊨¬𝑇1∨𝑆1 ,𝑆2 ,⊨𝑇 2

𝑆1 ,𝑆2⊨𝑇 1⇒𝑇2

𝑆1⊨𝐵𝑆2⊨𝐵𝑆1 ,𝑆2⊨𝐵

⟦𝐵 ⟧𝑆1= ⟦𝐵 ⟧S2

𝑆1 ,𝑆2⊨𝐵⋉

Page 53: A Certificate Infrastructure for Machine-Checked Proofs of Conditional Information Flow

Previous work

SIFL precondition algorithm to check conditional information flow policies

Algorithm uses an agreement logic with hoare-style rules

Allows for precise treatment of arrays and for loops