Formal Security Analysis of Cryptographic Protocol Code - - PowerPoint PPT Presentation

formal security analysis of cryptographic protocol code
SMART_READER_LITE
LIVE PREVIEW

Formal Security Analysis of Cryptographic Protocol Code - - PowerPoint PPT Presentation

Formal Security Analysis of Cryptographic Protocol Code Karthikeyan Bhargavan INRIA Karthikeyan.Bhargavan@inria.fr IIT Delhi, Fall 2010 Lecture 4: Security


slide-1
SLIDE 1

Formal ¡Security ¡Analysis ¡of ¡ Cryptographic ¡Protocol ¡Code ¡ ¡

Karthikeyan ¡Bhargavan ¡ INRIA ¡ Karthikeyan.Bhargavan@inria.fr ¡ IIT ¡Delhi, ¡Fall ¡2010 ¡

slide-2
SLIDE 2

Lecture ¡4: ¡ Security ¡Proofs ¡for ¡Protocol ¡Code ¡

Formalizing ¡Security: ¡ Interfaces ¡and ¡Opponents ¡

slide-3
SLIDE 3

F ¡Syntax ¡

3 ¡

slide-4
SLIDE 4

PrimiGve ¡Constructors ¡& ¡FuncGons ¡

  • PrimiGve ¡types: ¡unit, ¡string, ¡bool, ¡tuples, ¡chan ¡

– F ¡is ¡an ¡untyped ¡lambda ¡calculus, ¡ ¡but ¡funcGons ¡and ¡constructors ¡have ¡ariGes. ¡ ¡ – We ¡write ¡protocol ¡code ¡that ¡compiles/typechecks ¡in ¡F#, ¡ ¡but ¡the ¡opponent ¡is ¡an ¡untyped ¡F ¡program ¡ ¡

slide-5
SLIDE 5

Interfaces ¡

  • An ¡interface ¡is ¡a ¡set ¡of ¡menGons ¡
  • A ¡menGon ¡declares ¡ ¡

– A ¡value ¡variable, ¡or ¡ – A ¡constructor ¡of ¡arity ¡n, ¡or ¡ – A ¡funcGon ¡of ¡arity ¡n ¡

slide-6
SLIDE 6

Prim: ¡An ¡Interface ¡for ¡F ¡PrimiGves ¡

  • Constructors ¡

– true ¡: ¡ctor ¡0 ¡ – false ¡: ¡ctor ¡0 ¡ – tuplei ¡: ¡ctor ¡i ¡(i∈1..m) ¡ – Ss ¡: ¡ctor ¡0 ¡ ¡ ¡ ¡ ¡ ¡(s∈Strings) ¡

  • FuncGons ¡

– failwith: ¡fun ¡1 ¡ ¡ ¡ ¡ ¡ ¡ ¡failwith ¡“error ¡condiGon” ¡ – log ¡: ¡fun ¡1 ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡log ¡(Send(x)) ¡ – name ¡: ¡fun ¡1 ¡ ¡ ¡ ¡ ¡ ¡ ¡name ¡() ¡ – send: ¡fun ¡2 ¡ ¡ ¡ ¡ ¡send ¡chan ¡msg ¡ – recv: ¡fun ¡1 ¡ ¡ ¡ ¡ ¡recv ¡chan ¡

slide-7
SLIDE 7

FormaGon ¡Rules ¡for ¡F ¡Interfaces ¡

slide-8
SLIDE 8

Example: ¡System ¡Interface ¡

slide-9
SLIDE 9

Example: ¡System ¡Interface ¡

System ¡(Program) ¡ System ¡Interface ¡

slide-10
SLIDE 10

Public ¡Interfaces ¡and ¡Opponents ¡

  • For ¡each ¡system ¡we ¡declare ¡a ¡public ¡interface ¡

– It ¡must ¡be ¡a ¡proper ¡subset ¡of ¡the ¡system ¡interface ¡

  • Opponents ¡are ¡parameterized ¡by ¡public ¡interfaces ¡
  • An ¡I-­‑opponent ¡is ¡an ¡F ¡program ¡that ¡can ¡access ¡ ¡

