B - Attacking - Smartcards Hacking
B - Attacking - Smartcards Hacking
Erik Poll
Digital Security
Smartcard security
2
Classification of attacks
• cost
– time
– equipment
– know-how
• tamper-evidence
– ie can the card, card holder, or card issuer see a card is
being or has been messed with?
• impact for the organisation
• and business case for the attacker
3
The attacker’s business case
ie. the motivation for professional attacker!
The hobbyist is after fame or publicity,
the professional is after money!
4
Classification of attacks
An attacker can target
1. organisation: eg. issuance & usage process
5
Smartcard attacks: cost
• Logical attacks
Only 50$ of equipment, but possibly lots of brain power!
Analysis may take weeks, but final attack can be in real time
• Side channel attacks (DPA)
5K$ of equipment
Again, lots of time to prepare, but final attack can be quick
• Physical attacks
100K$
Several weeks to attack a single card
6
(1) Attacking the crypto
Attacking the crypto
Difficult for standard algorithms, eg
DES, 3DES, AES, RSA, ECC, …
Homemade, proprietary cryptographic algorithms are
routinely broken, eg
Crypto-1 used in MIFARE Classic
COMP128 and A5/1 used in GSM
Keeloq used for car keys
SecureMemory, CryptoMemory, CryptoRF
iClass, iClass Elite
HiTag2
8
movies: MIFARE and Hitag2
https://www.youtube.com/watch?v=NW3RGbQTLhE
https://www.youtube.com/watch?v=S8z9mgIkqBA
https://www.youtube.com/watch?v=dZfxdctzX6Q
Attacking the key management
You can easily check that people use proper cryptographic
`algorithms, but not that people use it properly…
Common problems: using same key in all cards, or default keys
For example
• the iClass tags use one master key that is in all readers!
• 75% of MIFARE applications was found to use default keys or
keys used in examples in documentation
• A0A1A2A3A4A5 is an initial transport key of MIFARE tags.
Googling for A0A1A2A3A4A5 produces links to
documentation with other example keys to try!
(2) Attacking the protocols
(or the software implementing them)
Attacking the protocols
Replay attack
record communication between card & terminal, and replay it
Shouldn’t work for well-designed protocol!
• Man-in-the-Middle attack
intercept and modify the communication
Shouldn’t work for well-designed protocol!
Relay attack
intercept communication and relay it to a different terminal
Eg from hacked PIN terminal in mafia-operated shop to an ATM
Very hard to prevent, if relay is done fast enough!
12
Relay attack
Using two NFC mobile phones, you can carry out a relay attack
• one phone in active mode, to read tag of the vicim
• another phone in card emulation mode, to forward the tag’s
communication to a real terminal
data
connection
NFC phone
NFC phone
in active mode
in card emulation mode
Tools for protocol analysis
14
Example protocol attack on Dutch ov0 chipcard
[Pieter Siekerman and Maurits van der Schee, Security Evaluation of the
disposable OV-chipkaart, MSc thesis, UVA, 2007]
15
Example protocol attack: ABN AMRO e.dentifier2
16
(3) side-channel attacks
Smartcard attacks
So far we discussed logical attacks (50$) to exploit flaws in
– crypto, security protocol (or the software implementing it)
Other possibilities
• Side channel attacks (5K$)
– passive: power or timing analysis
– active: fault injection (glitching or laser attacks)
18
Invasive vs non-invasive
• Logical & side-channel attacks are non-invasive
– violate tamper-resistance and tamper-evidence
– can happen in a few minutes in mafia-operated shop or a
tampered terminal
19
Side-channel analysis
20
Side-channel analysis
21
Side-channel analysis
• Side-channel = any other channel than the normal
I/O channel that may be observed
• Possible side-channels:
– power consumption
– timing
– electro-magnetic radiation
– ....
Very powerful !
22
Power consumption of a smartcard
23
This is a DES encryption!
24
Power trace detail of RSA encryption
27
Equipment for side-channel analysis in our lab
28
Other side-channel attacks: EMSEC/TEMPEST
laptop screen
at 10 meter
through
3 (thin) walls
33
Spot the weakness! Hint: card tear
class PIN{
int tryCounter = 3; // no of tries left
byte[] pin;
…
boolean check (byte[] guess) {
if (tryCounter != 0) {
if arrayCompare(pin, 0, guess, 0, 4)
{ tryCounter = 3;
return true;}
else {tryCounter--;
return false; }
else return false}
34
Spot the weakness! Hint: cardcutting
tear power
at this point will
class PIN{ leave tryCounter
int tryCounter = 3; // no of triesunchanged
left
byte[] pin;
…
boolean check (byte[] guess) {
if (tryCounter != 0) {
if arrayCompare(pin, 0, guess, 0, 4)
{ tryCounter = 3;
return true;}
else {tryCounter--;
return false; }
else return false}
35
More secure code
class PIN{
int tryCounter = 3; // no of tries left
byte[] pin;
…
boolean check (byte[] guess) {
if (tryCounter != 0) {
tryCounter--;
if arrayCompare(pin, 0, guess, 0, 4)
{ tryCounter = 3;
return true;}
else { // tryCounter--;
return false; }
else return false}
Examples
• probing
• fibbing
• reading memory contents
• …
39
First step: removing chip from smartcard
probing with
8 needles
42
Probing countermeasures
• use smaller circuitry
reducing size makes many physical attacks harder
• hide the bus
glue logic, and bus on lower layers of chip
• scramble bus lines
attacker has to optically reverse engineering this
• encrypting bus
• protective sensor mesh layer
to prevent access to chip surface
trend: accessing to chip surface from the back
43
Visual reconstruction of bus permutation
hole drilled in
the chip surface blown fuse
46
Using FIB in probing
47
Physical attack: extracting ROM content
Staining can
optically reveal
the bits in ROM:
dark squares are 1
light squares are 0
[Source: Brightsight]
48
Physical attack: extracting RAM content
49
memory extraction countermeasures
• obfuscate chip layout
• scramble or encrypt memo
• sensors
low and high temperatures, light, clock frequency, voltage, …
But… external power supply is needed to react when intrusion
is detected
Sensors can be destroyed when power is off => they must be
tested periodically in normal operation
50
Conclusions
51
Things can go wrong at many levels
• card itself, and the crypto, card configuration & protocols,,
software
• terminals & terminal software
• organisational
issuance
usage
incl. personnel, procedures, …
52
What to worry about?
Choosing secure crypto primitives & key lengths is the
easy part (3DES, AES, RSA,...)
54
Why are smartcards everywhere?
Cryptography provides a building block for security
solutions, but also introduces 2 security problems:
55
Humans are incapable of securely storing high-quality
cryptographic keys, and they have unacceptable speed and
accuracy when performing cryptographic operations.
They are also large, expensive to maintain, difficult to
manage, and they pollute the environment.
It is astonishing that these devices continue to be
manufactured and deployed. But they are sufficently
pervasive that we must design our protocols around their
limitations
56