Formal Security Analysis of Cryptographic Protocol Code - - PowerPoint PPT Presentation
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
Lecture ¡4: ¡ Security ¡Proofs ¡for ¡Protocol ¡Code ¡
Formalizing ¡Security: ¡ Interfaces ¡and ¡Opponents ¡
F ¡Syntax ¡
3 ¡
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 ¡ ¡
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 ¡
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 ¡
FormaGon ¡Rules ¡for ¡F ¡Interfaces ¡
Example: ¡System ¡Interface ¡
Example: ¡System ¡Interface ¡
System ¡(Program) ¡ System ¡Interface ¡
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) ¡
Example: ¡System ¡Interface ¡
System ¡Interface ¡ Public ¡Interface ¡
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 ¡
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’’ ¡
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 ¡ ¡
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 ¡
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? ¡
Lecture ¡4: ¡ Security ¡Proofs ¡for ¡Protocol ¡Code ¡
A ¡Proof ¡of ¡Security ¡
Security ¡Goal ¡
- Is ¡S10 ¡robustly ¡safe ¡for ¡q ¡and ¡Ipub? ¡
- where ¡q ¡is: ¡ev:Accept(x) ¡=> ¡ev:Send(x) ¡
- and ¡Ipub ¡is: ¡
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 ¡
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 ¡ ¡
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 ¡
Recall: ¡ReducGons ¡of ¡init ¡
Recall: ¡ReducGons ¡of ¡init ¡
Recall: ¡ReducGons ¡of ¡recv ¡
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 ¡ ¡
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 ¡
Lecture ¡4: ¡ Security ¡Proofs ¡for ¡Protocol ¡Code ¡
Proof ¡Techniques ¡
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 ¡
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 ¡
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 ¡
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 ¡ ¡
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) ¡
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 ¡
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 ¡