Breaking Hitag2
Breaking Hitag2
Breaking Hitag2
Roel Verdult
Flavio D. Garcia
Josep Balasch
{rverdult,flaviog}@cs.ru.nl
josep.balasch@esat.kuleuven.be
Abstract
cording to European directive 95/56/EC. Similar regulations apply to other countries like Australia, New Zealand (AS/NZS 4601:1999) and Canada (CAN/ULC S33898). An electronic car immobilizer consists of two main
components: a small transponder chip which is embedded in (the plastic part of) the car key, see Figure 1; and
a reader which is located somewhere in the dashboard of
the vehicle and has an antenna coil around the ignition,
see Figure 2.
1 Introduction
In the past, most cars relied only on mechanical keys to
prevent a hijacker from stealing the vehicle. Since the
90s most car manufacturers incorporated an electronic
car immobilizer as an extra security mechanism in their
vehicles. From 1995 it is mandatory that all cars sold in
the EU are fitted with such an immobilizer device, ac-
Make
button on the remote key. More recent car keys are often deployed with a hybrid chip that supports the battery
powered ultra-high frequency as well as the passive low
frequency communication interface.
With the Hitag2 family of transponders, its manufacturer NXP Semiconductors (formerly Philips Semiconductors) leads the immobilizer market [34]. Figure 4 shows a list containing some of the vehicles that
are deployed with a Hitag2 transponder. Even though
NXP boosts Unbreakable security levels using mutual
authentication, challenge-response and encrypted data
communication1, it uses a shared key of only 48 bits.
Since 1988, the automotive industry has moved towards the so-called keyless ignition or keyless entry in
their high-end vehicles [26]. In such a vehicle the mechanical key is no longer present and it has been replaced
by a start button like the one shown in Figure 3. The only
anti-theft mechanism left in these vehicles is the immobilizer. Startlingly, many keyless ignition or entry vehicles
sold nowadays are still based on the Hitag2 cipher. In
some keyless entry cars Hitag2 is also used as a backup
mechanism for opening the doors, e.g., when the battery
of the remote is depleted.
Acura
Alfa Romeo
Audi
Bentley
Cadillac
Chevrolet
Chrysler
Citroen
Dodge
Fiat
GMC
Honda
Hummer
H2, H3
Hyundai
Isuzu
D-Max
Iveco
Jeep
Kia
Lancia
Mini
Mitsubishi
Nissan
Opel
A8
Continental
Buick
Dacia
Related work
BMW
Daewoo
Models
CSX, MDX, RDX, TL, TSX
Peugeot
106, 206, 207, 307, 406, 407, 607, 807, 1007, 3008, 5008
Beeper, Partner, Boxer, RCZ
Pontiac
Porsche
Cayenne
Renault
Saturn
Suzuki
Volkswagen
Touareg, Phaeton
1 http://www.nxp.com/products/automotive/
car access immobilizers/immobilizer/
Stembera
and Novotny [45] implemented a brute-force
attack that could be carried out in less than two hours by
using the COPACOBANA2 high-performance cluster of
FPGAs. Note however, that such attack would require
about 4 years if carried out on a standard PC. Finally,
Sun et. al [44] tested the security of the Hitag2 cipher
against cube attacks. Although according to their results
the key can be recovered in less than a minute, this attack
requires chosen initialization vectors and thus should be
regarded as strictly theoretical.
Our contribution
2 http://www.copacobana.org
2 Hardware setup
Before diving into details about Hitag2, this section introduces the experimental platform we have developed
in order to carry out attacks in real-life deployments of
car immobilizer systems. In particular, we have built
a portable and highly flexible setup allowing us to i)
eavesdrop communications between Hitag2 readers and
transponders, ii) emulate a Hitag2 reader, and iii) emulate a Hitag2 transponder. Figure 5 depicts our setup in
the setting of eavesdropping communications between a
reader and a transponder.
The central element of our experimental platform
is the Proxmark III board3, originally developed by
Jonathan Westhues4 , and designed to work with RFID
3 http://www.proxmark.org
4 http://cq.cx/proxmark3.pl
3 Hitag2
This section describes Hitag2 in detail. Most of this information is in the public domain. We first describe the
Hitag2 functionality, memory structure, and communication protocols, this comes mostly from the product data
sheet [36]. Then we describe the cipher and the authentication protocol which was previously reverse engineered in [47]. In Section 3.7 we show that it is possible
to run the cipher backwards which we use in our attacks.
We first need to introduce some notation. Let F2 =
{0, 1} the field of two elements (or the set of Booleans).
The symbol denotes exclusive-or (XOR) and 0n denotes a bitstring of n zero-bits. Given two bitstrings x and
y, xy denotes their concatenation. x denotes the bitwise
complement of x. We write yi to denote the i-th bit of y.
For example, given the bitstring y = 0x03, y0 = y1 = 0
and y6 = y7 = 1. We denote encryptions by {}.
Block
Contents
transponder identifier id
configuration password
47
3.3 Communication
The communication protocol between the reader and
transponder is based on the master-slave principle. The
reader sends a command to the transponder, which then
responds after a predefined period of time. There are five
different commands: authenticate, read, read, write and
halt. As shown in Figure 9, the authenticate command
has a fixed length of 5 bits, whereas the others have a
length of at least 10 bits. Optionally, these 10 bits can
be extended with a redundancy message of size multiple
of 5 bits. A redundancy message is composed by the
bit-complement of the last five bits of the command. According to the datasheet [36] this feature is introduced to
achieve a higher confidence level.
In crypto mode the transponder starts in a halted state
and is activated by the authenticate command. After a
successful authentication, the transponder enters the active state in which it only accepts active commands which
are encrypted. Every encrypted bit that is transferred
consists of a plaintext bit XOR-ed with one bit of the
keystream. The active commands have a 3-bit argument
n which represents the offset (block number) in memory.
From this point we address Hitag2 active commands by
referring to commands and explicitly mention authentication otherwise.
3.1 Functionality
Access to the Hitag2 memory contents is determined by
pre-configured security policies. Hitag2 transponders offer up to three different modes of operation:
1. In public mode the contents of the user data pages
are simply broadcast by the transponder once it is
powered up.
2. In password mode reader and transponder authenticate each other by interchanging their passwords.
Communication is carried out in the clear, therefore
this authentication procedure is vulnerable to replay
attacks.
3. In crypto mode the reader and the transponder perform a mutual authentication by means of a 48-bit
shared key. Communication between reader and
transponder is encrypted using a proprietary stream
cipher. This mode is used in car immobilizer systems and will be the focus of this paper.
Command
Bits
State
authenticate
11000
halted
read
11n0 n1 n2 00n0 n1 n2 . . .
active
read
01n0 n1 n2 10n0 n1 n2 . . .
active
3.2 Memory
write
10n0 n1 n2 01n0 n1 n2 . . .
active
Hitag2 transponders have a total of 256 bits of nonvolatile memory (EEPROM) organized in 8 blocks of
4 bytes each. Figure 8 illustrates the memory contents
of a transponder configured in crypto mode. Block 0
stores the read-only transponder identifier; the secret key
is stored in blocks 1 and 2; the password and configuration bits in block 3; blocks 4 till 7 store user defined
memory. Access to any of the memory blocks in crypto
mode is only granted to a reader after a successful mutual
authentication.
halt
00n0 n1 n2 11n0 n1 n2 . . .
active
For example, the command to read block 0 with two redundancy messages results in the following bit string.
cmd(11, 0, 2) = 11000 00111 11000 00111
The encrypted messages between reader and transponder
are transmitted without any parity bits. The transponder
response always starts with a prefix of five ones, see Figure 10. In the remainder of this paper we will omit this
prefix. A typical forward and backwards communication
takes about 12 ms.
fc (i) = (0xD949CBB0)i .
{11000001111100000111}
11111{id0 . . . id31 }
3.4 Cipher
In crypto mode, the communication between transponder
and reader (after a sucessful authentication) is encrypted
with the Hitag2 stream cipher. This cipher has been reverse engineered in [47]. The cipher consists of a 48-bit
linear feedback shift register (LFSR) and a non-linear filter function f . Each clock tick, twenty bits of the LFSR
are put through the filter function, generating one bit of
keystream. Then the LFSR shifts one bit to the left, using the generating polynomial to generate a new bit on
the right. See Figure 11 for a schematic representation.
authenticate
id
{nR}{aR }
{aT }
o
0
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
f a = 0xA63C
f b = 0xA770
f b = 0xA770
f b = 0xA770
f a = 0xA63C
f c = 0xD949CBB0
keystream
F32
.
.
.
a
F32
,
and
a
transponder
answer
a
=
a
T31
T
T0
2 ,
2
the internal state of the cipher at time i is i :=
ai . . . a47+i F48
2 . Here the ai F2 are given by
ai := idi
i [0, 31]
a32+i := ki
i [0, 15]
i [0, 31]
a48+i := k16+i nRi
a80+i := L(a32+i . . . a79+i )
i N .
Furthermore, we define the keystream bit bi F2 at time
i by
bi := f (ai . . . a47+i )
i N .
Define {nR }, {aR }i , {aT }i F2 by
i [0, 31]
{nR}i := nRi bi
i [0, 31]
{aR}i := aRi b32+i
i [0, 31] .
4 Hitag2 weaknesses
i [0, 31].
{aT }i := aTi b64+i
Note that the ai , i , bi , {nR }i , {aR}i , and {aT }i are formally functions of k, id, and nR . Instead of making this explicit by writing, e.g., ai (k, id, nR ), we just write ai where
k, id, and nR are clear from the context.
3.7 Rollback
to communicate without a send/receive buffer. Therefore, all cipher operations are performed directly at arrival or transmission of bits. Experiments show that a
Hitag2 transponder successfully accepts encrypted commands from the reader which are sent with 1000 redundancy messages. The size of such a command consists of
10 + 5 1000 = 5010 bits.
Since there is no challenge from the transponder it
is possible to replay any valid {nR}{aR } pair to the
transponder to achieve a successful authentication. After
receiving aT , the internal state of the transponder is initialized and waits for an encrypted command from the
reader as defined in Figure 9. Without knowledge of the
keystream bits b96 b97 . . . and onwards, all possible combinations need to be evaluated. A command consist of
at least 10 bits, therefore there are 210 possibilities. Each
command requires a 3-bit parameter containing the block
number. Both read and read receive a 32-bit response,
while the write and halt have a different response length.
Hence, when searching for 10-bit encrypted commands
that get a 32-bit response there are exactly 16 out of the
210 values that match. On average the first read command is found after 32 attempts, the complement of this
read and its parameters are a linear difference and therefore take only 15 attempts more.
id b136 . . . b167
id b106 . . . b137
P[Y,Y F14
2 : f (XY ) = f (XY )] = 1/4.
Proof. By inspection.
Definition 4.2. The function that checks for this property
P : F48
2 F2 is defined by
P(x0 . . . x47 ) = (0x84D7)i
where
i = fa (x2 x3 x5 x6 ) fb (x8 x12 x14 x15 )
fb (x17 x21 x23 x26 ) fb (x28 x29 x31 x33 ).
Because P(x0 . . . x47 ) only depends on x0 . . . x33 we shall
overload notation and see P() as a function F34
2 F2 ,
writing P(x0 . . . x47 ) as P(x0 . . . x33 014 ).
8
5 Attacks
Proposition 5.1. Let s be an LFSR state and n N. Furthermore, let di = sucn (2i ) i.e., the LFSR state that results from running the cipher n steps from the state 2i .
Then
sucn (s) =
47
M
(di si ) .
i=0
~ 14
for all y F18
2 such that P(ky 0 ) = 1. Note that the
expected size of this table is 218 1/4 = 216 which
easily fits in memory.
Attack
Description
Practical
Computation
Traces
[45]
brute-force
yes
4 years
Time
[14]
sat-solver
yes
2 880 min
2 days
[42]
sat-solver
no1
386 min
N/A
[44]
cube
no2
1 min
500
N/A
Our
cryptanalytic
yes
5 min
136
6 min
N/A
1 Soos
2 Sun
10
6 Starting a car
7 Implementation weaknesses
To verify the practicality of our attacks, we have tested
all three of them on at least 20 different car models
from various makes. During our experiments we found
that, besides the weaknesses in cipher and protocol, the
transponder is often misconfigured and poorly integrated
in the cars. Most of the cars we tested use a default
Message
Description
CAR
TAG
CAR
TAG
18
39 0F 20 10
0A 00 00 00 23 71 90 14
27 23 F8 AF
authenticate
id
{nR }{aR }
{aT }
CAR
TAG
CAR
TAG
18
39 0F 20 10
56 00 00 00 85 CA 95 BA
38 07 50 C5
authenticate
id
{nR }{aR }
{aT }
of a transponder that is wirelessly accessible over a distance of several meters and a non protected readable key
is most worrying.
{aR }
20
70
B0
D0
D1
61
A1
41
0B
1B
5B
FB
08
58
98
B8
56
1B
1E
01
36
18
94
3B
F3
F3
62
54
66
38
3A
10
25
05
C5
E5
1A
7A
3A
DA
3C
9C
5C
FC
AD
8D
4D
6D
15
F7
30
D8
88
4D
B1
BD
5E
F7
4A
79
19
70
D4
C3
Message
Description
CAR
TAG
CAR
18
E4 13 05 1A
4D 49 4B 52
authenticate
id
password = MIKR
CAR
TAG
CAR
TAG
18
E4 13 05 1A
DA 63 3D 24 A7 19 07 12
EC 2A 4B 58
authenticate
id
{nR }{aR }
{aT }
Figure 19: Car C authenticates using the default password and secret key 0xFFFF814632FF
One option is to use the low-frequency (LF) interface to wirelessly pickpocket the identifier from the
victims key. This can be done within proximity
distance and takes only a few milliseconds. According to the Hitag2 datasheet [36], the communication
range of a transponder is up to one meter. Although,
Hitag2 transponders embedded into car keys are optimized for size and do not achieve such a communication distance. However, an adversary can use
tuned equipment with big antennas that ignore radiation regulations (e.g., [17]) in order to reach a
larger reading distance. Many examples in the literature show the simplicity and low-cost of such a
setup [24, 30, 31, 43].
8 Mitigation
This section briefly discusses a simple but effective authentication protocol for car immobilizers and it also describes a number of mitigating measures for the attacks
proposed in Section 5. For more details we refer the
reader to [1, 9].
First of all we emphasize that it is important for the
automotive industry to migrate from weak proprietary
ciphers to a peer-reviewed one such as AES [15], used
in cipher block chaining mode (CBC). A straightforward mutual authentication protocol is sketched in Figure 20. The random nonces nR , nT , secret key k and
transponder password PWDT should be at least 128 bits
long. Comparable schemes are proposed in the literature [32, 33, 46, 48, 49].
authenticate
id, nT
{nR , nT }k
{nR, PWDT }k
9 Conclusions
There are already in the market immobilizer transponders which implement AES like the ATA5795[2] from
Atmel and the Hitag AES / Pro[37] from NXP. It should
be noted that, although they use a peer-reviewed encryption algorithm, their authentication protocol is still proprietary and therefore lacks public and academic scrutiny.
In order to reduce the applicability of our cryptographic attack, the automotive industry could consider
the following measures. This attack is the most sensitive
as it does not require access to the car key. These countermeasures should be interpreted as palliating (but not a
solution) before migrating to a more secure and openly
designed product.
10 Acknowledgments
The authors would like to thank Bart Jacobs for his
firm support in the background. We are also thankful
to E. Barendsen, L. van den Broek, J. de Bue, Y. van
Dalen, E. Gouwens, R. Habraken, I. Haerkens, S. Hoppenbrouwers, K. Koster, S. Meeuwsen, J. Reule, J. Reule, I. Roggema, L. Spix, C. Terheggen, M. Vaal, S. Vernooij, U. Zeitler, B. Zwanenburg, and those who prefer to
remain anonymous for (bravely) volunteering their cars
for our experiments.
[8] Andrey Bogdanov. Linear slide attacks on the KeeLoq block cipher. In Information Security and
Cryptology (INSCRYPT 2007), volume 4990 of
Lecture Notes in Computer Science, pages 6680.
Springer, 2007.
[9] Andrey Bogdanov and Christof Paar. On the security and efficiency of real-world lightweight authentication protocols. In 1st Workshop on Secure Component and System Identification (SECSI
2008). ECRYPT, 2008.
References
[1] Ross J. Anderson. Security Engineering: A guide
to building dependable distributed systems. Wiley,
2010.
[10] Stephen C. Bono, Matthew Green, Adam Stubblefield, Ari Juels, Aviel D. Rubin, and Michael
Szydlo. Security analysis of a cryptographicallyenabled RFID device. In 14th USENIX Security
Symposium (USENIX Security 2005), pages 116.
USENIX Association, 2005.
[3] Steve Babbage. A space/time tradeoff in exhaustive search attacks on stream ciphers. In European
Convention on Security and Detection, volume 408
of Conference Publications, pages 161166. IEEE
Computer Society, 1995.
[23] Flavio D. Garcia, Peter van Rossum, Roel Verdult, and Ronny Wichers Schreur. Dismantling SecureMemory, CryptoMemory and CryptoRF. In
17th ACM Conference on Computer and Communications Security (CCS 2010), pages 250259.
ACM/SIGSAC, 2010.
[27] Sebastiaan Indesteege, Nathan Keller, Orr Dunkelmann, Eli Biham, and Bart Preneel. A practical attack on KeeLoq. In 27th International
Conference on the Theory and Application of
Cryptographic Techniques, Advances in Cryptology (EUROCRYPT 2008), volume 4965 of Lecture
Notes in Computer Science, pages 18. SpringerVerlag, 2008.
Capkun.
Relay attacks on passive keyless entry
and start systems in modern cars. In 18th Network
and Distributed System Security Symposium (NDSS
2011). The Internet Society, 2011.
[19] Flavio D. Garcia, Gerhard de Koning Gans, Ruben
Muijrers, Peter van Rossum, Roel Verdult, Ronny
Wichers Schreur, and Bart Jacobs. Dismantling MIFARE Classic. In 13th European Symposium on
Research in Computer Security (ESORICS 2008),
volume 5283 of Lecture Notes in Computer Science, pages 97114. Springer-Verlag, 2008.
[32] Kerstin Lemke, Ahmad-Reza Sadeghi, and Christian Stble. An open approach for designing secure electronic immobilizers. In Information Security Practice and Experience (ISPEC 2005), volume
3439 of Lecture Notes in Computer Science, pages
230242. Springer-Verlag, 2005.
[42] Mate Soos, Karsten Nohl, and Claude Castelluccia. Extending SAT solvers to cryptographic problems. In 12th International Conference on Theory and Applications of Satisfiability Testing (SAT
2009), volume 5584 of Lecture Notes in Computer
Science, pages 244257. Springer-Verlag, 2009.
[33] Kerstin Lemke, Ahmad-Reza Sadeghi, and Christian Stuble. Anti-theft protection: Electronic immobilizers. Embedded Security in Cars, pages 51
67, 2006.
[43] Frank Stajano and Ross J. Anderson. The resurrecting duckling: Security issues for ad-hoc wireless
networks. In 7th International Workshop on Security Protocols (WSP 2000), volume 1796 of Lecture Notes in Computer Science, pages 172182.
Springer-Verlag, 2000.
[34] Karsten Nohl. Immobilizer security. In 8th International Conference on Embedded Security in Cars
(ESCAR 2010), 2010.
[38] Philippe Oechslin. Making a faster cryptanalytic time-memory trade-off. In 23rd International
Cryptology Conference, Advances in Cryptology
(CRYPTO 2003), volume 2729 of Lecture Notes
in Computer Science, pages 617630. SpringerVerlag, 2003.
[47] I.C.
Wiener.
Philips/NXP
Hitag2
PCF7936/46/47/52 stream cipher reference
implementation. http://cryptolib.com/ciphers/hitag2/,
2007.
[40] Amir Rahmati, Mastooreh Salajegheh, Dan Holcomb, Jacob Sorber, Wayne P. Burleson, and Kevin
Fu. TARDIS: Time and remanence decay in
SRAM to implement secure protocols on embedded devices without clocks. In 21st USENIX Security Symposium (USENIX Security 2012). USENIX
Association, 2012.