the ¡values, ¡constructors ¡and ¡funcGons ¡in ¡ ¡ Prim ¡\ ¡log ¡+ ¡I ¡ ¡ ¡

– An ¡opponent ¡must ¡be ¡well-­‑formed ¡(respect ¡ariGes) ¡

slide-11
SLIDE 11

Example: ¡System ¡Interface ¡

System ¡Interface ¡ Public ¡Interface ¡

slide-12
SLIDE 12

Formalizing ¡Security: ¡Queries ¡

  • A ¡query ¡is ¡a ¡property ¡of ¡runGme ¡configuraGons ¡

– E ¡is ¡called ¡the ¡end ¡event ¡ – B1,…, ¡Bn ¡ ¡are ¡called ¡begin ¡events ¡ – It ¡encodes ¡a ¡safety ¡property ¡on ¡reducGon ¡traces ¡ – E.g. ¡ev:Accept(x) ¡=> ¡ev:Send(x) ¡ – Whenever ¡the ¡event ¡Accept(x) ¡is ¡logged ¡(for ¡any ¡x) ¡ the ¡event ¡Send(x) ¡must ¡have ¡been ¡logged ¡before ¡ ¡ – Free ¡variables ¡in ¡end ¡events ¡(e.g. ¡x) ¡are ¡universally ¡quanGfied ¡

slide-13
SLIDE 13

Query ¡SaGsfacGon ¡

  • A ¡configuraGon ¡saGsfies ¡a ¡query ¡iff ¡

– whenever ¡the ¡end ¡event ¡occurs ¡in ¡the ¡ configuraGon ¡under ¡some ¡subsGtuGon ¡σ ¡ – one ¡of ¡the ¡begin ¡events ¡also ¡occurs ¡under ¡σ ¡

  • E.g. ¡if ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡C ¡≡ ¡event ¡Accept(x) ¡{“foo”/x} ¡| ¡C’, ¡ ¡

¡ ¡ ¡ ¡ ¡ ¡ ¡then ¡ ¡ ¡ ¡C’ ¡≡ ¡event ¡Send(x) ¡{“foo”/x”} ¡| ¡C’’ ¡

slide-14
SLIDE 14

Formal ¡Security ¡Goal: ¡Robust ¡Safety ¡

  • A ¡program ¡is ¡safe ¡for ¡a ¡query ¡q ¡if ¡q ¡is ¡saGsfied ¡by ¡all ¡its ¡reachable ¡

configuraGons ¡ ¡ – QuanGficaGon ¡over ¡all ¡reducGon ¡traces ¡

  • A ¡program ¡is ¡robustly ¡safe ¡for ¡q ¡and ¡public ¡interface ¡I ¡if ¡it ¡is ¡safe ¡

against ¡all ¡I-­‑opponents ¡ – QuanGficaGon ¡over ¡all ¡opponents ¡ ¡

slide-15
SLIDE 15

Undecidability ¡of ¡Security ¡VerificaGon ¡

  • Robust ¡safety ¡quanGfies ¡over ¡all ¡reducGon ¡traces ¡

and ¡all ¡opponents ¡

– Is ¡the ¡number ¡of ¡traces ¡finite? ¡ ¡ – No, ¡but ¡a ¡number ¡of ¡traces ¡look ¡the ¡same ¡ e.g. ¡(client ¡k1 ¡| ¡server ¡k1) ¡vs ¡(client ¡k2 ¡| ¡server ¡k2) ¡ ¡ – Is ¡the ¡number ¡of ¡disGnct ¡“shapes” ¡of ¡traces ¡finite? ¡ – Only ¡if ¡the ¡number ¡of ¡names ¡is ¡fixed ¡

  • That ¡is, ¡if ¡the ¡number ¡of ¡sessions/keys/nonces ¡is ¡fixed ¡
  • In ¡general, ¡security ¡verificaGon ¡is ¡undecidable ¡

– Decidable ¡under ¡a ¡variety ¡of ¡(unrealisGc) ¡restricGons ¡

slide-16
SLIDE 16

