unboxing the whitebox - intl cryptographic module ...€¦ · unboxing the whitebox jasper van...

48
Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16

Upload: others

Post on 29-Sep-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Unboxing the whitebox

Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16

Page 2: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Riscure

•  Pay TV, EMVco, smart meter, CC

Certification

•  Mobile (TEE/HCE/WBC) •  Secure architecture / design

Evaluation & consultancy

•  Side channel analysis, fault injection

Tools

•  Whitebox crypto, SCA, FI

Training

Page 3: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Protecting the keys…

Plain Text

Key

Crypto Cipher Text

Internal state needs to be protected

Secure Environment

Page 4: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

•  White-Box cryptography -> secure software crypto in an untrusted environment

•  Being used today in Pay TV DRMs, mobile payments, …

•  This talk: applying hardware attack concepts to software environments

What and why…

Page 5: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Introduction

Key recovery attacks

Conclusion

Page 6: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Sign of the times…

Page 7: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Sign of the times…

Page 8: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Software in the White-Box context

Crypto

Input

Output

Business logic

key I/O Direct access

Can be modified at will

Page 9: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

•  Protection against key extraction in the white-box security model

•  A technique that allows merging a key into a given crypto algorithm:

•  Described for the first time in 2002 by S. Chow et al. •  Available for AES and DES

•  Lookup tables used for applying mathematical transforms to data

•  Remove the distinction between keys and crypto algorithm code.

•  “Pure WBC” weakness: cloning/lifting

White-Box Cryptography

Page 10: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

How does WBC work?

Imagesource:whiteboxcrypto.com

Page 11: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

WBC Construction: partial evaluation

inkey

out

Tin

out

S

Page 12: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

WBC Construction: encoding

T’in

out

T

in

out

DECODE

ENCODE

Internalencoding

Page 13: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

External encoding

WB AES E(INPUT) E’(OUTPUT)

DEC

OD

E

ENC

OD

E

SnDECO

DE

ENCO

DE

S2DECO

DE

ENCO

DE

S1DECO

DE

ENCO

DE

Sending Process

Receiving Process

ENCODE DECODE

Page 14: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

•  Attacks for all academic WBC proposals •  Focus on key extraction •  Type of transformations assumed known •  Concrete transformation and key unknown

•  In real life… •  we do not know much about the design!

•  Not many publicly documented SCA/FI on WBC •  Implementation-specific DFA paper in 2002 [2] •  Recent generic DPA-like attack in [3]*

WBC attack literature

* Authors coined the term Differential Computational Analysis

Page 15: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Side channel analysis (SCA) / intermediate data analysis

Observedatahere

Potential attacks on WBC (I)

andcompareittoexpecteddatahere

Page 16: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Data manipulation – Fault Injection (FI)

Modifydatahere

Potential attacks on WBC (II)

andobservechangestotheoutput

Page 17: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Process manipulation – Fault injection (FI)

Potential attacks on WBC (III)

Modifycodeflowhere

andobservechangestotheoutput

Page 18: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Key recovery attacks

Introduction

Conclusion

Page 19: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Fault Injection Attacks …on WBC

Page 20: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Differential Fault Analysis

Correct result

Faulty result

Correct result

Faulty result

Correct result

Faulty result

Correct result

Faulty result

Page 21: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

DFA computation for DES

L16R16

R15L15

R16=F(R15,K16)⊕L15

R’16=F(R’15,K16)⊕L15

R16⊕R’16=F(R15,K16)⊕F(R’15,K16)

XOR

R’16 L’16

R’15K16

K15

Page 22: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

How to port DFA to WBC?

Page 23: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

1.  Location of fault injection point 2.  Fault injection and ciphertext collection

▪  Multiple options available

3.  Fault analysis ▪  We use our own tools ▪  Some AES DFA examples on GitHub

DFA attack process

Page 24: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

•  Binary DES encryption WBC •  Challenge posted at whiteboxcrypto.com

•  DES key hidden within lookups •  Key value is 0x30 0x32 0x34 0x32 0x34 0x36 0x32 0x36

•  We’ll demo all our attacks on this target

Example target: wbDES

Page 25: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Red: writes Green: reads

STEP 1: Locating the injection point

Event counter

Sta

ck s

pace

Target area

Page 26: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

STEP 2: Fault injection

1.  Select target event within target region 2.  Modify data read by that event 3.  Collect input/output pairs

If event id within target region

Invert a random bit

Page 27: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

STEP 3: Analysis

DEMO

Page 28: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Demo screenshots

Page 29: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Summary DFA results

Implementation Fault injection Results

Wyseur (DES) Unicorn script Broken in 40 faults Hack.lu 2009

(AES) Debugger script Broken in 90 faults

SSTIC 2012 (DES) Modified lifted code Broken in 60 faults

Karroumi (AES) Modified source code Broken in 80 faults

NSC 2013 (encoded AES) N/A

Not broken – encoding makes DFA not feasible

Page 30: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Side Channel Attacks …on WBC

