Analysis of Security APIs (part I) Riccardo Focardi Universit` a - - PowerPoint PPT Presentation

analysis of security apis part i
SMART_READER_LITE
LIVE PREVIEW

Analysis of Security APIs (part I) Riccardo Focardi Universit` a - - PowerPoint PPT Presentation

Analysis of Security APIs (part I) Riccardo Focardi Universit` a Ca Foscari di Venezia, Italy focardi@dsi.unive.it http://www.dsi.unive.it/~focardi http://secgroup.ext.dsi.unive.it/ FOSAD 2010 Bertinoro, Italy, September 6-11, 2010


slide-1
SLIDE 1

Analysis of Security APIs (part I)

Riccardo Focardi

Universit` a Ca’ Foscari di Venezia, Italy focardi@dsi.unive.it http://www.dsi.unive.it/~focardi http://secgroup.ext.dsi.unive.it/

FOSAD 2010 Bertinoro, Italy, September 6-11, 2010

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 1 / 42

slide-2
SLIDE 2

Security APIs Introduction

Security APIs

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 2 / 42

slide-3
SLIDE 3

Security APIs Introduction

Example 1: Hardware Security Module (HSM)

Used in the ATM Bank network Tamper resistant Security API for

Managing cryptographic keys Decrypting/re-encrypting the PIN Checking the validity of the PIN

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 3 / 42

slide-4
SLIDE 4

Security APIs Introduction

Example 2: PKCS#11 API for tokens/smarcards

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 4 / 42

slide-5
SLIDE 5

Security APIs Introduction

Example 3: API to a service or on-line game

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 5 / 42

slide-6
SLIDE 6

Security APIs Introduction

Outline of the course

Today: PIN processing APIs

Attacks to guess bank PINs Best strategies to break PINs Language-based analysis and fixes

Tomorrow: PKCS#11 devices

Attacks to compromise a sensitive key A formal model of PKCS#11 How to secure PKCS#11: a software token Tookan: Analysis of real tokens

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 6 / 42

slide-7
SLIDE 7

PIN processing APIs The ATM bank network

PIN processing infrastructure

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 7 / 42

slide-8
SLIDE 8

PIN processing APIs The ATM bank network

PIN processing infrastructure

PIN

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 7 / 42

slide-9
SLIDE 9

PIN processing APIs The ATM bank network

PIN processing infrastructure

PIN PIN PIN PIN PIN Accept Refuse

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 7 / 42

slide-10
SLIDE 10

PIN processing APIs The ATM bank network

PIN processing infrastructure

PIN PIN PIN PIN PIN Accept Refuse {PIN}k1 {PIN}k2 {PIN}k3 {PIN}k4

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 7 / 42

slide-11
SLIDE 11

PIN processing APIs The ATM bank network

PIN processing infrastructure

PIN Accept Refuse {PIN}k1 {PIN}k2 {PIN}k3 {PIN}k4

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 7 / 42

slide-12
SLIDE 12

PIN processing APIs The ATM bank network

Hardware Security Module (HSM)

Tamper resistant Security API for

Managing cryptographic keys Decrypting/re-encrypting the PIN Checking the validity of the PIN

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 8 / 42

slide-13
SLIDE 13

PIN processing APIs PIN verification in the HSM

The PIN verification API

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 9 / 42

slide-14
SLIDE 14

PIN processing APIs PIN verification in the HSM

The PIN verification API

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs Example: PIN V({4104, r}k,vdata,4,0123456789012345,4732)

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 9 / 42

slide-15
SLIDE 15

PIN processing APIs PIN verification in the HSM

The PIN verification API

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs Example: PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 9 / 42

slide-16
SLIDE 16

PIN processing APIs PIN verification in the HSM

The PIN verification API

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs Example: PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r 4104

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 9 / 42

slide-17
SLIDE 17

PIN processing APIs PIN verification in the HSM

The PIN verification API

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs Example: PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 9 / 42

slide-18
SLIDE 18

PIN processing APIs PIN verification in the HSM

The PIN verification API

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs Example: PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 9 / 42

slide-19
SLIDE 19

PIN processing APIs PIN verification in the HSM

The PIN verification API

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs Example: PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 9 / 42

slide-20
SLIDE 20

PIN processing APIs PIN verification in the HSM

The PIN verification API

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs Example: PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 9 / 42

slide-21
SLIDE 21

PIN processing APIs PIN verification in the HSM

The PIN verification API

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs Example: PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 9 / 42

slide-22
SLIDE 22

PIN processing APIs PIN verification in the HSM

The code for PIN verification

PIN V(EPB, vdata, len, dectab, offset) { x1 := encpdk(vdata); x2 := left(len, x1); x3 := decimalize(dectab, x2); u pin := sum mod10(x3, offset); x4 := deck(EPB); t pin := fcheck(x4); if (t pin =⊥) then return(′′format wrong′′); if (t pin = u pin) then return(′′PIN is correct′′); else return(′′PIN is wrong′′) }

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 10 / 42

slide-23
SLIDE 23

PIN processing APIs Attacker model

Secure? Against who ... ?

Security property Confidentiality: PIN should never be disclosed Cards can be cloned, user PIN is the only secret

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 11 / 42

slide-24
SLIDE 24

PIN processing APIs Attacker model

Secure? Against who ... ?