Example ¡

  • Let ¡S10 ¡be ¡our ¡target ¡program ¡
  • Let ¡I10 ¡be ¡its ¡full ¡system ¡interface ¡
  • Let ¡Ipub ¡be ¡its ¡public ¡interface ¡
  • Let ¡q ¡be ¡the ¡query ¡ev:Accept(x) ¡=> ¡ev:Send(x) ¡
  • Is ¡S10 ¡safe ¡for ¡q? ¡
  • Is ¡S10 ¡robustly ¡safe ¡for ¡q ¡and ¡I10? ¡

– Is ¡there ¡an ¡I10-­‑opponent ¡O ¡s.t. ¡S10 ¡O ¡is ¡unsafe ¡for ¡q? ¡

  • Is ¡S10 ¡robustly ¡safe ¡for ¡q ¡and ¡Ipub? ¡
slide-17
SLIDE 17

Lecture ¡4: ¡ Security ¡Proofs ¡for ¡Protocol ¡Code ¡

A ¡Proof ¡of ¡Security ¡

slide-18
SLIDE 18

Security ¡Goal ¡

  • Is ¡S10 ¡robustly ¡safe ¡for ¡q ¡and ¡Ipub? ¡
  • where ¡q ¡is: ¡ev:Accept(x) ¡=> ¡ev:Send(x) ¡
  • and ¡Ipub ¡is: ¡
slide-19
SLIDE 19

Towards ¡a ¡RunGme ¡Invariant ¡

  • We ¡can ¡show ¡that ¡S10 ¡ ¡always ¡goes ¡to ¡
  • Let ¡O ¡be ¡an ¡Ipub-­‑opponent ¡
  • Let ¡C1 ¡be ¡C0 ¡| ¡du1 ¡du2 ¡O ¡
  • Then ¡S10 ¡O ¡-­‑>* ¡C1 ¡
  • The ¡program ¡du1 ¡du2 ¡O ¡ ¡is ¡also ¡an ¡Ipub-­‑opponent ¡

– Does ¡not ¡use ¡key, ¡uses ¡only ¡funcGons ¡and ¡values ¡in ¡Ipub ¡

  • Hence, ¡C1 ¡is ¡of ¡the ¡form ¡C0 ¡| ¡O’, ¡where ¡C0 ¡is ¡inacGve ¡
slide-20
SLIDE 20

Towards ¡a ¡RunGme ¡Invariant ¡

  • How ¡can ¡the ¡opponent ¡O’ ¡produce ¡event ¡Accept(x)? ¡

– by ¡calling ¡resp ¡(), ¡and ¡ ¡ – by ¡producing ¡Enc(x,k) ¡

  • Can ¡the ¡opponent ¡obtain ¡k? ¡

– No, ¡otherwise ¡the ¡protocol ¡is ¡broken ¡

  • How ¡can ¡the ¡opponent ¡produce ¡Enc(x,k)? ¡

– by ¡calling ¡init ¡x, ¡and ¡ – hence, ¡triggering ¡Send(x) ¡before ¡obtaining ¡Enc(x,k) ¡

  • So, ¡our ¡runGme ¡invariant ¡must ¡capture ¡

– The ¡states ¡of ¡different ¡calls ¡to ¡resp, ¡ – The ¡occurrences ¡of ¡k ¡ ¡ – The ¡states ¡of ¡different ¡calls ¡to ¡init ¡ ¡

slide-21
SLIDE 21

A ¡RunGme ¡Invariant ¡

For ¡all ¡configuraGons ¡C ¡such ¡that ¡C1 ¡-­‑>* ¡C ¡ ¡ ¡ ¡C ¡must ¡be ¡of ¡the ¡form ¡ ¡ ¡C0 ¡| ¡event ¡Accept(s1) ¡| ¡event ¡Send(s1) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡| ¡… ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡| ¡event ¡Accept(sk) ¡| ¡event ¡Send(sk) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡| ¡event ¡Send(t1) ¡| ¡… ¡| ¡event ¡Send(tm) ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡| ¡i1 ¡| ¡… ¡| ¡il ¡| ¡r1 ¡| ¡… ¡| ¡rl ¡| ¡O’ ¡where ¡ – All ¡occurrences ¡of ¡k ¡in ¡O’ ¡are ¡of ¡the ¡form ¡Enc(G, ¡k) ¡ – Each ¡ij ¡ ¡is ¡of ¡the ¡form ¡let ¡x ¡= ¡ej ¡in ¡Oj ¡where ¡ ¡