Page 31: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Differential Power Analysis attack First proposed ~1998 by Paul Kocher to attack on smart cards: ü Measuring power consumption of a crypto execution ü  Take multiple measurements for different inputs ü  Infer information about the key from the difference of these

What is a DPA attack?

Page 32: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Differential trace

00

00

11

11

Groupbyknowndata Averagetrace

Subtract

DifferenPaltrace

Page 33: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Hypothesis testing

Page 34: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Generalization of differential SCA attacks

TakemulIple“measurements”ofbehaviorofcryptooperaIonsfor

differentdata

Predictbehaviorforsubkeysbasedonthesamedataand“leakage”

model

ApplystaIsIcalmethodstodisInguishthe“best”subkey•  Differenceofmeans•  CorrelaIon•  MutualInformaIonanalysis,Linearregression

analysis,…

Findcorrectguessesforallsubkeystodeterminekey

Page 35: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

To our surprise….

It works on White Box Crypto out-of-the-box!!!

Page 36: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

SCA attack process

1.  Instrument WBC to collect “measurements” •  Again:

2.  Execute WBC with random inputs multiple times 3.  Collect “measurement – input/output pairs” in useable

form 4.  SCA Analysis

Page 37: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

STEP1: Capture measurement

•  Grab the data using any method that fits your target •  Instrument execution (eg. PIN, Valgrind) •  Capture stack snapshots per crypto round (Hooking,

debugger) •  Use emulators and record (QEMU, Unicorn, PANDA)

•  Capture any information during execution that might leak •  All reads/writes to memory •  Lower bits of addresses of memory accesses •  All register contents

Page 38: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

STEP2+3: Execute + Collect

•  Provide/inject random input data, capture output data •  Program arguments •  Use instrumentation from STEP 1

•  Store it in a way that allows testing key guesses •  Store as single bit samples •  Assure alignment between multiple captures

Page 39: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

STEP 4: SCA Analysis

Same target as for DFA: wbDES Same hidden key: 0x30 0x32 0x34 0x32 0x34 0x36 0x32 0x36

DEMO

Page 40: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Demo screenshots

Page 41: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Summary SCA results

Implementation

Attacked intermediate Results

Wyseur (DES) Round output Broken in 75

traces Hack.lu 2009

(AES) S-Box output Broken in 16 traces

SSTIC 2012 (DES) Round output Broken in 16

traces

Karroumi (AES)

S-Box and GF(256) inverse

Broken in ~2000 traces

NSC 2013 (encoded

AES) N/A Not broken

Page 42: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Introduction

Key recovery attacks

Conclusion

Page 43: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

What does it mean?

No detailed knowledge required •  Of WBC implementation •  Where the WBC is processed exactly

No manipulation required Ø A secret random input/output encoding is the only barrier But: These random encodings do not work for many real world applications After instrumentation, push-button attack

Page 44: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Side Channel Analysis attacks •  Must prevent statistical dependence between intermediates

and key •  Typical countermeasures based on randomness difficult in

white-box scenario

Differential Fault Analysis attacks •  Double-checks on encoded data -> might be bypassed if

detected! •  Carry redundant data along computation? •  Break fault models by propagating faults?

Mitigating WBC leakage

Page 45: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Mitigating WBC attacks

Obfuscation •  Control-flow obfuscation •  Data obfuscation

Anti-analysis and anti-tamper •  Detect debugger/emulator •  Detect hooks and modifications

Device binding •  Bind code to current device

WBC

Input

Output

Protected binary

Business logic

I/O

Page 46: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Take it away

•  Like many security tech, WBC mitigates attacks •  Key extraction effort we’ve seen: days to few months

•  WBC designers: •  Validate your assumptions(!) •  Always combine strong RE / cloning countermeasures

•  WBC integrators: •  Ask for all countermeasures •  Ask for quantified attack resistance against all known

attacks

Page 47: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

Riscure North America 71 Stevenson Street, Suite 400 San Francisco, CA 94105 USA Phone: +1 650 646 99 79 [email protected]

Riscure B.V. Frontier Building, Delftechpark 49 2628 XJ Delft The Netherlands Phone: +31 15 251 40 90 www.riscure.com

Contact:

Riscure North America 71 Stevenson Street, Suite 400 San Francisco, CA 94105 USA Phone: +1 650 646 99 79 [email protected]

Riscure B.V. Frontier Building, Delftechpark 49 2628 XJ Delft The Netherlands Phone: +31 15 251 40 90 www.riscure.com

Contact: Jasper van Woudenberg (@jzvw) [email protected]

Page 48: Unboxing the whitebox - Intl Cryptographic Module ...€¦ · Unboxing the whitebox Jasper van Woudenberg @jzvw CTO Riscure North America ICMC’16 . Riscure • Pay TV, EMVco, smart

References

[1] http://crypto.stanford.edu/DRM2002/whitebox.pdf [2] http://crypto.stanford.edu/DRM2002/drm1.pdf [3] https://eprint.iacr.org/2015/753 [4] https://www.cosic.esat.kuleuven.be/publications/thesis-152.pdf [5] https://www.cosic.esat.kuleuven.be/publications/thesis-235.pdf