Code-Carrying Proofs

27
Code-Carrying Proofs Aytekin Vargun Rensselaer Polytechnic Institute

description

Code-Carrying Proofs. Aytekin Vargun Rensselaer Polytechnic Institute. Outline. Introduction Proof-Carrying Code (PCC) Code-Carrying Proofs(CCP) Sample CCP session Future Work. Potential Problems to be Solved. Memory Safety illegal operations or illegal access to memory Security - PowerPoint PPT Presentation

Transcript of Code-Carrying Proofs

Page 1: Code-Carrying Proofs

Code-Carrying Proofs

Aytekin Vargun

Rensselaer Polytechnic Institute

Page 2: Code-Carrying Proofs

Outline

Introduction Proof-Carrying Code (PCC) Code-Carrying Proofs(CCP) Sample CCP session Future Work

Page 3: Code-Carrying Proofs

Potential Problems to be Solved

Memory Safety illegal operations or illegal access to memory

Security unauthorized access to data or system

resources Functional Correctness

whether the code does correctly what it is formally required to do

Page 4: Code-Carrying Proofs

Two Solutions

Proof-Carrying Code (PCC) Code-Carrying Proofs (CCP)

Page 5: Code-Carrying Proofs

Proof-Carrying Code (PCC)

Developed by Necula and Lee [1996] at CMU.

Basic Idea: Use machine-checkable proofs as certificates.

Proof construction is harder than proof checking Code producer provides the proof Code consumer checks it

Page 6: Code-Carrying Proofs

Code Producer

Code Consumer

Theorem Prover

Safety Policy

Native CodeWith Annotations

Proof Checker

Ok

CPU

VCGen

Verification Condition

Safety Policy

Safety Proof Safety Proof

VCGen

Verification Condition

Source Code Touchstone Compiler

Native CodeWith Annotations

PCC

Page 7: Code-Carrying Proofs

Code Producer

Code Consumer

Theorem Prover

Safety Policy

Native CodeWith Annotations

Proof Checker

No

CPU

VCGen

Verification Condition

Safety Policy

Safety Proof

Safety Proof

VCGen

Verification Condition(may change)

Source Code Touchstone Compiler

TamperedNative Code

With Annotations

Hacker

Tampered Code is not delivered to the CPU

But safety is still guaranteed if the code is modified in such a way that the VC is unchanged

PCCTampered

Page 8: Code-Carrying Proofs

Code Producer

Code Consumer

Theorem Prover

Safety Policy

Native CodeWith Annotations

Proof Checker

No

CPU

VCGen

Verification Condition

Safety Policy

Tampered Safety Proof

Safety Proof

VCGen

Verification Condition

Source Code Touchstone Compiler

Native CodeWith Annotations

Proof is either invalidoris not the proof of the VC

Hacker

PCCTampered

Page 9: Code-Carrying Proofs

Code Producer

Code Consumer

Theorem Prover

Safety Policy

Native CodeWith Annotations

Proof Checker

VCGen

Verification Condition

Safety Policy

VCGen

Verification Condition(may change)

Source Code Touchstone Compiler

TamperedNative Code

With Annotations

Hacker

Safety is guaranteedif the tampered proof is the proof of the new VC

Safety Proof

Hacker

Tampered Safety Proof

Ok

CPU

PCCTampered

Page 10: Code-Carrying Proofs

Foundational PCC

Developed by Appel in [2000] at Princeton VCGen is a large program. Replace it! Basic Idea:

Define the semantics of the machine instructions and safety rules

Use foundational mathematical logic instead of programming-language-specific axioms or safety rules

No particular type system

Page 11: Code-Carrying Proofs

Foundational PCC

Prove w.r.t. the formal machine language semantics

Operates at a very low level of abstraction It does reduce dependency on a large

program (VCGen) but this is true for CCP also

Page 12: Code-Carrying Proofs

Code-Carrying Proofs (CCP)

Start with axioms that define functions The form of axioms is such that it is easy to

extract executable code from them. Prove that the defined functions obey certain

requirements The producer transmits

Axioms The correctness theorems And their proofs

Page 13: Code-Carrying Proofs

Code-Carrying Proofs (CCP)

No explicit code transmission The consumer checks proofs to see if the

correctness theorem is proved If proof checking succeeds, the consumer

applies the code extractor to the axioms and obtain the executable code

Page 14: Code-Carrying Proofs

Code-Carrying Proofs (CCP)

CCP attempts to solve Functional Correctness problem

We are dealing with a higher-level language

Page 15: Code-Carrying Proofs

Code Producer

Code Consumer

Axioms & Proofs

Theorem Prover

Requirements

Axioms & Theorems

Proof Checker

CPUAxioms & Theorems Code Extractor Code

CCP

Requirements

Axioms & Proofs

Page 16: Code-Carrying Proofs

Code Producer

Code Consumer

Axioms & Proofs

Tampered Axioms & Proofs

Theorem Prover

Requirements

Requirements

Axioms & Theorems

Proof Checker

CPUCode Extractor

Hacker

(Failed Proofs) (No Code)

CCPTampered

Page 17: Code-Carrying Proofs

Issues

Encoding axioms and proofs Proof Checking Tests to be applied by the consumer to new

function definitions (definitional principle) Syntactic Property Consistency Termination

Implementing Code Extractor

Page 18: Code-Carrying Proofs

Athena

Implemented by K.Arkoudas A language for both:

Ordinary Computation Logical Deduction

Page 19: Code-Carrying Proofs

Athena Ordinary Computation Language

Provides higher-order functions Has primitive functions for

Unification Matching Substitution

Page 20: Code-Carrying Proofs

Athena Logical Language

Special Deductive Forms dcheck, dbegin, assume, …

Primitive Deduction Methods mp, both, left-and, …

Declarations structure, declare, …

Directives load-file, clear-assumption-base, …

Page 21: Code-Carrying Proofs

Athena Advantages

Better Proof Readability Machine checkable proofs Makes it possible to formulate and write

proofs as methods Generic Proofs

write the proof once and instantiate it to prove specific cases

Page 22: Code-Carrying Proofs

Code Extractor

Quantified Equations and Conditional Equations

These are clauses of a recursive function definition

CE has to be able to combine these into a recursive function

Page 23: Code-Carrying Proofs
Page 24: Code-Carrying Proofs
Page 25: Code-Carrying Proofs

Code Extractor

CE can extract pure functions it is not capable of extracting destructive

functions Example Functions:

searching functions, sum It cannot handle functions like:

in-place reverse, sort

Page 26: Code-Carrying Proofs

Code Extractor

We have been working on simple functions. But: In analogy to STL, it is useful to have a library

of simple functions from which more complex functions can be composed, especially if the functions are generic

It is possible for code extractor to extract complex functions composed of such simple functions

Page 27: Code-Carrying Proofs

Future Work

New Definitions and Tests to be applied Defining Memory More Proof Examples Improving the Code Extractor Memory Safety Generic Proofs and Proof packaging