¡ej ¡ ¡ ¡is ¡an ¡intermediate ¡expression ¡of ¡init ¡and ¡

¡ ¡ ¡ ¡all ¡occurrences ¡of ¡k ¡in ¡Oj ¡are ¡of ¡the ¡form ¡Enc(G, ¡k) ¡ – Each ¡rj ¡ ¡is ¡of ¡the ¡form ¡let ¡x ¡= ¡ej ¡in ¡Oj ¡where ¡ ¡ ej ¡ ¡ ¡is ¡an ¡intermediate ¡expression ¡of ¡resp ¡

slide-22
SLIDE 22

Recall: ¡ReducGons ¡of ¡init ¡

slide-23
SLIDE 23

Recall: ¡ReducGons ¡of ¡init ¡

slide-24
SLIDE 24

Recall: ¡ReducGons ¡of ¡recv ¡

slide-25
SLIDE 25

Proof ¡of ¡Invariant ¡

  • By ¡inducGon ¡on ¡the ¡length ¡of ¡C1 ¡-­‑>* ¡C ¡

¡Base ¡Case ¡(length ¡0): ¡ ¡C1 ¡obeys ¡the ¡invariant ¡

¡InducRon ¡Hypothesis: ¡Amer ¡n ¡steps, ¡ ¡ ¡ ¡C ¡= ¡C0 ¡| ¡event ¡Accept(s1) ¡| ¡event ¡Send(s1) ¡| ¡… ¡ ¡ ¡ ¡ ¡Let ¡C ¡-­‑> ¡C’ ¡ ¡ ¡ ¡We ¡proceed ¡by ¡case ¡analysis ¡on ¡this ¡reducGon. ¡ ¡ ¡ ¡(1) ¡If ¡the ¡reducGon ¡is ¡in ¡one ¡of ¡the ¡ij ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡then ¡it ¡either ¡stays ¡an ¡ij ¡or ¡produces ¡a ¡Send(x) ¡and ¡an ¡Enc(x,k) ¡ ¡ ¡ ¡(2) ¡If ¡the ¡reducGon ¡is ¡in ¡one ¡of ¡the ¡rj ¡ ¡

¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡then ¡it ¡either ¡stays ¡an ¡rj ¡or ¡takes ¡an ¡Enc(x,k) ¡and ¡produces ¡Accept(x) ¡

¡ ¡ ¡(3) ¡If ¡the ¡reducGon ¡is ¡in ¡O ¡ ¡ ¡ ¡ ¡ ¡then ¡it ¡either ¡stays ¡an ¡O ¡or ¡produces ¡an ¡ij ¡ ¡or ¡an ¡rj ¡ ¡

slide-26
SLIDE 26

Proof ¡of ¡Robust ¡Safety ¡

  • Any ¡configuraGon ¡that ¡saGsfies ¡the ¡invariant ¡

saGsfies ¡our ¡target ¡query ¡

  • Every ¡reachable ¡configuraGon ¡of ¡our ¡program ¡

with ¡any ¡opponent ¡saGsfies ¡the ¡invariant ¡

  • Hence, ¡S10 ¡is ¡robustly ¡safe ¡
slide-27
SLIDE 27

Lecture ¡4: ¡ Security ¡Proofs ¡for ¡Protocol ¡Code ¡

Proof ¡Techniques ¡

slide-28
SLIDE 28

Proof ¡Techniques ¡for ¡Security ¡

  • We ¡have ¡used ¡an ¡invariant-­‑based ¡technique ¡to ¡

verify ¡the ¡security ¡of ¡our ¡program ¡

  • ParGcularly ¡suited ¡to ¡manual ¡proof, ¡but ¡not ¡easily ¡

automatable ¡

– Figuring ¡out ¡the ¡invariant ¡is ¡the ¡difficult ¡bit ¡

  • Developing ¡automated ¡proof ¡techniques ¡for ¡

