Tool-Assisted Specification and Verification of the JavaCard - - PowerPoint PPT Presentation

tool assisted specification and
SMART_READER_LITE
LIVE PREVIEW

Tool-Assisted Specification and Verification of the JavaCard - - PowerPoint PPT Presentation

Tool-Assisted Specification and Verification of the JavaCard Platform Gilles Barthe INRIA Sophia-Antipolis, France Joint work with: P . Courtieu, G. Dufay, M. Huisman, L. Jakubiec, B. Serpette, S. Melo de Sousa, S.


slide-1
SLIDE 1

Tool-Assisted Specification and Verification of the JavaCard Platform

Gilles Barthe INRIA Sophia-Antipolis, France Joint work with: P . Courtieu, G. Dufay, M. Huisman,

  • L. Jakubiec, B. Serpette, S. Melo de Sousa, S. Stratulat
  • ✁✄✂
☎ ✆ ✝
slide-2
SLIDE 2

New generation smartcards

  • Flexibility
  • High-level language for developing applets
  • Multi-application and post-issuance
  • New Security Threats
  • Confidentiality
  • Integrity
  • Availability
  • ✁✄✂
✝ ✆ ✝
slide-3
SLIDE 3

Formal verification for smartcards

  • Motivations
  • Complex software with high demands on security
  • Common Criteria require formal methods at levels

EAL5-EAL7

  • ✁✄✂
slide-4
SLIDE 4

Formal verification for smartcards

  • Motivations
  • Complex software with high demands on security
  • Common Criteria require formal methods at levels

EAL5-EAL7

  • Focus
  • Platform vs. program verification
  • Bytecode vs. source level
  • ✁✄✂
slide-5
SLIDE 5

Overview

  • JavaCard
  • CertiCartes: verification of the JavaCard platform
  • Jakarta: tool support for specification and verification
  • f virtual machines
  • ✁✄✂
slide-6
SLIDE 6

JavaCard

  • A superset of a subset of Java:
  • A subset: no large datatypes, security manager,

dynamic class loading, (garbage collection). . .

  • A superset: firewall, entry points, shareable

interfaces, transactions, etc.

  • JavaCard programs use the JavaCard APIs
  • ✁✄✂
slide-7
SLIDE 7

The JavaCard Platform

Virtual Machine APIs Industry−Specific Extensions Operating System

011100011 101011010 011111001 110110111 100100110

Applet

011100011 101011010 011111001 110110111 100100110

Applet

011100011 101011010 011111001 110110111 100100110

Applet

Linking Loading

011100011 101011010 011111001 110110111 100100110

Java compiler Class File Converter Cap File Builder

package fr.inri import javacar public class no public Object

011100011 101011010 011111001 110110111 100100110

Bytecode verifier Class file

Java source Cap file

  • ✁✄✂
slide-8
SLIDE 8

CertiCartes

Formal specification/verification of:

  • JCVMs: small-step semantics

exec : state

  • > returned_state
  • written in Coq but use a neutral style
  • executable with the JCVM Tools
  • BCV: executable in Caml
  • part of the JCRE
  • ✁✄✂
✁ ✆ ✝
slide-9
SLIDE 9

Program model

