devnology smartcardrfid nov 2012 - institute for computing ...lukas grunwald managed to crash...

46
H ki s t ds & RFID Hacking smartcards & RFID Erik Poll Di i l i Digital Security Radboud University Nijmegen 1

Upload: others

Post on 24-Jan-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

H ki s t ds & RFIDHacking smartcards & RFID

Erik PollDi i l iDigital Security

Radboud University Nijmegen

1

Page 2: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

What are smartcards & RFID tags?What are smartcards & RFID tags?

Micro-controller

with contact interface with contact interface

or contactless interface

Erik Poll – Digital Security 2

Page 3: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Why use them?Why use them?

Convenience• more convenient than username/password

Security• more secure than username/password

Also more convenient & secure than barcodes and magstripesAlso more convenient & secure than barcodes and magstripes

Erik Poll – Digital Security 3

Page 4: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

What makes them secure?What makes them secure?

• Tamper-resistant and tamper-evident – to some degree, but never tamper-proof

no way to remove or access the “hard disk”• no way to remove or access the hard disk”

• thereforetherefore– any access to data - say the credit on your ov-chipcard -

is under control of the card’s functionality– the same goes for adding or changing code on the card

• if possible at all

Erik Poll – Digital Security 4

Page 5: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

What can they do ?What can they do ?

1. stupid card just reports some datacard shouts out a (unique) serial number on start-up

2 t id t d k d2. stupid smartcard aka memory cardprovides configurable file system with some access control

by means of PIN code/passwords or crypto keysby means of PIN code/passwords or crypto keysor even simpler: irreversible writes (OTP or WORM memory)

3 d k i d3. smart smartcard aka microprocessor cardprovides programmable CPU that can implement any functionalityfunct ona ty

Erik Poll – Digital Security 5

Page 6: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Smartcard hardware for microprocessor cardsSmartcard hardware for microprocessor cards

• CPU (usually 8 or 16, but now also 32 bit)• possibly also

– crypto co-processor & random number generator (RNG)• memory: RAM and ROM & EEPROM

– EEPROM serves as the smartcard's hard disk l k!• no power, no clock!

A modern card may have 512 bytes RAM 16K ROM 64K EEPROM and A modern card may have 512 bytes RAM, 16K ROM, 64K EEPROM and operate at 13.5 MHz

Erik Poll – Digital Security 6

Page 7: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Do-it-YourselfDo-it-Yourself

• Buy a card reader or NFC mobile phoney p• Buy some tags and cards

• Programming you own smartcards ispossible using JavaCard or MULTOS smartcardspossible using JavaCard or MULTOS smartcards

• CheckCheck• www.ru.nl/ds/smartcards • libnfc• proxmark• rfidiot.org

Erik Poll – Digital Security 7

Page 8: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Attacking smartcards and RFIDAttacking smartcards and RFID

• logical attacksg– find flaw in the functionality, targeting eg

• the crypto – ie the cryptographic algorithmsh l• the protocol

• the key management• any other functionality• any other functionality

• physical attacks– physically mess with the cardp y y

• combinations– abuse functionality while you mess with the card

Erik Poll – Digital Security 8

Page 9: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

The simplest physical attackThe simplest physical attack

External power supply and external clockExternal power supply and external clock• Vcc: orignally 5 V, now also 3V or 1.8V • Vpp: higher voltage for writing EEPROM (13 V)pp g g g

Vpp no longer used: painting over this contact is a major security threat

Erik Poll – Digital Security 9

threat

Page 10: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Logical attacks: tools of the tradeLogical attacks: tools of the trade

for passive eavesdropping or active Man-in-the-Middle

Page 11: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

L i l tt kLogical attacks:A very weak RFID tag

Erik Poll – Digital Security 11

Page 12: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Mifare UltralightMifare Ultralight

• Used in disposable ov-chipkaartp p• No keys to protect memory access• Relies on read-only and write-once memory for security• Memory organised in 16 pages of 4 bytes

– first part is read-only• includes 7 byte serial number• includes 7 byte serial number

– second part is One Time Programmable (OTP)• you can write 1's, not 0'sy ,• includes data for locking

– third part is readable & writable

12Erik Poll – Digital Security 12

Page 13: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

MIFARE Ultralight memory layoutMIFARE Ultralight memory layoutPage byte 0 byte 1 byte 2 byte 30 UID0 UID1 UID2 checksum serial numberread 0 UID0 UID1 UID212 checksum lock 0 lock1