security ¡protocols ¡is ¡an ¡acGve ¡area ¡of ¡research ¡

– At ¡least ¡3 ¡internaGonal ¡conferences ¡ ¡ – IntersecGon ¡of ¡Programming ¡Languages, ¡Security, ¡ Cryptography, ¡and ¡Formal ¡Methods ¡

slide-29
SLIDE 29

Early ¡Apempts ¡

  • Dolev&Yao ¡first ¡formalize ¡N&S ¡problem ¡in ¡early ¡80s ¡

– Shared ¡key ¡decrypGon: ¡{ ¡{M}K ¡}K-­‑1 ¡= ¡M ¡ – Public ¡key ¡decrypGon: ¡{| ¡{| ¡M ¡|}KA ¡|}KA-­‑1 ¡= ¡M ¡ – Their ¡work ¡now ¡widely ¡recognised, ¡but ¡at ¡the ¡Gme, ¡few ¡proof ¡ techniques, ¡so ¡liple ¡applied ¡

  • In ¡1987, ¡Burrows, ¡Abadi ¡and ¡Needham ¡(BAN) ¡propose ¡a ¡

systemaGc ¡rule-­‑based ¡logic ¡for ¡reasoning ¡about ¡protocols ¡

– If ¡P ¡believes ¡that ¡he ¡shares ¡a ¡key ¡K ¡with ¡Q, ¡and ¡sees ¡the ¡ message ¡M ¡encrypted ¡under ¡K, ¡then ¡he ¡will ¡believe ¡that ¡Q ¡once ¡ said ¡M ¡ – If ¡P ¡believes ¡that ¡the ¡message ¡M ¡is ¡fresh, ¡and ¡also ¡believes ¡that ¡ Q ¡once ¡said ¡M, ¡then ¡he ¡will ¡believe ¡that ¡Q ¡believes ¡M ¡ – Incomplete, ¡but ¡useful; ¡hugely ¡influenGal ¡

slide-30
SLIDE 30

A ¡Poped ¡History: ¡1978-­‑2005 ¡

A ¡ B ¡ M ¡

1978: ¡N&S ¡propose ¡authenGcaGon ¡protocols ¡for ¡“large ¡networks ¡of ¡computers” ¡ 1981: ¡Denning ¡and ¡Sacco ¡find ¡apack ¡found ¡on ¡N&S ¡symmetric ¡key ¡protocol ¡ 1983: ¡Dolev ¡and ¡Yao ¡first ¡formalize ¡secrecy ¡properGes ¡wrt ¡N&S ¡threat ¡model, ¡using ¡formal ¡algebra ¡ 1987: ¡Burrows, ¡Abadi, ¡Needham ¡invent ¡authenGcaGon ¡logic; ¡incomplete, ¡but ¡useful ¡ 1994: ¡Hickman ¡(Netscape) ¡invents ¡SSL; ¡holes ¡in ¡v2, ¡but ¡v3 ¡fixes ¡these, ¡very ¡widely ¡deployed ¡ 1994: ¡Ylonen ¡invents ¡SSH; ¡holes ¡in ¡v1, ¡but ¡v2 ¡good, ¡very ¡widely ¡deployed ¡ 1995: ¡Abadi, ¡Anderson, ¡Needham, ¡et ¡al ¡propose ¡various ¡informal ¡“robustness ¡principles” ¡ 1995: ¡Lowe ¡finds ¡insider ¡apack ¡on ¡N&S ¡asymmetric ¡protocol; ¡rejuvenates ¡interest ¡in ¡FMs ¡ circa ¡2000: ¡Several ¡FMs ¡for ¡“D&Y ¡problem”: ¡tradeoff ¡between ¡accuracy ¡and ¡approximaGon ¡ 2000: ¡Abadi ¡and ¡Rogaway ¡iniGate ¡connecGons ¡between ¡formal ¡and ¡computaGonal ¡models ¡of ¡crypto ¡ circa ¡2005: ¡Many ¡FMs ¡now ¡developed; ¡several ¡(eg ¡ProVerif) ¡deliver ¡both ¡accuracy ¡and ¡automaGon ¡ 2005: ¡Cervesato ¡et ¡al ¡find ¡same ¡insider ¡apack ¡as ¡Lowe ¡on ¡proposed ¡public-­‑key ¡Kerberos ¡ 2005: ¡Goubault-­‑Larrecq ¡and ¡Parrennes ¡pioneer ¡direct ¡verificaGon ¡of ¡implementaGon ¡code ¡in ¡C ¡

