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 3: Coding


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 ¡3: ¡ Coding ¡Symbolic ¡Abstrac3ons ¡in ¡F# ¡

IntroducCon ¡

slide-3
SLIDE 3

A ¡Crypto ¡Protocol ¡ImplementaCon ¡

Protocol ¡ Code ¡ Key ¡ Management ¡ Cryptographic ¡ ¡ Library ¡ Network ¡ ¡ Stack ¡

Database ¡of ¡secrets ¡ (keys, ¡passwords) ¡ Crypto ¡algorithms ¡ Network ¡Protocols ¡

ApplicaCon ¡ Code ¡ Network ¡ ¡ Based ¡ Opponent ¡

Untrusted ¡Network ¡ ParGally ¡Trusted ¡

slide-4
SLIDE 4

Towards ¡Symbolic ¡VerificaCon ¡

One ¡Source, ¡Many ¡Tasks ¡

ApplicaCons ¡ ¡

¡ ¡Crypto, ¡Net ¡

¡ ¡Concrete ¡Libraries ¡

¡ ¡Crypto, ¡Net ¡

¡ ¡ ¡Symbolic ¡Libraries ¡ Interoperability ¡Tes3ng ¡ ¡ ¡Compile ¡

Network ¡

¡ ¡Compile ¡

Other ¡ Implementa3ons ¡ ¡

Symbolic ¡ ¡ Debugging ¡ Run ¡ Run ¡

No ¡AAack ¡

Verify ¡

Diverges ¡ AAack ¡

Symbolic ¡ ¡ Verifica3on ¡ Protocol ¡Code ¡ Security ¡ Goals ¡

One ¡Source ¡ Many ¡Tasks ¡

slide-5
SLIDE 5

Lecture ¡Outline ¡

  • Library ¡modules ¡review: ¡Data, ¡Net, ¡Crypto ¡
  • An ¡example ¡protocol ¡using ¡these ¡modules ¡

– AuthenCcated ¡RPC ¡ – Security ¡goals, ¡how ¡shall ¡we ¡formalize ¡them? ¡

  • A ¡symbolic ¡cryptographic ¡library ¡

– New ¡implementaCons ¡for ¡Data, ¡Crypto, ¡Net ¡

  • Symbolic ¡debugging ¡

– AuthenCcated ¡EncrypCon ¡example ¡

slide-6
SLIDE 6

Lecture ¡3: ¡ Coding ¡Symbolic ¡Abstrac3ons ¡in ¡F# ¡

Library ¡Modules ¡

slide-7
SLIDE 7

Data ¡Module: ¡Strings, ¡Bytestrings ¡

  • str ¡represents ¡string ¡
  • bytes ¡represents ¡byte[] ¡ ¡

Interface ¡

slide-8
SLIDE 8

Net ¡Module: ¡Networking ¡

  • Uses ¡Data.bytes ¡
  • fork ¡creates ¡a ¡new ¡thread ¡running ¡the ¡funcCon ¡ ¡ ¡
slide-9
SLIDE 9

Crypto ¡Module: ¡Cryptography ¡

slide-10
SLIDE 10

AUTHENTICATED ¡RPC ¡

SAMPLE ¡PROTOCOL ¡

Client ¡ ¡ Server ¡ request ¡ HMAC(key,request) ¡ response ¡ HMAC(key,request,response) ¡

slide-11
SLIDE 11

Informal ¡DescripCon ¡

slide-12
SLIDE 12

Why ¡Is ¡This ¡Protocol ¡Secure? ¡

slide-13
SLIDE 13

Logical ¡SpecificaCon ¡

slide-14
SLIDE 14

F# ¡ImplementaCon ¡

slide-15
SLIDE 15

Connecting to localhost:8080 Sending {BgAyICsgMj9mhJa7iDAcW3Rrk...} (28 bytes) Listening at ::1:8080 Received Request 2 + 2? Sending {AQA0NccjcuL/WOaYS0GGtOtPm...} (23 bytes) Received Response 4

Test ¡

slide-16
SLIDE 16

Is ¡The ¡Protocol ¡Code ¡Secure? ¡

  • 1. Can ¡the ¡opponent ¡cause ¡one ¡of ¡our ¡

authenCcaCon ¡goals ¡to ¡fail? ¡

  • 2. What ¡if ¡the ¡opponent ¡sent ¡a ¡forged ¡message ¡to ¡

the ¡server? ¡

  • 3. What ¡if ¡the ¡client ¡started ¡concurrent ¡sessions ¡

with ¡both ¡an ¡honest ¡and ¡a ¡dishonest ¡server? ¡

  • 4. What ¡if ¡the ¡MAC ¡key ¡is ¡compromised? ¡

More ¡importantly, ¡what ¡is ¡the ¡formal ¡model ¡under ¡ which ¡we ¡may ¡prove ¡our ¡security ¡goals? ¡ ¡