UIDonly

OTP3 OTP 0 OTP 1 OTP 2 OTP 34

OTP

5

6application

dataread/ 6

7

8

dataread/write

8

9

1310

11Erik Poll – Digital Security 13

Page 14: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Flaw in disposable ov-chipcardFlaw in disposable ov-chipcard

• wo lock bytes initially 0x00F0y y• set to 0xF8FF to invalidate tag• we can change an invalid tag so that terminals fail to

recognize it as invalidrecognize it as invalid...• remaining 3 lock bits can still be set to one, so that lock

bytes become 0xFFFFy• flaw in terminals: tags with lock bytes 0xF8FF are

recognized as invalid, but tags with 0xFFFF are not • flaw since fixed by patching terminals• flaw since fixed by patching terminals

[Source "Security Evaluation of the disposable OV chipkaart", by UvAstudents Pieter Siekerman and Maurits van der Schee , July 2007]

14Erik Poll – Digital Security 14

Page 15: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

More fundamental limitation: replay attack

• Mifare Ultraright can store signed or encrypted data, but

More fundamental limitation: replay attack

g g ypcannot do any processing, or offer any access control to reading the data

• No way to protect against spoofing of tagsNo way to protect against spoofing of tags

• Only mitigation: serial number (UID) cannot be overwritten, so spoofing requires special hardware if UID is used

15Erik Poll – Digital Security 15

Page 16: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Logical attacks:gAttacking the crypto

Erik Poll – Digital Security 16

Page 17: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Challenge-responseChallenge-response

secretkey K CPU challenge c

response encryptK(c)p yp K( )

• If the card can do encryption, the secret key K never leaves the card

• Card issuer does not have to trust card holder, terminal, or network

• This is how you bank card works: it uses a 3DES key that only the bank knows

Erik Poll – Digital Security 17

Page 18: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Breaking this?Breaking this?

secretkey K CPU challenge c

response encryptK(c)p yp K( )

1. Figuring out which encryption function is used– maybe this is known & published

otherwise: reverse engineering experimenting to figure – otherwise: reverse engineering, experimenting to figure out how encryption works

2. For poor encryption: by trying out few challenges,you may be able to reconstruct keyyou may be able to reconstruct key

For good crypto – 3DES, AES, RSA,... – this is hopeless

Erik Poll – Digital Security 18

Page 19: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Proprietary crypto broken in DS groupProprietary crypto broken in DS group

• Mifare Classic• ATMEL SecureMemory, CryptoMemory and CryptoRF• HID iClass and iClass Elite• Hitag2

• Moral of the story: use established, crypto primitives y yp p– publicly studied according to Kerckhoffs principle

Erik Poll – Digital Security 19

Page 20: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Crypto 1 in Mifare ClassicCrypto 1 in Mifare Classic

Erik Poll – Digital Security 20

Page 21: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

L i l tt kLogical attacks:Attacking the key management

Erik Poll – Digital Security 21

Page 22: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Common problems with crypto keysCommon problems with crypto keys

• people using the same key in all cards • people using the same key in all cards • for one customer, or - worse - all their customers!• HID iClass uses a globally unique master key, which is built into g y q y,

all HID card readers• worse still, using the default keys

75% of MIFARE applications was found to use default keys or • 75% of MIFARE applications was found to use default keys or keys used in examples in documentation

[Source: Lukas Grunwald, DEFCON14, 2007]

• A0A1A2A3A4A5 is an initial transport key of MIFARE tags. Googling for A0A1A2A3A4A5 produces links to documentation with other example keys to try!

22Erik Poll – Digital Security 22

Page 23: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Logical attacks:Logical attacks:attacking security protocols

Erik Poll – Digital Security 23

Page 24: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Fraud with internet banking in NetherlandsFraud with internet banking in Netherlands

2008 2 1 M€2008 2.1 M€2009 1.9 M€2010 9.8 M€ (7100€ per incident)

2011 35 M€ (4500€ per incident)

2012 (1st half) 27.3 M€

[source: NVB]

Erik Poll – Digital Security 24

Page 25: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Internet banking &Man-in-the-Browser attacks

display of PC can not be trusted(despite )(despite )

Erik Poll – Digital Security 25

Page 26: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Internet banking & protecting against Man-in-the-Browser attacks

this display can be trusted andunderstood

USB