slide-31
SLIDE 31

The ¡InducGve ¡Method ¡[Paulson] ¡

  • Formalize ¡the ¡protocol ¡from ¡the ¡viewpoint ¡of ¡the ¡

apacker, ¡using ¡Higher-­‑order ¡Logic ¡

  • Apacker’s ¡knowledge ¡represented ¡by ¡a ¡set ¡K ¡

– If ¡k ¡∈ ¡K ¡and ¡x ¡∈K, ¡then ¡Enc(k,x) ¡∈ ¡K ¡ – If ¡k ¡∈ ¡K ¡and ¡Enc(k,x) ¡∈ ¡K, ¡then ¡x ¡∈K ¡ – If ¡Enc(k,x) ¡∈ ¡K, ¡then ¡Accept(x) ¡ ¡ – Forall ¡x. ¡Send(x) ¡ – Forall ¡x. ¡Enc(k,x) ¡∈ ¡K ¡ – N ¡∈ ¡K, ¡M ¡∈ ¡K ¡

  • Use ¡a ¡theorem-­‑prover ¡(Coq ¡or ¡Isabelle/HOL) ¡to ¡

prove ¡robust ¡safety ¡by ¡rule ¡inducGon ¡ ¡

slide-32
SLIDE 32

ResoluGon ¡with ¡First-­‑order ¡UnificaGon ¡[Blanchet] ¡

  • Formalize ¡the ¡protocol ¡from ¡the ¡viewpoint ¡of ¡the ¡

apacker, ¡using ¡First-­‑order ¡Horn ¡Clauses ¡

  • Apacker’s ¡knowledge ¡represented ¡by ¡predicate ¡

ap ¡and ¡a ¡set ¡of ¡rewrite ¡rules ¡

– ap:k ¡and ¡ap:x ¡=> ¡ap:Enc(k,x) ¡ – ap:Enc(k,x) ¡=> ¡ ¡ev:Accept(x) ¡ ¡ – ev:Send(x) ¡ ¡

  • Use ¡resoluGon ¡to ¡compute ¡the ¡compleGon ¡of ¡

these ¡rewrite ¡rules ¡

  • Upon ¡compleGon, ¡ask ¡query ¡of ¡the ¡set ¡of ¡

generated ¡rules ¡(like ¡a ¡Prolog ¡program) ¡

slide-33
SLIDE 33

Model ¡Checking ¡[Roscoe, ¡Basin] ¡

  • Formalize ¡the ¡protocol ¡as ¡a ¡communicaGng ¡

finite ¡state ¡machine ¡(CSP/CCS/CFSM) ¡

  • Apacker ¡is ¡also ¡a ¡finite ¡state ¡process ¡with ¡

specific ¡capabiliGes ¡

  • Limit ¡number ¡of ¡sessions/names/nonces ¡
  • Find ¡all ¡reducGon ¡traces ¡and ¡verify ¡query ¡on ¡

each ¡reachable ¡state ¡

  • ViolaGon ¡of ¡query ¡=> ¡apack ¡

– No ¡violaGon ¡found ¡does ¡not ¡mean ¡proof ¡

slide-34
SLIDE 34

Verifying ¡Programs ¡not ¡Models ¡

  • Most ¡previous ¡methods ¡focus ¡on ¡models ¡
  • What ¡about ¡code? ¡

– Csur, ¡Aspier: ¡C ¡model ¡checking ¡ – FS2PV: ¡F# ¡to ¡ProVerif ¡ – F7: ¡Security ¡Typechecking ¡

  • AcGve ¡research ¡groups ¡

– CerGCrypt ¡(France) ¡ – Aspier ¡(CMU) ¡ – F7 ¡(France) ¡