slide-17
SLIDE 17

Lecture ¡3: ¡ Coding ¡Symbolic ¡Abstrac3ons ¡in ¡F# ¡

A ¡Symbolic ¡AbstracCon ¡of ¡ Cryptography ¡

slide-18
SLIDE 18

A ¡New ¡ImplementaCon ¡of ¡Data, ¡Crypto ¡

  • str, ¡bytes ¡are ¡both ¡now ¡algebraic ¡datatypes ¡
  • peraCons ¡on ¡bytes ¡are ¡represented ¡as ¡constructors ¡

– One-­‑one ¡determinisCc ¡funcCons ¡

slide-19
SLIDE 19

Recall: ¡Data ¡Interface ¡

  • We ¡must ¡implement ¡all ¡these ¡funcCons ¡
slide-20
SLIDE 20

Conversions ¡using ¡InverCble ¡Constructors ¡

  • UTF8, ¡Base64, ¡Concat ¡modeled ¡as ¡constructors ¡ ¡

– one-­‑one ¡determinisCc ¡funcCons ¡

  • Inverse ¡funcCons ¡modeled ¡using ¡pacern ¡matching ¡
slide-21
SLIDE 21

Random ¡Values ¡using ¡Fresh ¡Names ¡

  • A ¡name ¡is ¡a ¡freshly ¡generated ¡value ¡

– The ¡name ¡datatype ¡is ¡hidden ¡from ¡the ¡interface ¡ – Hence, ¡given ¡a ¡name, ¡one ¡cannot ¡deconstruct ¡it ¡ – And ¡given ¡a ¡counter, ¡one ¡cannot ¡construct ¡a ¡name ¡

slide-22
SLIDE 22

Hash/MAC ¡as ¡One-­‑way ¡Constructors ¡

  • Hash, ¡MAC ¡are ¡constructors ¡

– One-­‑one ¡funcCons ¡[Collision ¡resistance] ¡

  • The ¡implementaCon ¡of ¡type ¡bytes ¡is ¡hidden ¡

– No ¡funcCon ¡for ¡inverCng ¡Hash/MAC ¡ – Hence, ¡noboby ¡can ¡look ¡inside ¡a ¡Hash ¡or ¡a ¡MAC ¡ – [Preimage ¡resistance] ¡

  • To ¡construct ¡a ¡MAC ¡one ¡must ¡use ¡mac ¡

– One ¡must ¡know ¡the ¡key ¡[Unforgeability] ¡

  • AssumpGons ¡too ¡strong? ¡

– Nobody ¡can ¡read ¡the ¡contents ¡of ¡MAC ¡[Secrecy] ¡

slide-23
SLIDE 23

Symbolic ¡Symmetric ¡EncrypCon ¡ ¡

  • DecrypCon ¡succeeds ¡on ¡encrypted ¡values ¡

– [DeterminisGc ¡DecrypGon] ¡

  • SymEncrypt ¡constructor ¡hidden ¡from ¡interface ¡

– Only ¡way ¡to ¡open ¡it ¡is ¡to ¡use ¡sym_decrypt ¡ – Hence, ¡one ¡must ¡know ¡key ¡to ¡recover ¡plaintext ¡ – [Secrecy] ¡

slide-24
SLIDE 24

Public ¡and ¡Private ¡Keys ¡

  • Private ¡keys ¡are ¡fresh ¡names ¡
  • One ¡can ¡go ¡from ¡a ¡private ¡key ¡to ¡a ¡public ¡key ¡

– But ¡not ¡the ¡other ¡way ¡round ¡[Private ¡Key ¡Secrecy] ¡

slide-25
SLIDE 25

Symbolic ¡Asymmetric ¡EncrypCon ¡

  • EncrypCon ¡with ¡public ¡key ¡

– DecrypCon ¡with ¡private ¡key ¡ – AsymEncrypt ¡constructor ¡is ¡hidden ¡from ¡interface ¡ – Nobody ¡can ¡access ¡plaintext ¡without ¡calling ¡ asym_decrypt ¡with ¡private ¡key ¡[Secrecy] ¡ ¡

slide-26
SLIDE 26

Symbolic ¡Signatures ¡ ¡

  • Only ¡way ¡to ¡construct ¡Sign(k,b) ¡is ¡through ¡sign ¡

– One ¡must ¡know ¡k ¡[Unforgeability] ¡

  • VerificaCon ¡guarantees ¡that ¡the ¡signer ¡knows ¡

the ¡private ¡key ¡[Non-­‑repudiaGon] ¡

slide-27
SLIDE 27

Recall: ¡Net ¡Interface ¡

slide-28
SLIDE 28

Networking ¡using ¡Channels ¡

  • The ¡network ¡is ¡a ¡public ¡channel ¡
  • Channels ¡are ¡asynchronous, ¡unordered, ¡buffered ¡

