analysis of security apis (part i) · guessing a secret via api calls the mastermind game the...

130
Analysis of Security APIs (part I) Riccardo Focardi Universit` a Ca’ Foscari di Venezia, Italy [email protected] 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

Upload: others

Post on 21-Jun-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Analysis of Security APIs(part I)

Riccardo Focardi

Universita Ca’ Foscari di Venezia, [email protected]

http://www.dsi.unive.it/~focardi

http://secgroup.ext.dsi.unive.it/

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

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

Page 2: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Security APIs Introduction

Security APIs

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

Page 3: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Security APIs Introduction

Example 1: Hardware Security Module (HSM)

Used in the ATM Bank network

Tamper resistant

Security API for

Managing cryptographic keysDecrypting/re-encrypting the PINChecking the validity of the PIN

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

Page 4: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Security APIs Introduction

Example 2: PKCS#11 API for tokens/smarcards

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

Page 5: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Security APIs Introduction

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

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

Page 6: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Security APIs Introduction

Outline of the course

Today: PIN processing APIs

Attacks to guess bank PINsBest strategies to break PINsLanguage-based analysis and fixes

Tomorrow: PKCS#11 devices

Attacks to compromise a sensitive keyA formal model of PKCS#11How to secure PKCS#11: a software tokenTookan: Analysis of real tokens

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

Page 7: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

PIN processing APIs The ATM bank network

PIN processing infrastructure

PINPINPIN

PIN

PIN

Accept

Refuse

{PIN}k1

{PIN}k2

{PIN}k3

{PIN}k4

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

Page 8: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

PIN processing APIs The ATM bank network

PIN processing infrastructure

PIN

PINPIN

PIN

PIN

Accept

Refuse

{PIN}k1

{PIN}k2

{PIN}k3

{PIN}k4

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

Page 9: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

PIN processing APIs The ATM bank network

PIN processing infrastructure

PINPINPIN

PIN

PIN

Accept

Refuse

{PIN}k1

{PIN}k2

{PIN}k3

{PIN}k4

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

Page 10: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

PIN processing APIs The ATM bank network

PIN processing infrastructure

PINPINPIN

PIN

PIN

Accept

Refuse

{PIN}k1

{PIN}k2

{PIN}k3

{PIN}k4

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

Page 11: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 12: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

PIN processing APIs The ATM bank network

Hardware Security Module (HSM)

Tamper resistant

Security API for

Managing cryptographic keysDecrypting/re-encrypting the PINChecking the validity of the PIN

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

Page 13: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’

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

Page 14: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’

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

Page 15: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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) = A47295FDE 32A48B10472 ⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’

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

Page 16: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’

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

Page 17: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B1

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

Page 18: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B1

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

Page 19: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472

⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’

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

Page 20: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’

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

Page 21: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’

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

Page 22: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 23: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 24: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 25: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 26: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Guessing a secret via API calls The Mastermind Game

The Mastermind Game

Invented by the Israeli postmaster and telecommunications expertMordecai Meirowitz in 1970;

4 pegs from 6 possible colors, duplicates are allowed.

The codemaker chooses a sequence of 4 pegs, the codebreaker has toguess it

Goal: Minimize the number of guesses

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

Page 27: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 28: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 mod 10 = 4104

3 The two values coincide: PIN V returns ‘true’

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

Page 29: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 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

Page 30: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 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

Page 31: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 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

Page 32: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 4732 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

Page 33: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 4732 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

Page 34: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 4732 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

Page 35: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 4732 mod 10 = 5104

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

Page 36: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 4732 mod 10 = 5104

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

Page 37: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 4732 mod 10 = 5104

3 PIN V returns ‘false’

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

Page 38: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 4732 mod 10 = 5104

3 PIN V returns ‘false’

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

Page 39: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 3732 mod 10 = 5104

3 PIN V returns ‘false’

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

Page 40: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 3732 mod 10 = 5104

3 PIN V returns ‘false’

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

Page 41: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 3732 mod 10 = 4104

3 PIN V returns ‘false’

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

Page 42: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 3732 mod 10 = 4104

3 PIN V returns ‘false’

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

Page 43: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 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

Page 44: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 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

Page 45: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 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

Page 46: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11472 ⊕ 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

Page 47: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 onlyacademically possible”“What we see now is people going right to the source [..] and stealing theencrypted 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

Page 48: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 49: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 ∈ CExtended 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

Page 50: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 ∈ CExtended 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

Page 51: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 ∈ CExtended 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

Page 52: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Analysis of PIN processing APIs An extended mastermind

Red Markers

Colors: C = {0, 1, . . . ,N − 1}Secret sequence: (c1, c2, . . . , ck), with c1, . . . , ck ∈ CExtended 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

Page 53: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Analysis of PIN processing APIs An extended mastermind

Red Markers

Colors: C = {0, 1, . . . ,N − 1}Secret sequence: (c1, c2, . . . , ck), with c1, . . . , ck ∈ CExtended 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

Page 54: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 secretqj = |{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

Page 55: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 secretqj = |{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

Page 56: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 57: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 offsetprovide either equal or disjoint sets.

1 Modify the dectab mapping of all elements of the i-th set from d tod + i (mod 10)

2 Compensate by −i (mod 10) the offset in the corresponding positionsto 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

Page 58: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 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

PIN V returns ‘true’ iff PIN digits are in the sets

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

Page 59: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 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

PIN V returns ‘true’ iff PIN digits are in the sets

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

Page 60: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 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

PIN V returns ‘true’ iff PIN digits are in the sets

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

Page 61: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 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

PIN V returns ‘true’ iff PIN digits are in the sets

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

Page 62: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 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

PIN V returns ‘true’ iff PIN digits are in the sets

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

Page 63: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 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

PIN V returns ‘true’ iff PIN digits are in the sets

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

Page 64: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B10472 ⊕ 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

PIN V returns ‘true’ iff PIN digits are in the sets

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

Page 65: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11593 ⊕ 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

Page 66: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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, r4104

2 encpdk(vdata) = A47295FDE 32A48B11593 ⊕ 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

Page 67: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 standardMastermind problem (quasi optimal solutions).

1 Tries all the possible guesses. For each guess, computes the numberof ‘surviving’ solutions related to each possible outcome of the guess;

2 Picks the guess from the previous step which minimizes the maximumnumber of surviving solutions among all the possible outcomes andperforms 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}),one set and its complementary

perform very well and still find a complete strategy

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

Page 68: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 standardMastermind problem (quasi optimal solutions).

1 Tries all the possible guesses. For each guess, computes the numberof ‘surviving’ solutions related to each possible outcome of the guess;

2 Picks the guess from the previous step which minimizes the maximumnumber of surviving solutions among all the possible outcomes andperforms 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}),one set and its complementary

perform very well and still find a complete strategy

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

Page 69: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 callswith 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, forthe average case

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

Page 70: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 callswith 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, forthe average case

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

Page 71: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 callswith 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, forthe average case

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

Page 72: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 insidermight 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

Page 73: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 insidermight 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

Page 74: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 unintendedinformation leakage

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

Page 75: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 unintendedinformation leakage

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

Page 76: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 unintendedinformation leakage

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

Page 77: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Noninterference

Absence of information leakage [Goguen, Meseguer’82]

Noninterference

High behaviour is notobservable by the Low attacker

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

Page 78: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Noninterference

Absence of information leakage [Goguen, Meseguer’82]

Noninterference

High behaviour is notobservable by the Low attacker

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

Page 79: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Noninterference

Absence of information leakage [Goguen, Meseguer’82]

Noninterference

High behaviour is notobservable by the Low attacker

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

Page 80: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Noninterference

Absence of information leakage [Goguen, Meseguer’82]

Noninterference

High behaviour is notobservable by the Low attacker

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

Page 81: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

PIN correctness isdeclassified

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

Page 82: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 isdeclassified

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

Page 83: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 isdeclassified

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

Page 84: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

Robust declassification [Myers, Sabelfeld, Zdancewic ’06]

Robustness

Declassification is independent ofthe attacker behaviour

the attacker cannot cause torelease more informationthan intended

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

Page 85: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

Robust declassification [Myers, Sabelfeld, Zdancewic ’06]

Robustness

Declassification is independent ofthe attacker behaviour

the attacker cannot cause torelease more informationthan intended

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

Page 86: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

Robust declassification [Myers, Sabelfeld, Zdancewic ’06]

Robustness

Declassification is independent ofthe attacker behaviour

the attacker cannot cause torelease more informationthan intended

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

Page 87: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

Robust declassification [Myers, Sabelfeld, Zdancewic ’06]

Robustness

Declassification is independent ofthe attacker behaviour

the attacker cannot cause torelease more informationthan intended

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

Page 88: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

PIN V is not robust!

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

PIN correctness isdeclassified

the insider tries adecimalization attack

PIN V now fails in bothcases

the attacker hasinfluenced declassification

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

Page 89: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

PIN V is not robust!

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

PIN correctness isdeclassified

the insider tries adecimalization attack

PIN V now fails in bothcases

the attacker hasinfluenced declassification

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

Page 90: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

PIN V is not robust!

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

PIN correctness isdeclassified

the insider tries adecimalization attack

PIN V now fails in bothcases

the attacker hasinfluenced declassification

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

Page 91: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

PIN V is not robust!

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

PIN correctness isdeclassified

the insider tries adecimalization attack

PIN V now fails in bothcases

the attacker hasinfluenced declassification

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

Page 92: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

PIN V is not robust!

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

PIN correctness isdeclassified

the insider tries adecimalization attack

PIN V now fails in bothcases

the attacker hasinfluenced declassification

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

Page 93: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

PIN V is not robust!

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

PIN correctness isdeclassified

the insider tries adecimalization attack

PIN V now fails in bothcases

the attacker hasinfluenced declassification

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

Page 94: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Information flow Robustness

PIN V is not robust!

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

PIN correctness isdeclassified

the insider tries adecimalization attack

PIN V now fails in bothcases

the attacker hasinfluenced declassification

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

Page 95: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 96: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 97: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 98: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 99: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 100: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 101: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 102: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 103: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 104: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 105: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 106: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 . . .

elseFAIL

}

MAC guarantees that data come from a specific user

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

Page 107: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 PINare ‘determined’ by vdata

More precisely, in the two MACs

〈{pin1, r1}k , vdata , len1, dectab1, offset1〉j〈{pin2, r2}k , vdata , len2, dectab2, offset2〉j

we require len1=len2, dectab1=dectab2, offset1=offset2, pin1=pin2

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

Page 108: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 PINare ‘determined’ by vdata

More precisely, in the two MACs

〈{pin1, r1}k , vdata , len1, dectab1, offset1〉j〈{pin2, r2}k , vdata , len2, dectab2, offset2〉j

we require len1=len2, dectab1=dectab2, offset1=offset2, pin1=pin2

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

Page 109: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 PINare ‘determined’ by vdata

More precisely, in the two MACs

〈{pin1, r1}k , vdata , len1, dectab1, offset1〉j〈{pin2, r2}k , vdata , len2, dectab2, offset2〉j

we require len1=len2, dectab1=dectab2, offset1=offset2, pin1=pin2

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

Page 110: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 fromcompletely different users

... he only gets the expected outputs

disallow changes to vdata

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

Page 111: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 fromcompletely different users

... he only gets the expected outputs

disallow changes to vdata

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

Page 112: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 fromcompletely different users

... he only gets the expected outputs

disallow changes to vdata

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

Page 113: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 114: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 115: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 116: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 117: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 118: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 119: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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

Page 120: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 beunobservable

not true in general: {1234}k = {1234}k

randomization helps: {1234, r}k 6= {1234, 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 6= {1234, vdata′}kfor one user the PIN is determined by vdata

⇒ noninterference holds

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

Page 121: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 beunobservable

not true in general: {1234}k = {1234}k{1234}k 6= {5678}k

randomization helps: {1234, r}k 6= {1234, 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 6= {1234, vdata′}kfor one user the PIN is determined by vdata

⇒ noninterference holds

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

Page 122: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 beunobservable

not true in general: {1234}k = {1234}k{1234}k 6= {5678}k

randomization helps: {1234, r}k 6= {1234, 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 6= {1234, vdata′}kfor one user the PIN is determined by vdata

⇒ noninterference holds

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

Page 123: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 beunobservable

not true in general: {1234}k = {1234}k{1234}k 6= {5678}k

randomization helps: {1234, r}k 6= {1234, r ′}k{1234, r}k 6= {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 6= {1234, vdata′}kfor one user the PIN is determined by vdata

⇒ noninterference holds

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

Page 124: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 beunobservable

not true in general: {1234}k = {1234}k{1234}k 6= {5678}k

randomization helps: {1234, r}k 6= {1234, r ′}k{1234, r}k 6= {5678, r ′}k

ISO0 uses (a part of) vdata: {1234, vdata}kfor different users with the same PIN, vdata is like randomization{1234, vdata}k 6= {1234, vdata′}kfor one user the PIN is determined by vdata

⇒ noninterference holds

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

Page 125: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 beunobservable

not true in general: {1234}k = {1234}k{1234}k 6= {5678}k

randomization helps: {1234, r}k 6= {1234, r ′}k{1234, r}k 6= {5678, r ′}k

ISO0 uses (a part of) vdata: {1234, vdata}kfor different users with the same PIN, vdata is like randomization{1234, vdata}k 6= {1234, vdata′}kfor one user the PIN is determined by vdata

⇒ noninterference holds

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

Page 126: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Fixing the API Summary

Summary: fixing PIN management APIs

robustness in a non-randomized cryptographic setting: existing PINprocessing 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 satisfiesnoninterference, too

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

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

Page 127: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Analysis of PIN processing APIs Conclusion

Conlusion

X API-level attacks to guess bank PINs(much more can be found in [Bond, Zielinski ’03, Clulow ’03])

X How to become rich by playing Mastermind:almost-optimal strategies to break PINs [Focardi, Luccio, FUN’10]

X 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 beeasily cloned

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

Page 128: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Analysis of PIN processing APIs Conclusion

Conlusion

X API-level attacks to guess bank PINs(much more can be found in [Bond, Zielinski ’03, Clulow ’03])

X How to become rich by playing Mastermind:almost-optimal strategies to break PINs [Focardi, Luccio, FUN’10]

X 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 beeasily cloned

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

Page 129: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

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 APIsIn 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 APIsIn proceedings of NORDSEC’09, Obtober 2009.

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

Page 130: Analysis of Security APIs (part I) · Guessing a secret via API calls The Mastermind Game The Mastermind Game Invented by the Israeli postmaster and telecommunications expert Mordecai

Analysis of PIN processing APIs Conclusion

References

R. Focardi, F.L. Luccio.Secure upgrade of hardware security modules in bank networksARSPA-WITS10 Paphos, Cyprus March 27-28, 2010.

IBM Inc.CCA Basic Services Reference and Guide for the IBM 4758 PCITechnical 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 AttacksTheoretical 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