Erik Poll – Digital Security 26

Page 27: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Protocol of USB-connected e.dentifier2

Erik Poll – Digital Security 27

Page 28: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Protocol of USB-connected e.dentifier2

28Erik Poll – Digital Security

Page 29: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Protocol of USB-connected e.dentifier2

V l bilitVulnerability: e.dentifier2 tells PC that

user pressed OKPC instructs e dentifier2 PC instructs e.dentifier2to continue transaction

29Erik Poll – Digital Security

Page 30: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Attack

30Erik Poll – Digital Security

Page 31: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

MovieMovie

31Erik Poll – Digital Security

Page 32: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Other example logical weaknessesOth r amp og ca w a n ss s-

for e-passports f p p

Erik Poll – Digital Security 32

Page 33: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Unwanted functionalityUnwanted functionality

• Test version of Dutch passport p pprovided software emulation of Mifare Classic

• with default key, of course...

This allows adding a cloned ov-chipcard on the passport

Erik Poll – Digital Security 33

Page 34: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Attacking the terminal softwareAttacking the terminal software

Lukas Grunwald managed to crash e-passport terminals by g p p ysending a malformed JPEG causing a buffer overflow in the graphics library

Smartcards and RFID tags should be treated as untrusted inputs

/ until we have authenticated the card and/or the data it provides

Erik Poll – Digital Security 34

Page 35: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

e-passport leaking info by error responsee-passport leaking info by error response

2 byte error meaningyresponse

Belgian 6986 not allowedD t h 6982 it t t t ti fi dDutch 6982 security status not satisfiedFrench 6F00 no precise diagnosisItalian 6D00 not supportedItalian 6D00 not supportedGerman 6700 wrong length

Error code for illegal B0 ie READ BINARY instructionError code for illegal B0, ie. READ BINARY, instruction

This reveals the nationality of a passport • in spite of access control to passport data

255 other instructions to try, and we can try different parameters ...

p p p

But attack range limited to 30 cm, so danger of passport bombs overhyped

Erik Poll – Digital Security 35

Page 36: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Ph i l tt kPhysical attacks:side-channel attacks

Erik Poll – Digital Security 36

Page 37: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Power trace of an RSA encryption Power trace of an RSA encryption

[Source: Riscure]

Erik Poll – Digital Security 37

Page 38: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Power analysis: reading the key from this trace!Power analysis: reading the key from this trace!

38Erik Poll – Digital Security

Page 39: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Physical, invasive attacks

Erik Poll – Digital Security 39

Page 40: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

F h f d First step: removing chip from smartcard

Erik Poll – Digital Security 40

Page 41: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Optical reverse engineeringOptical reverse engineering

microscope images with different layers in different colours, before and after etchingg

[Source: Oliver Kömmerling, Marcus Kuhn] Erik Poll – Digital Security 41

Page 42: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

ProbingProbing

Observe or change the data on the bus while the chip is in Observe or change the data on the bus while the chip is in operation.

eg to observe keyeg to observe key

probing with8 needles

Erik Poll – Digital Security 42

Page 43: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Fibbing

FIB = Focussed Ion Beam

Fibbing

FIB = Focussed Ion Beam can observe or modify chip by• drilling holesdr ll ng holes• cutting connections• soldering new connections and

i creating new gates

blown fusehole drilled in

the chip surface blown fusep f

Erik Poll – Digital Security 43

Page 44: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Extracting ROM contentExtracting ROM content

Staining can optically revealoptically revealthe bitsstored in ROM:dark squares are 1light squares are 0

[Source: Brightsight] Erik Poll – Digital Security 44

Page 45: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

Latest fashion: fault attacksLatest fashion: fault attacks

• Introduce a fault while chip is operatingp p g– by glitching: dipping the voltage– by shooting a laser at the chip

Erik Poll – Digital Security 45

Page 46: Devnology smartcardRFID nov 2012 - Institute for Computing ...Lukas Grunwald managed to crash e-pppassport terminals by sending a malformed JPEG causing a buffer overflow in the graphics

ConclusionsConclusions

• Smartcard & RFID security not perfecty p– cheap, logical attacks

• little equipment, but some time & brainpoweri h i l k– expensive, physical atacks

• more equipment– both can be devastating– both can be devastating...

• The ongoing arms race between defenders and attackers will g gnever end– these days esp. for side-channel and fault attacks

Erik Poll – Digital Security 46