Security property Confidentiality: PIN should never be disclosed Cards can be cloned, user PIN is the only secret Worst case scenario the attacker works inside the bank breaks into the system and have direct access to the HSM can perform any sequence of API calls ... but no direct access to HSM keys, memory or resources

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 11 / 42

slide-25
SLIDE 25

PIN processing APIs Attacker model

Secure? Against who ... ?

Security property Confidentiality: PIN should never be disclosed Cards can be cloned, user PIN is the only secret Worst case scenario the attacker works inside the bank breaks into the system and have direct access to the HSM can perform any sequence of API calls ... but no direct access to HSM keys, memory or resources But, how can we break PIN secrecy by just calling the API? ... have you ever played Mastermind?

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 11 / 42

slide-26
SLIDE 26

Guessing a secret via API calls The Mastermind Game

The Mastermind Game

Invented by the Israeli postmaster and telecommunications expert Mordecai Meirowitz in 1970; 4 pegs from 6 possible colors, duplicates are allowed. The codemaker chooses a sequence of 4 pegs, the codebreaker has to guess it Goal: Minimize the number of guesses

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 12 / 42

slide-27
SLIDE 27

Guessing a secret via API calls The Mastermind Game

The Mastermind ‘API’

The codebreaker ‘calls’ MasterMind(guess) where ‘guess’ is a sequence of 4 pegs The return value is a set of 4 markers:

red marker: right color and position; white marker: right color and wrong position.

Partial information about the secret sequence ...

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 13 / 42

slide-28
SLIDE 28

Guessing a secret via API calls Playing mastermind on PIN V?

Can we ‘play mastermind’ on this API?

Encrypted PIN Block : contains the PIN at the ATM PIN V( EPB , vdata,len,dectab,offset ) Data for computing the user PIN Returns the equality of the two PINs Example: PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 14 / 42

slide-29
SLIDE 29

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104

3 PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-30
SLIDE 30

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,0123456789012345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104

3 PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-31
SLIDE 31

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104

3 PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-32
SLIDE 32

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104

3 PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-33
SLIDE 33

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 4732 mod 10 = 4104

3 PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-34
SLIDE 34

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 4732 mod 10 = 4104

3 PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-35
SLIDE 35

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 4732 mod 10 = 5104

3 PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-36
SLIDE 36

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 4732 mod 10 = 5104

3 PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-37
SLIDE 37

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 4732 mod 10 = 5104

3 PIN V returns ‘false’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-38
SLIDE 38

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,4732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 4732 mod 10 = 5104

3 PIN V returns ‘false’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-39
SLIDE 39

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,3732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 3732 mod 10 = 5104

3 PIN V returns ‘false’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-40
SLIDE 40

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,3732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 3732 mod 10 = 5104

3 PIN V returns ‘false’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-41
SLIDE 41

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,3732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 3732 mod 10 = 4104

3 PIN V returns ‘false’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-42
SLIDE 42

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,3732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 3732 mod 10 = 4104

3 PIN V returns ‘false’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-43
SLIDE 43

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,3732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 3732 mod 10 = 4104

3 PIN V returns ‘true’ FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-44
SLIDE 44

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,3732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 3732 mod 10 = 4104

3 PIN V returns ‘true’

We discover that the first digit is 4 with 2 API calls, being lucky

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-45
SLIDE 45

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,3732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 3732 mod 10 = 4104

3 PIN V returns ‘true’

We discover that the first digit is 4 with 2 API calls, being lucky Has this kind of attack been tried on real bank systems?

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-46
SLIDE 46

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

The ‘decimalization’ attack on PIN V [Bond, Zielinski ’03]

PIN V({4104, r}k,vdata,4,1123456789112345,3732)

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1472 ⊕ 3732 mod 10 = 4104

3 PIN V returns ‘true’

We discover that the first digit is 4 with 2 API calls, being lucky Has this kind of attack been tried on real bank systems? How long does it take to discover the whole PIN?

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 15 / 42

slide-47
SLIDE 47

Guessing a secret via API calls The ‘decimalization’ attack on PIN V

Reports suggest something has been going on ...

Verizon Breach Report 2008

“Were seeing entirely new attacks that a year ago were thought to be only academically possible” “What we see now is people going right to the source [..] and stealing the encrypted PIN blocks and using complex ways to un-encrypt the PIN blocks.” (Quotes from Wired Magazine interview with report author, Bryan Sartin)

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 16 / 42

slide-48
SLIDE 48

Analysis of PIN processing APIs Finding efficient strategies

How many API calls are needed?

For a four digit PIN: [Bond, Zielinski ’03] Average 16.5 API calls [Steel, TCS06] Average 16.145 API calls [Focardi, Luccio, FUN’10] Average 14.47 API calls (as instance of Mastermind) Lower-bound of 13.362 API calls

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 17 / 42

slide-49
SLIDE 49

Analysis of PIN processing APIs An extended mastermind

The Extended Mastermind Game

Colors: C = {0, 1, . . . , N − 1} Secret sequence: (c1, c2, . . . , ck), with c1, . . . , ck ∈ C Extended guess: (S1, S2, . . . , Sk), with S1, . . . , Sk ⊆ C

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 18 / 42

slide-50
SLIDE 50

Analysis of PIN processing APIs An extended mastermind

The Extended Mastermind Game