Record jcprogram : Set : = { i n t e r f a c e s : ( l i s t Interface classes : ( l i s t Class ) ; methods : ( l i s t Method ) Record Method : Set : = { i s _ s t a t i c : bool ; signature : ( ( l i s t type )

  • type ) ;

l o c a l : nat ; (

  • Number of

l o c a l h a n d l e r _ l i s t : ( l i s t handler_type ) ; (

  • Exception

handl bytecode : ( l i s t I n s t r u c t i o n ) ; (

  • i n s t r u c t i o n s

to method_id : method_idx ; (

  • Index
  • f

the me

  • wner

: class_idx (

  • Index
  • f

the ow

  • ✁✄✂
✁ ✆ ✝
slide-10
SLIDE 10

Memory model

  • Stack as a list of frames

Record frame : Set : = { locvars : ( l i s t valu ) ; (

  • Local

Varia

  • pstack

: ( l i s t valu ) ; (

  • Operand sta

p_count : bytecode_idx ; (

  • Program co

method_loc : method_idx ; (

  • Location
  • context_ref

: package ; (

  • Context

Inf

  • State

D e f i n i t i o n state : = static_heap

  • heap
  • stack .
  • ✁✄✂
slide-11
SLIDE 11

Instruction

D e f i n i t i o n NEW : = [ idx : cap_class_idx ] [ state : jcvm_state ] Cases ( stack_f state ) of ( cons h l f ) = > (

  • Extract

the owner class from thew c a p _ fi l e

  • )

Cases ( Nth_elt ( classes cap ) idx ) of (

  • then a new instance

i s created and pushed i n t o the heap

  • )

(Some c l ) = > l e t new_obj = . . . in ( Normal ( Build_jcvm_state ( sheap_f state ) ( app ( heap_f state ) new_obj ) (

  • the

reference

  • f

the created

  • bject

i s pushed i n t o the

  • pstack
  • )

( cons ( update_opstack ( cons ( vRef ( vRef_instance idx ( S ( length ( heap_f state ) l f ) ) ) | None = > ( AbortCode class_membership_error state ) end | _ = > ( AbortCode state_error state ) end .

  • ✁✄✂
☎✁ ✆ ✝
slide-12
SLIDE 12

Virtual Machines Specification

  • Defensive JCVM is closest to specification:
  • It manipulates typed values
  • Types are checked at run-time
  • ✁✄✂
☎ ☎ ✆ ✝
slide-13
SLIDE 13

Virtual Machines Specification

  • Defensive JCVM is closest to specification:
  • It manipulates typed values
  • Types are checked at run-time
  • Offensive JCVM is closest to implementation:
  • It manipulates untyped values
  • Type correctness enforced by BCV
  • ✁✄✂
☎ ☎ ✆ ✝
slide-14
SLIDE 14

Virtual Machines Specification

  • Defensive JCVM is closest to specification:
  • It manipulates typed values
  • Types are checked at run-time
  • Offensive JCVM is closest to implementation:
  • It manipulates untyped values
  • Type correctness enforced by BCV
  • Abstract JCVM used in bytecode verification:
  • Manipulates types as values
  • Operates on a method-per-method basis
  • ✁✄✂
☎ ☎ ✆ ✝
slide-15
SLIDE 15

Cross-Validation

Defensive and offensive VMs coincide on programs that are well-typed for the abstract VM

  • ✁✄✂
☎ ✝ ✆ ✝
slide-16
SLIDE 16

Cross-Validation

Defensive and offensive VMs coincide on programs that are well-typed for the abstract VM

  • ffensive and defensive VMs coincide on programs

well-typed for the defensive VM

  • ✁✄✂
☎ ✝ ✆ ✝
slide-17
SLIDE 17

Cross-Validation

Defensive and offensive VMs coincide on programs that are well-typed for the abstract VM

  • ffensive and defensive VMs coincide on programs

well-typed for the defensive VM

  • programs that are well-typed for the abstract VM are

well-typed with the defensive VM

  • ✁✄✂
☎ ✝ ✆ ✝
slide-18
SLIDE 18

Cross-Validation

Defensive and offensive VMs coincide on programs that are well-typed for the abstract VM

  • ffensive and defensive VMs coincide on programs

well-typed for the defensive VM

  • programs that are well-typed for the abstract VM are

well-typed with the defensive VM Best viewed as some form of correctness of abstract interpretations

  • ✁✄✂
☎ ✝ ✆ ✝
slide-19
SLIDE 19

Offensive vs. Defensive

  • Abstraction function:
✂✁ ✄ ☎ ✆✞✝ ✟ ✠ ✡☞☛ ✠
  • ✁✄✂
slide-20
SLIDE 20

Offensive vs. Defensive

  • Abstraction function:
✂✁ ✄ ☎ ✆✞✝ ✟ ✠ ✡☞☛ ✠
  • Diagram commutes
✂✁ ✄ ☎ ✄✝✆ ✞ ✟✡✠
  • ☛✝☞
✌ ☞ ✍
  • ✏✎
✁ ✄ ☎ ✄✝✆ ✞ ✑ ✟✡✠
✁ ✄ ☎ ✄✝✆ ✓ ☞ ✌ ☞ ✍
✎ ✁ ✄ ☎ ✄✝✆

if defensive VM does not raise typing errors

  • ✁✄✂
slide-21
SLIDE 21

Abstract vs. Defensive

  • Abstraction function:
✂✁
✆✞✝ ✟ ✠ ✡ ☛ ✝
  • ✁✄✂
slide-22
SLIDE 22

Abstract vs. Defensive

  • Abstraction function:
✂✁
✆✞✝ ✟ ✠ ✡ ☛ ✝
  • Diagram commutes
✂✁ ✄ ☎ ✄✝✆ ✞ ✟✁
  • ☛✝☞
✌ ☞ ✍
  • ✏✎
✁ ✄ ☎ ✄✝✆ ✞ ✑ ✟
✁ ✄ ☎ ✄✝✆ ✂ ☞ ✌ ☞ ✍
✎ ✁ ✄ ☎ ✄ ✆ ✄

if “execution keeps in the same frame”

  • ✁✄✂
slide-23
SLIDE 23

Bytecode verifier

  • Reject programs which go wrong (on the abstract

VM) using dataflow analysis (Kildall’s algorithm)

  • ✁✄✂
slide-24
SLIDE 24

Bytecode verifier

  • Reject programs which go wrong (on the abstract

VM) using dataflow analysis (Kildall’s algorithm)

  • Defensive and offensive machines coincide on

programs that pass bytecode verification

  • ✁✄✂
slide-25
SLIDE 25

Bytecode verifier

  • Reject programs which go wrong (on the abstract

VM) using dataflow analysis (Kildall’s algorithm)

  • Defensive and offensive machines coincide on

programs that pass bytecode verification

  • Proof builds upon commuting diagrams, correctness
  • f DFA, methodwise verification, and monotonicity of

abstract VM

  • ✁✄✂
slide-26
SLIDE 26

Assessment

  • Positive evaluation from Gemplus but CertiCartes is

an in-depth feasibility study

  • ✁✄✂
slide-27
SLIDE 27

Assessment

  • Positive evaluation from Gemplus but CertiCartes is

an in-depth feasibility study

  • A complete formalization of the JavaCard platform is

labour intensive (E. Giménez)

  • ✁✄✂
slide-28
SLIDE 28

Assessment

  • Positive evaluation from Gemplus but CertiCartes is

an in-depth feasibility study

  • A complete formalization of the JavaCard platform is

labour intensive (E. Giménez)

  • The methodology works well and could be used for
  • ther analyses
  • ✁✄✂
slide-29
SLIDE 29

Assessment

  • Positive evaluation from Gemplus but CertiCartes is

an in-depth feasibility study

  • A complete formalization of the JavaCard platform is

labour intensive (E. Giménez)

  • The methodology works well and could be used for
  • ther analyses
  • High-level of automation is possible
  • ✁✄✂
slide-30
SLIDE 30

Assessment

  • Positive evaluation from Gemplus but CertiCartes is

an in-depth feasibility study

  • A complete formalization of the JavaCard platform is

labour intensive (E. Giménez)

  • The methodology works well and could be used for
  • ther analyses
  • High-level of automation is possible
  • Specifications use a restricted language and proofs

use well-understood techniques

  • ✁✄✂
slide-31
SLIDE 31

Jakarta

  • A dedicated environment for formal specification and

verification of typed low-level languages

  • ✁✄✂
☎ ✁ ✆ ✝
slide-32
SLIDE 32

Jakarta

  • A dedicated environment for formal specification and

verification of typed low-level languages

  • Designed to support:
  • executable specifications
  • abstractions (and refinement) of specifications
  • automation of correctness proofs
  • ✁✄✂
☎ ✁ ✆ ✝
slide-33
SLIDE 33

Current focus

  • Input: defensive virtual machine
  • ✁✄✂
☎ ✁ ✆ ✝
slide-34
SLIDE 34

Current focus

  • Input: defensive virtual machine
  • Output:
  • ✁✄✂
☎ ✁ ✆ ✝
slide-35
SLIDE 35

Current focus

  • Input: defensive virtual machine
  • Output:
  • ffensive and abstract virtual machines
  • ✁✄✂
☎ ✁ ✆ ✝
slide-36
SLIDE 36

Current focus

  • Input: defensive virtual machine
  • Output:
  • ffensive and abstract virtual machines
  • ffensive and defensive machines coincide on

well-typed programs

  • ✁✄✂
☎ ✁ ✆ ✝
slide-37
SLIDE 37

Current focus

  • Input: defensive virtual machine
  • Output:
  • ffensive and abstract virtual machines
  • ffensive and defensive machines coincide on

well-typed programs

  • programs that are ill-typed for the defensive VM

are ill-typed with the abstract VM

  • ✁✄✂
☎ ✁ ✆ ✝
slide-38
SLIDE 38

Current focus

  • Input: defensive virtual machine
  • Output:
  • ffensive and abstract virtual machines
  • ffensive and defensive machines coincide on

well-typed programs

  • programs that are ill-typed for the defensive VM

are ill-typed with the abstract VM

  • the abstract virtual machine is monotone
  • ✁✄✂
☎ ✁ ✆ ✝
slide-39
SLIDE 39

Jakarta Specification Language

  • JSL types are first-order polymorphic types
  • JSL expressions are first-order algebraic terms
✁ ✂
  • ✂☎✄
  • Functions defined by conditional rewrite rules
✝✟✞ ✠ ✡ ✞ ✟ ☛ ☛ ☛ ✟ ✝ ☞ ✠ ✡ ☞ ✌ ✍

where

✡✏✎

are patterns with fresh variables

  • ✁✄✂
slide-40
SLIDE 40

Compiling JSL Specifications

  • Specifications are executed by rewriting engines
  • Deterministic specifications are compiled into

case-expressions then CAML, Coq, Isabelle, PVS

  • Non-deterministic specifications
☎ ✁

are translated into

✄ ☎
  • Partial specifications

are translated into

✂ ☎
  • ✁✄✂
✝ ✁ ✆ ✝
slide-41
SLIDE 41

Abstractions

  • For each datatype
  • define
  • and
✁ ☛ ✂ ✄ ☎
  • ✁✄✂
✝ ☎ ✆ ✝
slide-42
SLIDE 42

Abstractions

  • For each datatype
  • define
  • and
✁ ☛ ✂ ✄ ☎
  • For each defined function

, define

  • by transforming
✝ ✞ ✠ ✡ ✞ ✟ ☛ ☛ ☛ ✟ ✝ ☞ ✠ ✡ ☞ ✌ ✍

into

✁ ✝ ✞ ✂ ✠ ✁ ✡ ✞ ✂ ✟ ☛ ☛ ☛ ✟ ✁ ✝ ☞ ✂ ✠ ✁ ✡ ☞ ✂ ✁ ✌ ✂ ✁ ✍ ✂
  • ✁✄✂
✝ ☎ ✆ ✝
slide-43
SLIDE 43

Abstractions

  • For each datatype
  • define
  • and
✁ ☛ ✂ ✄ ☎
  • For each defined function

, define

  • by transforming
✝ ✞ ✠ ✡ ✞ ✟ ☛ ☛ ☛ ✟ ✝ ☞ ✠ ✡ ☞ ✌ ✍

into

✁ ✝ ✞ ✂ ✠ ✁ ✡ ✞ ✂ ✟ ☛ ☛ ☛ ✟ ✁ ✝ ☞ ✂ ✠ ✁ ✡ ☞ ✂ ✁ ✌ ✂ ✁ ✍ ✂
  • Not a legal rule: substitution and cleaning steps

declared in abstraction scripts

  • ✁✄✂
✝ ☎ ✆ ✝
slide-44
SLIDE 44

Abstractions

  • For each datatype
  • define
  • and
✁ ☛ ✂ ✄ ☎
  • For each defined function

, define

  • by transforming
✝ ✞ ✠ ✡ ✞ ✟ ☛ ☛ ☛ ✟ ✝ ☞ ✠ ✡ ☞ ✌ ✍

into

✁ ✝ ✞ ✂ ✠ ✁ ✡ ✞ ✂ ✟ ☛ ☛ ☛ ✟ ✁ ✝ ☞ ✂ ✠ ✁ ✡ ☞ ✂ ✁ ✌ ✂ ✁ ✍ ✂
  • Not a legal rule: substitution and cleaning steps

declared in abstraction scripts

  • Generated offensive and abstract JCVMs
  • ✁✄✂
✝ ☎ ✆ ✝
slide-45
SLIDE 45

Proof automation using Coq

  • Mostly case analysis + equational reasoning
  • ✁✄✂
✝ ✝ ✆ ✝
slide-46
SLIDE 46

Proof automation using Coq

  • Mostly case analysis + equational reasoning
  • Built tactics that reduce
  • ✆✂✁
☛ ✆ ✆✂✁ ✟ ✆✂✁ ✡

to

✄ ☎✝✆ ✞ ☎✠✟☛✡ ✄ ☎✝☞ ✞ ☎ ✟ ✌ ✡ ✍✏✎ ✑ ✒ ✎ ✓ ✡ ✡ ✡ ✓ ✍✕✔ ✑ ✒ ✔ ✖ ✗ ✘ ☎✝✆✚✙ ✛ ☎ ✆ ✜

and perform some equational reasoning

  • ✁✄✂
✝ ✝ ✆ ✝
slide-47
SLIDE 47

Proof automation using Coq

  • Mostly case analysis + equational reasoning
  • Built tactics that reduce
  • ✆✂✁
☛ ✆ ✆✂✁ ✟ ✆✂✁ ✡

to

✄ ☎✝✆ ✞ ☎✠✟☛✡ ✄ ☎✝☞ ✞ ☎ ✟ ✌ ✡ ✍✏✎ ✑ ✒ ✎ ✓ ✡ ✡ ✡ ✓ ✍✕✔ ✑ ✒ ✔ ✖ ✗ ✘ ☎✝✆✚✙ ✛ ☎ ✆ ✜

and perform some equational reasoning

  • Further automation of equational reasoning

is highly desirable

  • ✁✄✂
✝ ✝ ✆ ✝
slide-48
SLIDE 48

Proof automation using Coq

  • Mostly case analysis + equational reasoning
  • Built tactics that reduce
  • ✆✂✁
☛ ✆ ✆✂✁ ✟ ✆✂✁ ✡

to

✄ ☎✝✆ ✞ ☎✠✟☛✡ ✄ ☎✝☞ ✞ ☎ ✟ ✌ ✡ ✍✏✎ ✑ ✒ ✎ ✓ ✡ ✡ ✡ ✓ ✍✕✔ ✑ ✒ ✔ ✖ ✗ ✘ ☎✝✆✚✙ ✛ ☎ ✆ ✜

and perform some equational reasoning

  • Further automation of equational reasoning

is highly desirable

  • Exploiting abstraction scripts seems promising
  • ✁✄✂
✝ ✝ ✆ ✝
slide-49
SLIDE 49

Proof automation using Spike

  • Spike is a first-order prover for “inductive theorems”
  • ✁✄✂
slide-50
SLIDE 50

Proof automation using Spike

  • Spike is a first-order prover for “inductive theorems”
  • Cross-validation of the VMs for 2/3 of bytecodes
  • ✁✄✂
slide-51
SLIDE 51

Proof automation using Spike

  • Spike is a first-order prover for “inductive theorems”
  • Cross-validation of the VMs for 2/3 of bytecodes
  • Now applying Spike to prove the monotonicity of

abstract VM

  • ✁✄✂
slide-52
SLIDE 52

Conclusions

  • Formal specification and verification of the JavaCard

platform is feasible but labor-intensive

  • ✁✄✂
slide-53
SLIDE 53

Conclusions

  • Formal specification and verification of the JavaCard

platform is feasible but labor-intensive

  • Tool support for formal specification and verification
  • f (type safety for) low-level typed languages
  • ✁✄✂
slide-54
SLIDE 54

Conclusions

  • Formal specification and verification of the JavaCard

platform is feasible but labor-intensive

  • Tool support for formal specification and verification
  • f (type safety for) low-level typed languages
  • Some interesting topics:
  • extracting code or tests from specifications
  • tools for certifying certifying compilers
  • ✁✄✂
slide-55
SLIDE 55

Conclusions

  • Formal specification and verification of the JavaCard

platform is feasible but labor-intensive

  • Tool support for formal specification and verification
  • f (type safety for) low-level typed languages
  • Some interesting topics:
  • extracting code or tests from specifications
  • tools for certifying certifying compilers
  • For further information www.inria.fr/lemme/verificard
  • ✁✄✂