– send ¡adds ¡a ¡message ¡to ¡the ¡buffer ¡

slide-29
SLIDE 29

Networking ¡using ¡Channels ¡

  • recv ¡is ¡blocking ¡

– It ¡waits ¡for ¡a ¡message ¡to ¡appear ¡on ¡the ¡network ¡ – Code ¡uses ¡monitors ¡to ¡avoid ¡race ¡condiCons ¡

slide-30
SLIDE 30

Network-­‑based ¡Acacker ¡

  • The ¡network ¡channel ¡netChan ¡is ¡made ¡

available ¡to ¡the ¡acacker ¡

– He ¡knows ¡all ¡connecCon ¡idenCfiers ¡ – He ¡can ¡send ¡any ¡message ¡using ¡Net.send ¡ – He ¡can ¡intercept ¡any ¡message ¡using ¡Net.recv ¡

  • Hence, ¡the ¡acacker ¡controls ¡the ¡network ¡
slide-31
SLIDE 31

AUTHENTICATED ¡RPC ¡REVISITED ¡

SAMPLE ¡PROTOCOL ¡

Client ¡ ¡ Server ¡ request ¡ HMAC(key,request) ¡ response ¡ HMAC(key,request,response) ¡

slide-32
SLIDE 32

F# ¡ImplementaCon ¡

slide-33
SLIDE 33

Connecting to http://localhost:8081 Listening at http://localhost:8081 Accepted channels Sending: Foo | HMAC-SHA1{symkey[1]}[Foo] Sending Bar in response to Foo Sending: Bar | HMAC-SHA1{symkey[1]}[Foo | Bar] Accepted Bar as response to Foo

Test ¡with ¡Symbolic ¡Libraries ¡

Connecting to localhost:8080 Sending {BgAyICsgMj9mhJa7iDAcW3Rrk...} (28 bytes) Listening at ::1:8080 Received Request 2 + 2? Sending {AQA0NccjcuL/WOaYS0GGtOtPm...} (23 bytes) Received Response 4

Compare ¡with ¡the ¡original ¡concrete ¡run: ¡

slide-34
SLIDE 34

Is ¡The ¡Protocol ¡Code ¡Secure? ¡

  • 1. Can ¡the ¡opponent ¡cause ¡one ¡of ¡our ¡

authenCcaCon ¡goals ¡to ¡fail? ¡

  • 2. What ¡if ¡the ¡opponent ¡sent ¡a ¡forged ¡message ¡to ¡

the ¡server? ¡

  • 3. What ¡if ¡the ¡client ¡started ¡concurrent ¡sessions ¡

with ¡both ¡an ¡honest ¡and ¡a ¡dishonest ¡server? ¡

  • 4. What ¡if ¡the ¡MAC ¡key ¡is ¡compromised? ¡

More ¡importantly, ¡what ¡is ¡the ¡formal ¡model ¡under ¡ which ¡we ¡may ¡prove ¡our ¡security ¡goals? ¡ ¡

slide-35
SLIDE 35

Security ¡SpecificaCon ¡

  • Assume ¡the ¡protocol ¡implementaCon ¡runs ¡with ¡

the ¡symbolic ¡code ¡for ¡Data, ¡Crypto, ¡Net ¡

  • An ¡acacker ¡is ¡any ¡F# ¡program ¡that ¡has ¡access ¡to ¡

Data, ¡Crypto, ¡Net, ¡but ¡only ¡through ¡their ¡ interfaces ¡

  • For ¡all ¡such ¡acackers, ¡in ¡all ¡runs ¡of ¡the ¡protocol ¡
  • ur ¡security ¡goals ¡must ¡hold: ¡

– If ¡b ¡accepts ¡s ¡from ¡a, ¡a ¡must ¡have ¡sent ¡s ¡to ¡b ¡ – If ¡a ¡accepts ¡t ¡from ¡b, ¡b ¡must ¡have ¡sent ¡t ¡as ¡a ¡response ¡ to ¡s ¡from ¡a ¡

slide-36
SLIDE 36

Summary ¡

  • New ¡symbolic ¡implementaCons ¡for ¡libraries ¡

– Data, ¡Net, ¡Crypto ¡

  • They ¡code ¡up ¡our ¡security ¡abstracCon ¡

– AssumpCons ¡on ¡crypto ¡primiCves ¡ – Abstract ¡model ¡of ¡data ¡conversions ¡ – Network ¡under ¡the ¡control ¡of ¡the ¡adversary ¡

  • Symbolic ¡libraries ¡enable ¡symbolic ¡debugging ¡

– We ¡can ¡see ¡the ¡structure ¡of ¡crypto ¡messages ¡ ¡

  • They ¡enable ¡a ¡precise ¡security ¡specificaCon ¡as ¡a ¡

basis ¡for ¡formal ¡verificaCon ¡