Colors: C = {0, 1, . . . , N − 1} Secret sequence: (c1, c2, . . . , ck), with c1, . . . , ck ∈ C Extended guess: (S1, S2, . . . , Sk), with S1, . . . , Sk ⊆ C Example 6 colors: C = {0, 1, . . . , 5} Secret: (1, 2, 3, 1) Extended guess: ({1}, {3}, {1}, {1, 3}) what’s the answer?

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 18 / 42

slide-51
SLIDE 51

Analysis of PIN processing APIs An extended mastermind

The Extended Mastermind Game

Colors: C = {0, 1, . . . , N − 1} Secret sequence: (c1, c2, . . . , ck), with c1, . . . , ck ∈ C Extended guess: (S1, S2, . . . , Sk), with S1, . . . , Sk ⊆ C Example 6 colors: C = {0, 1, . . . , 5} Secret: (1, 2, 3, 1) Extended guess: ({1}, {3}, {1}, {1, 3}) what’s the answer? 2 red and 1 white markers

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 18 / 42

slide-52
SLIDE 52

Analysis of PIN processing APIs An extended mastermind

Red Markers

Colors: C = {0, 1, . . . , N − 1} Secret sequence: (c1, c2, . . . , ck), with c1, . . . , ck ∈ C Extended guess: (S1, S2, . . . , Sk), with S1, . . . , Sk ⊆ C Definition (Red markers) The number b of red markers is computed as r = |{i ∈ [1, k] | ci ∈ Si}|.

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 19 / 42

slide-53
SLIDE 53

Analysis of PIN processing APIs An extended mastermind

Red Markers

Colors: C = {0, 1, . . . , N − 1} Secret sequence: (c1, c2, . . . , ck), with c1, . . . , ck ∈ C Extended guess: (S1, S2, . . . , Sk), with S1, . . . , Sk ⊆ C Definition (Red markers) The number b of red markers is computed as r = |{i ∈ [1, k] | ci ∈ Si}|. Example Secret: (1, 2, 3, 1) Extended guess: ({1}, {3}, {1}, {1, 3}) r = |{i ∈ [1, k] | ci ∈ Si}| = 2

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 19 / 42

slide-54
SLIDE 54

Analysis of PIN processing APIs An extended mastermind

White Markers

Secret : (c1, c2, . . . , ck), Extended guess: (S1, S2, . . . , Sk) pj = |{i ∈ [1, k] | j = ci}| occurrences of a color j in the secret qj = |{i ∈ [1, k] | j ∈ Si}| occurrences of a color j in the guess Definition (White markers) The number w of white markers is computed as w =

N

  • j=1

min(pj, qj) − r.

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 20 / 42

slide-55
SLIDE 55

Analysis of PIN processing APIs An extended mastermind

White Markers

Secret : (c1, c2, . . . , ck), Extended guess: (S1, S2, . . . , Sk) pj = |{i ∈ [1, k] | j = ci}| occurrences of a color j in the secret qj = |{i ∈ [1, k] | j ∈ Si}| occurrences of a color j in the guess Definition (White markers) The number w of white markers is computed as w =

N

  • j=1

min(pj, qj) − r. Example Secret (1, 2, 3, 1) and extended guess ({1}, {3}, {1}, {1, 3}): p1 = |{1, 4}| = 2, q1 = |{1, 3, 4}| = 3, min(p1, q1) = 2 p2 = 1, q2 = 0, min(p2, q2) = 0; p3 = 1, q3 = 2, min(p3, q3) = 1 w =

N

  • j=1

min(pj, qj) − r = 2 + 0 + 1 − 2 = 1

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 20 / 42

slide-56
SLIDE 56

Analysis of PIN processing APIs An extended mastermind

We can still play Mastermind

Proposition The Mastermind game is an instance of the Extended game Proof. Trivial: just restrict the sets in the estended guesses to singletons.

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 21 / 42

slide-57
SLIDE 57

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Cracking a PIN by playing extended Mastermind

Theorem PIN cracking is an instance of the Extended Mastermind game Proof. Intuition: Restrict to cases in which guesses (S1, S2, . . . , Sk) minus offset provide either equal or disjoint sets.

1 Modify the dectab mapping of all elements of the i-th set from d to

d + i (mod 10)

2 Compensate by −i (mod 10) the offset in the corresponding positions

to find out whether those PIN digits are in the set. The answer is four red markers if and only if PIN verification succeeds.

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 22 / 42

slide-58
SLIDE 58

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Example

Example: PIN V({4104, r}k,vdata,4, 0123456789012345,4732 )

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104 We play: ({4, 5, 6, 7, 8}, {0, 1, 7, 8, 9}, {0, 1}, {2, 3, 4, 5, 6})

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 23 / 42

slide-59
SLIDE 59

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Example

Example: PIN V({4104, r}k,vdata,4, 0123456789012345,4732 )

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104 We play: ({4, 5, 6, 7, 8}, {0, 1, 7, 8, 9}, {0, 1}, {2, 3, 4, 5, 6}) Subtract the offset: ({0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {7, 8}, {0, 1, 2, 3, 4}) Two disjoint sets: {0, 1, 2, 3, 4}, {7, 8}, change the dectab

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 23 / 42

slide-60
SLIDE 60

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Example

Example: PIN V({4104, r}k,vdata,4, 0123456789012345,4732 )

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104 We play: ({4, 5, 6, 7, 8}, {0, 1, 7, 8, 9}, {0, 1}, {2, 3, 4, 5, 6}) Subtract the offset: ({0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {7, 8}, {0, 1, 2, 3, 4}) Two disjoint sets: {0, 1, 2, 3, 4}, {7, 8}, change the dectab

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 23 / 42

slide-61
SLIDE 61

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Example

Example: PIN V({4104, r}k,vdata,4, 1234556909123455,4732 )

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104 We play: ({4, 5, 6, 7, 8}, {0, 1, 7, 8, 9}, {0, 1}, {2, 3, 4, 5, 6}) Subtract the offset: ({0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {7, 8}, {0, 1, 2, 3, 4}) Two disjoint sets: {0, 1, 2, 3, 4}, {7, 8}, change the dectab

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 23 / 42

slide-62
SLIDE 62

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Example

Example: PIN V({4104, r}k,vdata,4, 1234556909123455,4732 )

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104 We play: ({4, 5, 6, 7, 8}, {0, 1, 7, 8, 9}, {0, 1}, {2, 3, 4, 5, 6}) Subtract the offset: ({0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {7, 8}, {0, 1, 2, 3, 4}) Two disjoint sets: {0, 1, 2, 3, 4}, {7, 8}, change the dectab Compensate the offset

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 23 / 42

slide-63
SLIDE 63

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Example

Example: PIN V({4104, r}k,vdata,4, 1234556909123455,3611 )

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104 We play: ({4, 5, 6, 7, 8}, {0, 1, 7, 8, 9}, {0, 1}, {2, 3, 4, 5, 6}) Subtract the offset: ({0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {7, 8}, {0, 1, 2, 3, 4}) Two disjoint sets: {0, 1, 2, 3, 4}, {7, 8}, change the dectab Compensate the offset

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 23 / 42

slide-64
SLIDE 64

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Example

Example: PIN V({4104, r}k,vdata,4, 1234556909123455,3611 )

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 0472 ⊕ 4732 mod 10 = 4104 We play: ({4, 5, 6, 7, 8}, {0, 1, 7, 8, 9}, {0, 1}, {2, 3, 4, 5, 6}) Subtract the offset: ({0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {7, 8}, {0, 1, 2, 3, 4}) Two disjoint sets: {0, 1, 2, 3, 4}, {7, 8}, change the dectab Compensate the offset

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 23 / 42

slide-65
SLIDE 65

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Example

Example: PIN V({4104, r}k,vdata,4, 1234556909123455,3611 )

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1593 ⊕ 3611 mod 10 = 4104 We play: ({4, 5, 6, 7, 8}, {0, 1, 7, 8, 9}, {0, 1}, {2, 3, 4, 5, 6}) Subtract the offset: ({0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {7, 8}, {0, 1, 2, 3, 4}) Two disjoint sets: {0, 1, 2, 3, 4}, {7, 8}, change the dectab Compensate the offset

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 23 / 42

slide-66
SLIDE 66

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Example

Example: PIN V({4104, r}k,vdata,4, 1234556909123455,3611 )

1

deck({4104, r}k) = 4104, r 4104

2

encpdk(vdata) = A47295FDE32A48B1 1593 ⊕ 3611 mod 10 = 4104 We play: ({4, 5, 6, 7, 8}, {0, 1, 7, 8, 9}, {0, 1}, {2, 3, 4, 5, 6}) Subtract the offset: ({0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {7, 8}, {0, 1, 2, 3, 4}) Two disjoint sets: {0, 1, 2, 3, 4}, {7, 8}, change the dectab Compensate the offset PIN V returns ‘true’ iff PIN digits are in the sets

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 23 / 42

slide-67
SLIDE 67

Analysis of PIN processing APIs PIN cracking by playing Mastermind

An algorithm for the Extended Mastermind Problem

Based on [Knuth JRM76]: an algorithm for the solution of the standard Mastermind problem (quasi optimal solutions).

1 Tries all the possible guesses. For each guess, computes the number

  • f ‘surviving’ solutions related to each possible outcome of the guess;

2 Picks the guess from the previous step which minimizes the maximum

number of surviving solutions among all the possible outcomes and performs the guess.

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 24 / 42

slide-68
SLIDE 68

Analysis of PIN processing APIs PIN cracking by playing Mastermind

An algorithm for the Extended Mastermind Problem

Based on [Knuth JRM76]: an algorithm for the solution of the standard Mastermind problem (quasi optimal solutions).

1 Tries all the possible guesses. For each guess, computes the number

  • f ‘surviving’ solutions related to each possible outcome of the guess;

2 Picks the guess from the previous step which minimizes the maximum

number of surviving solutions among all the possible outcomes and performs the guess. Focus on two kinds of guesses: ({0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 4, 5}, {0, 1, 2, 3, 4, 5}), the same set repeated: checks if 6,7,8,9 are in the PIN ({1, 3}, {0, 2, 4, 5, 6, 7, 8, 9}, {0, 2, 4, 5, 6, 7, 8, 9}, {1, 3}),

  • ne set and its complementary

perform very well and still find a complete strategy

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 24 / 42

slide-69
SLIDE 69

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Summary of results for PIN cracking

Four digit PINs [Bond, Zielinski ’03] Average 16.5 API calls [Steel, TCS06] Average 16.145 API calls [Focardi, Luccio, FUN’10] Average 14.47 API calls with the previous algorithm in Python on this laptop ≈ 18 seconds

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 25 / 42

slide-70
SLIDE 70

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Summary of results for PIN cracking

Four digit PINs [Bond, Zielinski ’03] Average 16.5 API calls [Steel, TCS06] Average 16.145 API calls [Focardi, Luccio, FUN’10] Average 14.47 API calls with the previous algorithm in Python on this laptop ≈ 18 seconds Five digit PINs [Focardi, Luccio, FUN’10] Average 19.3 API calls ≈ 18 minutes

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 25 / 42

slide-71
SLIDE 71

Analysis of PIN processing APIs PIN cracking by playing Mastermind

Summary of results for PIN cracking

Four digit PINs [Bond, Zielinski ’03] Average 16.5 API calls [Steel, TCS06] Average 16.145 API calls [Focardi, Luccio, FUN’10] Average 14.47 API calls with the previous algorithm in Python on this laptop ≈ 18 seconds Five digit PINs [Focardi, Luccio, FUN’10] Average 19.3 API calls ≈ 18 minutes Lower bounds The lower bounds for 4 and 5 digit PINs are 13.362 and 16.689, for the average case

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 25 / 42

slide-72
SLIDE 72

Analysis of PIN processing APIs How to fix the API

The ‘lunch-break’ attack

A realistic scenario gaining access to the HSM and intercepting incoming data an insider might disclose thousands of PINs in a lunch-break!

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 26 / 42

slide-73
SLIDE 73

Analysis of PIN processing APIs How to fix the API

The ‘lunch-break’ attack

A realistic scenario gaining access to the HSM and intercepting incoming data an insider might disclose thousands of PINs in a lunch-break! How to prevent the attack? low-impact CVV-based fix [Focardi, Luccio, Steel, NORDSEC’09]

mitigates the attack (50000 times slower)

point-to-point MAC-based fix and type-based proof of security [Centenaro, Focardi, Luccio, Steel, ESORICS’09]

prevents the attack but requires modifying each HSM

efficient HSM upgrading strategies [Focardi, Luccio, ARSPA-WITS’10]

securing subnetworks while keeping service up

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 26 / 42

slide-74
SLIDE 74

Analysis of PIN processing APIs How to fix the API

What kind of attack?

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 27 / 42

slide-75
SLIDE 75

Analysis of PIN processing APIs How to fix the API

What kind of attack?

no cryptoanalysis and no broken protocols

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 27 / 42

slide-76
SLIDE 76

Analysis of PIN processing APIs How to fix the API

What kind of attack?

no cryptoanalysis and no broken protocols Information-flow: variations on the input produce unintended information leakage

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 27 / 42

slide-77
SLIDE 77

Information flow Noninterference

Absence of information leakage [Goguen, Meseguer’82]

Noninterference High behaviour is not

  • bservable by the Low attacker

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 28 / 42

slide-78
SLIDE 78

Information flow Noninterference

Absence of information leakage [Goguen, Meseguer’82]

Noninterference High behaviour is not

  • bservable by the Low attacker

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 28 / 42

slide-79
SLIDE 79

Information flow Noninterference

Absence of information leakage [Goguen, Meseguer’82]

Noninterference High behaviour is not

  • bservable by the Low attacker

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 28 / 42

slide-80
SLIDE 80

Information flow Noninterference

Absence of information leakage [Goguen, Meseguer’82]

Noninterference High behaviour is not

  • bservable by the Low attacker

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 28 / 42

slide-81
SLIDE 81

Information flow Noninterference

Noninterference is too much

PIN V({ 4104 , r}k,vdata, 4, 0123456789012345, 4732) PIN V intentionally ‘leaks’ the correctness of the PIN

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 29 / 42

slide-82
SLIDE 82

Information flow Noninterference

Noninterference is too much

PIN V({ 5832 , r}k,vdata, 4, 0123456789012345, 4732) PIN V intentionally ‘leaks’ the correctness of the PIN

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 29 / 42

slide-83
SLIDE 83

Information flow Noninterference

Noninterference is too much

PIN V({ 5832 , r}k,vdata, 4, 0123456789012345, 4732) PIN V intentionally ‘leaks’ the correctness of the PIN PIN correctness is declassified

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 29 / 42

slide-84
SLIDE 84

Information flow Robustness

Robust declassification [Myers, Sabelfeld, Zdancewic ’06]

Robustness Declassification is independent of the attacker behaviour the attacker cannot cause to release more information than intended

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 30 / 42

slide-85
SLIDE 85

Information flow Robustness

Robust declassification [Myers, Sabelfeld, Zdancewic ’06]

Robustness Declassification is independent of the attacker behaviour the attacker cannot cause to release more information than intended

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 30 / 42

slide-86
SLIDE 86

Information flow Robustness

Robust declassification [Myers, Sabelfeld, Zdancewic ’06]

Robustness Declassification is independent of the attacker behaviour the attacker cannot cause to release more information than intended

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 30 / 42

slide-87
SLIDE 87

Information flow Robustness

Robust declassification [Myers, Sabelfeld, Zdancewic ’06]

Robustness Declassification is independent of the attacker behaviour the attacker cannot cause to release more information than intended

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 30 / 42

slide-88
SLIDE 88

Information flow Robustness

PIN V is not robust!

PIN V({ 4104 , r}k,vdata, 4, 0123456789012345 , 4732) PIN correctness is declassified

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 31 / 42

slide-89
SLIDE 89

Information flow Robustness

PIN V is not robust!

PIN V({ 5832 , r}k,vdata, 4, 0123456789012345 , 4732) PIN correctness is declassified

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 31 / 42

slide-90
SLIDE 90

Information flow Robustness

PIN V is not robust!

PIN V({ 5832 , r}k,vdata, 4, 0123456789012345 , 4732) PIN correctness is declassified the insider tries a decimalization attack

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 31 / 42

slide-91
SLIDE 91

Information flow Robustness

PIN V is not robust!

PIN V({ 5832 , r}k,vdata, 4, 1123456789112345 , 4732) PIN correctness is declassified the insider tries a decimalization attack

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 31 / 42

slide-92
SLIDE 92

Information flow Robustness

PIN V is not robust!

PIN V({ 5832 , r}k,vdata, 4, 1123456789112345 , 4732) PIN correctness is declassified the insider tries a decimalization attack PIN V now fails in both cases

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 31 / 42

slide-93
SLIDE 93

Information flow Robustness

PIN V is not robust!

PIN V({ 4104 , r}k,vdata, 4, 1123456789112345 , 4732) PIN correctness is declassified the insider tries a decimalization attack PIN V now fails in both cases

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 31 / 42

slide-94
SLIDE 94

Information flow Robustness

PIN V is not robust!

PIN V({ 4104 , r}k,vdata, 4, 1123456789112345 , 4732) PIN correctness is declassified the insider tries a decimalization attack PIN V now fails in both cases the attacker has influenced declassification

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 31 / 42

slide-95
SLIDE 95

Information flow Robustness

The code for PIN verification, what is wrong ... ?

PIN V(EPB, vdata, len, dectab, offset) { x1 := encpdk(vdata); x2 := left(len, x1); x3 := decimalize(dectab, x2); u pin := sum mod10(x3, offset); x4 := deck(EPB); t pin := fcheck(x4); if (t pin =⊥) then return(′′format wrong′′); if (t pin = u pin) then return(′′PIN is correct′′); else return(′′PIN is wrong′′) }

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 32 / 42

slide-96
SLIDE 96

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-97
SLIDE 97

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

declassify(xH = yH);

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-98
SLIDE 98

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

declassify(xH = yH);

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-99
SLIDE 99

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

declassify(xH = yH); declassify(xH = zL);

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-100
SLIDE 100

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

declassify(xH = yH); declassify(xH = zL);

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-101
SLIDE 101

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

declassify(xH = yH); declassify(xH = zL); if zL declassify(xH);

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-102
SLIDE 102

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

declassify(xH = yH); declassify(xH = zL); if zL declassify(xH);

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-103
SLIDE 103

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

declassify(xH = yH); declassify(xH = zL); if zL declassify(xH);

user PIN u pin is computed from low-integrity data PIN V( {t pin, r}k , vdata,len,dectab,offset )

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-104
SLIDE 104

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

declassify(xH = yH); declassify(xH = zL); if zL declassify(xH);

user PIN u pin is computed from low-integrity data PIN V( {t pin, r}k , vdata,len,dectab,offset )

declassify(t pin = u pin)

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-105
SLIDE 105

Information flow Robustness

How to be robust?

declassify high-integrity data in high-integrity program points

declassify(xH = yH); declassify(xH = zL); if zL declassify(xH);

user PIN u pin is computed from low-integrity data PIN V( {t pin, r}k , vdata,len,dectab,offset )

declassify(t pin = u pin)

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 33 / 42

slide-106
SLIDE 106

Fixing the API A MAC-based solution

Fixing PIN V

add a Message Authentication Code m = {t pin, r}k, vdata,len,dectab,offset j PIN V+( {t pin, r}k, vdata,len,dectab,offset, m ) { if macj( {t pin, r}k, vdata,len,dectab,offset ) = m . . . old PIN V code . . . else FAIL } MAC guarantees that data come from a specific user

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 34 / 42

slide-107
SLIDE 107

Fixing the API Integrity w.r.t. a representative

Integrity representatives

MAC creation has to be regulated with these three MACs the attacker can get the first PIN digit {4104, r}k, vdata, 4, 0123456789012345, 4732 j {4104, r}k, vdata, 4, 1123456789112345, 4732 j {4104, r}k, vdata, 4, 1123456789112345, 3732 j

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 35 / 42

slide-108
SLIDE 108

Fixing the API Integrity w.r.t. a representative

Integrity representatives

MAC creation has to be regulated with these three MACs the attacker can get the first PIN digit {4104, r}k, vdata, 4, 0123456789012345, 4732 j {4104, r}k, vdata, 4, 1123456789112345, 4732 j {4104, r}k, vdata, 4, 1123456789112345, 3732 j vdata is the integrity representative: len, dectab, offset and the PIN are ‘determined’ by vdata

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 35 / 42

slide-109
SLIDE 109

Fixing the API Integrity w.r.t. a representative

Integrity representatives

MAC creation has to be regulated with these three MACs the attacker can get the first PIN digit {4104, r}k, vdata, 4, 0123456789012345, 4732 j {4104, r}k, vdata, 4, 1123456789112345, 4732 j {4104, r}k, vdata, 4, 1123456789112345, 3732 j vdata is the integrity representative: len, dectab, offset and the PIN are ‘determined’ by vdata More precisely, in the two MACs {pin1, r1}k, vdata , len1, dectab1, offset1j {pin2, r2}k, vdata , len2, dectab2, offset2j we require len1=len2, dectab1=dectab2, offset1=offset2, pin1=pin2

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 35 / 42

slide-110
SLIDE 110

Fixing the API Integrity w.r.t. a representative

... still not robust!

user 1 has inserted the correct PIN: PIN V+(EPB1, vdata1, len1, dectab1, offset1, m1) → true user 2 has typed a wrong PIN: PIN V+(EPB2, vdata2, len2, dectab2, offset2, m2) → false the attacker affects declassification by calling PIN V+with data from completely different users

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 36 / 42

slide-111
SLIDE 111

Fixing the API Integrity w.r.t. a representative

... still not robust!

user 1 has inserted the correct PIN: PIN V+(EPB1, vdata1, len1, dectab1, offset1, m1) → true user 2 has typed a wrong PIN: PIN V+(EPB2, vdata2, len2, dectab2, offset2, m2) → false the attacker affects declassification by calling PIN V+with data from completely different users ... he only gets the expected outputs

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 36 / 42

slide-112
SLIDE 112

Fixing the API Integrity w.r.t. a representative

... still not robust!

user 1 has inserted the correct PIN: PIN V+(EPB1, vdata1, len1, dectab1, offset1, m1) → true user 2 has typed a wrong PIN: PIN V+(EPB2, vdata2, len2, dectab2, offset2, m2) → false the attacker affects declassification by calling PIN V+with data from completely different users ... he only gets the expected outputs disallow changes to vdata

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 36 / 42

slide-113
SLIDE 113

Fixing the API Robustness, intuitively

PIN V+is robust, for each user

PIN V+( {pin, r}k, vdata, len, dectab, offset, {pin, r}k, vdata, len, dectab, offset j )

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 37 / 42

slide-114
SLIDE 114

Fixing the API Robustness, intuitively

PIN V+is robust, for each user

PIN V+( {pin, r}k, vdata, len, dectab, offset, {pin, r}k, vdata, len, dectab, offset j )

1 vdata cannot be manipulated (focus on one user) FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 37 / 42

slide-115
SLIDE 115

Fixing the API Robustness, intuitively

PIN V+is robust, for each user

PIN V+( {pin, r}k, vdata, len, dectab, offset, {pin, r}k, vdata, len, dectab, offset j )

1 vdata cannot be manipulated (focus on one user) 2 vdata in the MAC must correspond FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 37 / 42

slide-116
SLIDE 116

Fixing the API Robustness, intuitively

PIN V+is robust, for each user

PIN V+( {pin, r}k, vdata, len, dectab, offset, {pin, r}k, vdata, len, dectab, offset j )

1 vdata cannot be manipulated (focus on one user) 2 vdata in the MAC must correspond 3 pin, len, dectab and offset in the MAC are determined FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 37 / 42

slide-117
SLIDE 117

Fixing the API Robustness, intuitively

PIN V+is robust, for each user

PIN V+( {pin, r}k, vdata, len, dectab, offset, {pin, r}k, vdata, len, dectab, offset j )

1 vdata cannot be manipulated (focus on one user) 2 vdata in the MAC must correspond 3 pin, len, dectab and offset in the MAC are determined 4 ... and must correspond to the ones outside FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 37 / 42

slide-118
SLIDE 118

Fixing the API Robustness, intuitively

PIN V+is robust, for each user

PIN V+( {pin, r}k, vdata, len, dectab, offset, {pin, r}k, vdata, len, dectab, offset j )

1 vdata cannot be manipulated (focus on one user) 2 vdata in the MAC must correspond 3 pin, len, dectab and offset in the MAC are determined 4 ... and must correspond to the ones outside

Note: The only possible change is in the random padding r ⇒ PIN V+result cannot be influenced by the attacker ⇒ PIN V+is robust

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 37 / 42

slide-119
SLIDE 119

Fixing the API Robustness, intuitively

PIN V+is robust, for each user

PIN V+( {pin, r}k, vdata, len, dectab, offset, {pin, r}k, vdata, len, dectab, offset j )

1 vdata cannot be manipulated (focus on one user) 2 vdata in the MAC must correspond 3 pin, len, dectab and offset in the MAC are determined 4 ... and must correspond to the ones outside

Note: The only possible change is in the random padding r ⇒ PIN V+result cannot be influenced by the attacker ⇒ PIN V+is robust vdata : [VDATA] , dectab : [DTAB← ֓VDATA]

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 37 / 42

slide-120
SLIDE 120

Fixing the API Confidentiality via cryptography

The ISO0 PIN block format

encrypting a secret produces a low-confidentiality ciphertext Noninterference: changes to the secret plaintexts should be unobservable not true in general: {1234}k = {1234}k

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 38 / 42

slide-121
SLIDE 121

Fixing the API Confidentiality via cryptography

The ISO0 PIN block format

encrypting a secret produces a low-confidentiality ciphertext Noninterference: changes to the secret plaintexts should be unobservable not true in general: {1234}k = {1234}k {1234}k = {5678}k

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 38 / 42

slide-122
SLIDE 122

Fixing the API Confidentiality via cryptography

The ISO0 PIN block format

encrypting a secret produces a low-confidentiality ciphertext Noninterference: changes to the secret plaintexts should be unobservable not true in general: {1234}k = {1234}k {1234}k = {5678}k randomization helps: {1234, r}k = {1234, r′}k

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 38 / 42

slide-123
SLIDE 123

Fixing the API Confidentiality via cryptography

The ISO0 PIN block format

encrypting a secret produces a low-confidentiality ciphertext Noninterference: changes to the secret plaintexts should be unobservable not true in general: {1234}k = {1234}k {1234}k = {5678}k randomization helps: {1234, r}k = {1234, r′}k {1234, r}k = {5678, r′}k

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 38 / 42

slide-124
SLIDE 124

Fixing the API Confidentiality via cryptography

The ISO0 PIN block format

encrypting a secret produces a low-confidentiality ciphertext Noninterference: changes to the secret plaintexts should be unobservable not true in general: {1234}k = {1234}k {1234}k = {5678}k randomization helps: {1234, r}k = {1234, r′}k {1234, r}k = {5678, r′}k ISO0 uses (a part of) vdata: {1234, vdata}k

for different users with the same PIN, vdata is like randomization {1234, vdata}k = {1234, vdata′}k for one user the PIN is determined by vdata

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 38 / 42

slide-125
SLIDE 125

Fixing the API Confidentiality via cryptography

The ISO0 PIN block format

encrypting a secret produces a low-confidentiality ciphertext Noninterference: changes to the secret plaintexts should be unobservable not true in general: {1234}k = {1234}k {1234}k = {5678}k randomization helps: {1234, r}k = {1234, r′}k {1234, r}k = {5678, r′}k ISO0 uses (a part of) vdata: {1234, vdata}k

for different users with the same PIN, vdata is like randomization {1234, vdata}k = {1234, vdata′}k for one user the PIN is determined by vdata

⇒ noninterference holds

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 38 / 42

slide-126
SLIDE 126

Fixing the API Summary

Summary: fixing PIN management APIs

robustness in a non-randomized cryptographic setting: existing PIN processing APIs are not robust a MAC-based fix of PIN V (and PIN T in the paper)

low-impact CVV-based fix [Focardi, Luccio, Steel, NORDSEC’09]

integrity w.r.t. a representative, e.g., dectab : [DTAB← ֓VDATA] a type system to type-check APIs Theorem

1

Γ ⊢ P then P is robust

2

if P does not declassify data, then P satisfies noninterference, too

More detail in [Centenaro, Focardi, Luccio, Steel, ESORICS’09]

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 39 / 42

slide-127
SLIDE 127

Analysis of PIN processing APIs Conclusion

Conlusion

API-level attacks to guess bank PINs (much more can be found in [Bond, Zielinski ’03, Clulow ’03]) How to become rich by playing Mastermind: almost-optimal strategies to break PINs [Focardi, Luccio, FUN’10] Language-based analysis and fixes [Centenaro, Focardi, Luccio, Steel, ESORICS’09, Focardi, Luccio, Steel, NORDSEC’09]

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 40 / 42

slide-128
SLIDE 128

Analysis of PIN processing APIs Conclusion

Conlusion

API-level attacks to guess bank PINs (much more can be found in [Bond, Zielinski ’03, Clulow ’03]) How to become rich by playing Mastermind: almost-optimal strategies to break PINs [Focardi, Luccio, FUN’10] Language-based analysis and fixes [Centenaro, Focardi, Luccio, Steel, ESORICS’09, Focardi, Luccio, Steel, NORDSEC’09] Tomorrow we will see why some smarcard and crypto-tokens can be easily cloned

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 40 / 42

slide-129
SLIDE 129

Analysis of PIN processing APIs Conclusion

References

  • M. Bond and P. Zielinski.

Decimalization table attacks for PIN cracking. UCAM-CL-TR-560, Univ. Cambridge, Computer Lab., 2003.

  • M. Centenaro, R. Focardi, F.L. Luccio, G. Steel.

Type-Based Analysis of PIN Processing APIs In proceedings of ESORICS’09, September 2009.

  • J. Clulow.

The design and analysis of cryptographic APIs for security devices. Master’s thesis, University of Natal, Durban, 2003.

  • R. Focardi, F.L. Luccio,

Cracking bank pins by playing mastermind. In Proceedings of FUN’10, June 2010.

  • R. Focardi, F.L. Luccio, G. Steel.

Blunting Differential Attacks on PIN Processing APIs In proceedings of NORDSEC’09, Obtober 2009.

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 41 / 42

slide-130
SLIDE 130

Analysis of PIN processing APIs Conclusion

References

  • R. Focardi, F.L. Luccio.

Secure upgrade of hardware security modules in bank networks ARSPA-WITS10 Paphos, Cyprus March 27-28, 2010. IBM Inc. CCA Basic Services Reference and Guide for the IBM 4758 PCI Technical report, 2006. Rel. 2.53–3.27.

  • A. Myers, A. Sabelfeld, and S. Zdancewic.

Enforcing robust declassification and qualified robustness. Journal of Computer Security, 14(2):157–196, May 2006.

  • G. Steel.

Formal Analysis of PIN Block Attacks Theoretical Computer Science, 367, 1-2, pages 257-270, November 2006.

  • D. Knuth,

The Computer as a Master Mind, Journal of Recreational Mathematics, 9, pages 1-6, 1976.

FOSAD 2010 () Analysis of Security APIs September 2010, Bertinoro 42 / 42