Gone in 360 Seconds Hijacking With Hitag2-USENIX 2012
Gone in 360 Seconds Hijacking With Hitag2-USENIX 2012
Gone in 360 Seconds Hijacking With Hitag2-USENIX 2012
11111{id
0
. . . id
31
}
x
16
x
22
x
23
x
26
x
30
x
41
x
42
x
43
x
46
x
47
.
The lter function f consists of three different circuits
f
a
, f
b
and f
c
which output one bit each. The circuits f
a
and f
b
are employed more than once, using a total of
twenty input bits from the LFSR. Their resulting bits are
used as input for f
c
. The circuits are represented by three
boolean tables that contain the resulting bit for each in-
put.
Denition 3.3 (Filter function). The lter function
f : F
48
2
F
2
is dened by
f (x
0
. . . x
47
) = f
c
( f
a
(x
2
x
3
x
5
x
6
), f
b
(x
8
x
12
x
14
x
15
),
f
b
(x
17
x
21
x
23
x
26
), f
b
(x
28
x
29
x
31
x
33
),
f
a
(x
34
x
43
x
44
x
46
)),
where f
a
, f
b
: F
4
2
F
2
and f
c
: F
5
2
F
2
are
f
a
(i) = (0xA63C)
i
f
b
(i) = (0xA770)
i
f
c
(i) = (0xD949CBB0)
i
.
For future reference, note that each of the building blocks
of f (and hence f itself) has the property that it outputs
zero for half of the possible inputs (respectively one).
Remark 3.4 (Cipher schematic). Figure 11 is different
from the schematic that was introduced by [47] and later
used by [14, 19, 44, 45]. The input bits of the lter func-
tion in Figure 11 are shifted by one with respect to those
of [47]. The lter function in the old schematic repres-
ents a keystreambit at the previous state f (x
i1
. . . x
i+46
),
while the one in Figure 11 represents a keystream bit of
the current state f (x
i
. . . x
i+47
). Furthermore, we have
adapted the boolean tables to be consistent with our
notation.
3.5 Authentication protocol
The authentication protocol used in Hitag2 in crypto
mode, reversed engineered and published online in
2007 [47], is depicted in Figure 12. The reader starts the
communication by sending an authenticate command,
to which the transponder answers by sending its identi-
er id. From this point on, communication is encryp-
ted, i.e., XOR-ed with the keystream. The reader re-
sponds with its encrypted challenge n
R
and the answer
a
R
= 0xFFFFFFFF also encrypted to prove knowledge
of the key; the transponder nishes with its encrypted
answer a
T
(corresponding to block 3 in Fig. 8) to the
challenge of the reader.
authenticate
id
{n
R
}{a
R
}
{a
T
}
oo
fa =0xA63C f
b
=0xA770 f
b
=0xA770 f
b
= 0xA770 fa = 0xA63C
fc =0xD949CBB0
keystream
x
22
x
23
x
26
x
30
x
41
x
42
x
43
x
46
x
47
x
48
.
If one rst shifts the LFSR left using L to generate a
new bit on the right, then R recovers the bit that dropped
out on the left, i.e.,
R(x
1
. . . x
47
L(x
0
. . . x
47
)) = x
0
. (1)
Theorem 3.7. In the situation from Denition 3.5, we
have
a
32+i
= R(a
33+i
. . . a
80+i
) i N
a
i
= id
i
i [0, 31] .
Proof. Straightforward, using Denition 3.5 and Equa-
tion (1).
If an attacker manages to recover the internal state of
the LFSR
i
= a
i
a
i+1
. . . a
i+47
at some time i, then she
can repeatedly apply Theorem 3.7 to recover a
0
a
1
. . . a
79
and, consequently, the keystream b
0
b
1
b
2
. . .. By having
eavesdropped {n
R
} from the authentication protocol, the
adversary can further calculate
n
R
i
= {n
R
}
i
b
i
i [0, 31] .
Finally, the adversary can compute the secret key as fol-
lows
k
i
= a
32+i
i [0, 15]
k
16+i
= a
48+i
n
R
i
i [0, 31] .
4 Hitag2 weaknesses
This section describes three weaknesses in the design of
Hitag2. The rst one is a protocol aw while the last two
concern the ciphers design. These weaknesses will later
be exploited in Section 5.
4.1 Arbitrary length keystream oracle
This weakness describes that without knowledge of the
secret key, but by having only one authentication at-
tempt, it is possible to gather an arbitrary length of key-
stream bits from the transponder. Section 3.3 describes
the reader commands that can modify or halt a Hitag2
transponder. As mentioned in Denition 3.1 it is pos-
sible to extend the length of such a command with a
multiple of ve bits. A 10-bit command can have an op-
tional number of redundancy messages r so that the total
bit count of the message is 10 +5r bits. Due to power
and memory constraints, Hitag2 seems to be designed
7
to communicate without a send/receive buffer. There-
fore, all cipher operations are performed directly at ar-
rival or transmission of bits. Experiments show that a
Hitag2 transponder successfully accepts encrypted com-
mands from the reader which are sent with 1000 redund-
ancy 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 {n
R
}{a
R
} pair to the
transponder to achieve a successful authentication. After
receiving a
T
, the internal state of the transponder is ini-
tialized and waits for an encrypted command from the
reader as dened in Figure 9. Without knowledge of the
keystream bits b
96
b
97
. . . and onwards, all possible com-
binations need to be evaluated. A command consist of
at least 10 bits, therefore there are 2
10
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
2
10
values that match. On average the rst read com-
mand is found after 32 attempts, the complement of this
read and its parameters are a linear difference and there-
fore take only 15 attempts more.
cmd(11, 0, 0) b
96
. . . b
105
id b
106
. . . b
137
id b
136
. . . b
167
F
14
2
: f (XY) = f (XY
)] = 1/4.
Proof. By inspection.
Denition 4.2. The function that checks for this property
P: F
48
2
F
2
is dened by
P(x
0
. . . x
47
) = (0x84D7)
i
where
i = f
a
(x
2
x
3
x
5
x
6
) f
b
(x
8
x
12
x
14
x
15
)
f
b
(x
17
x
21
x
23
x
26
) f
b
(x
28
x
29
x
31
x
33
).
Because P(x
0
. . . x
47
) only depends on x
0
. . . x
33
we shall
overload notation and see P() as a function F
34
2
F
2
,
writing P(x
0
. . . x
47
) as P(x
0
. . . x
33
0
14
).
8
5 Attacks
This section describes three attacks against Hitag2. The
rst attack is straightforward and grants an adversary
read and write access to the memory of the transponder.
The cryptanalysis described in the second attack recovers
the secret key after briey communicating with the car
and the transponder. This attack uses a general technique
that can be applied to other LFSR-like stream ciphers.
The third attack describes a custom cryptanalysis of the
Hitag2 cipher. It only requires a few authentication at-
tempts from the car and allows an adversary to recover
the secret key with a computational complexity of 2
35
op-
erations. The last two attacks allow a trade-off between
time/memory/data and time/traces respectively. For the
sake of simplicity we describe these attacks with con-
crete values that are either optimal or what we consider
sensible in view of currently available hardware.
5.1 Malleability attack
This attack exploits the arbitrary length keystream or-
acle weakness described in Section 4.1, and the fact that
during the authentication algorithm the transponder does
not provide any challenge to the reader. This notorious
weaknesses allow an adversary to rst acquire keystream
and then use it to read or write any block on the card with
constant communication and computational complexity.
After the recovery of the keystream bits b
96
. . . b
137
as
shown in Figure 13 an adversary can dump the complete
memory of the transponder which includes its password.
Recovery of the keystream and creating a memory dump
from the transponder takes in total less than one second
and requires only to be in proximity distance of the vic-
tim. This shows a similar scenario to [22] where Garcia
et al. show how to wirelessly pickpocket a MIFARE
Classic card from the victim.
The memory blocks where the cryptographic key is
stored have an extra optional protection mechanism.
There is a one time programable conguration bit which
determines whether these blocks are readable or not.
If the reader tries to read a protected block, then the
transponder does not respond. In that case the adversary
can still use the attacks presented in Section 5.2 and Sec-
tion 5.3. If the transponder is not correctly congured,
it enables an adversary to read all necessary data to start
the car.
5.2 Time/memory tradeoff attack
This attack is very general and it can be applied to any
LFSR-based stream cipher as long as enough contigu-
ous keystream is available. This is in fact the case with
Hitag2 due to the weakness described in Section 4.1. It
extends the methods of similar time/memory tradeoffs
articles published over the last decades [3, 6, 7, 11, 25,
38]. This attack requires communication with the reader
and the transponder. The next proposition introduces a
small trick that makes it possible to quickly perform n
cipher steps at once. Intuitively, this proposition states
that the linear difference between a state s and its n-th
successor is a combination of the linear differences gen-
erated by each bit. This will be later used in the attack.
Proposition 5.1. Let s be an LFSR state and n N. Fur-
thermore, let d
i
= suc
n
(2
i
) i.e., the LFSR state that res-
ults from running the cipher n steps from the state 2
i
.
Then
suc
n
(s) =
47
i=0
(d
i
s
i
).
To perform the attack the adversary A proceeds as fol-
lows:
1. Only once, A builds a table containing 2
37
entries.
Each entry in the table is of the form ks, s where
s F
48
2
is an LFSR state and ks F
48
2
are 48 bits
of keystream produced by the cipher when running
from s. Starting from some state where s = 0,
the adversary generates 48 bits of keystream and
stores it. Then it uses Theorem 5.1 to quickly
jump n = 2
11
cipher states to the next entry in the
table. This reduces the computational complexity
of building the table from 2
48
to 48 2
37
= 2
42.5
cipher ticks. Moreover, in order to improve lookup
time the table is sorted on ks and divided into
2
24
sub-tables encoded in the directory structure
like /ks_byte1/ks_byte2/ks_byte3.bin
where each ks_byte3.bin le has only 8 KB.
The total size of this table amounts 1.2 TB.
2. A emulates a transponder and runs an authentication
attempt with the target car. Following the authen-
tication protocol, the car answers with a message
{n
R
}{a
R
}.
3. Next, the attacker wirelessly replays this message
to the legitimate transponder and uses the weakness
described in Section 4.1 to obtain 256 bytes of key-
stream ks
0
. . . ks
2048
. Note that this might be done
while the key is in the victims bag or pocket.
4. The adversary sets i = 0.
5. Then it looks up (in logarithmic time) the keystream
ks
i
. . . ks
i+47
in the table from step 1.
6. If the keystreamis not in the table then it increments
i and goes back to step 5. If there is a match, then
the corresponding state is a candidate internal state.
A uses the rest of the keystream to conrm is this is
the internal state of the cipher.
9
7. Finally, the adversary uses Theorem 3.7 to rollback
the cipher state and recover the secret key.
Complexity and time. In step 1 the adversary needs to
pre-compute a 1.2 TB table which requires 2
42.5
cipher
ticks, which is equal to 2
37
encryptions. During gener-
ation, each entry is stored directly in the corresponding
.bin le as mentioned before. Each of these 8 KB les
also needs to be sorted but it only takes a few minutes
to sort them all. Computing and sorting the whole table
takes less than one day on a standard laptop. Steps 2-3
take about 30 seconds to gather the 256 bytes of key-
stream from the transponder. Steps 4-6 require (in worst
case) 2000 table lookups which take less than 30 seconds
on a standard laptop. This adds to a total of one minute
to execute the attack from begin to end.
5.3 Cryptanalytic attack
A combination of the weaknesses described in Section
4.2 and 4.3 enable an attacker to recover the secret key
after gathering a few authentication attempts from a car.
In case that identier white-listing is used as a second-
ary security measure, which is in fact the case for all the
cars we tested, the adversary rst needs to obtain a valid
transponder id, see Section 7.5.
The intuition behind the attack is simple. Suppose that
an adversary has a guess for the rst 34 bits of the key.
One out of four traces is expected to have the property
from Theorem 4.1 which enables the adversary to per-
form a test on the rst bit of {a
R
}. The dependencies
between sessions described in Section 4.2 allow the at-
tacker to performthis test many times decreasing drastic-
ally the amount of candidate (partial) keys. If an attacker
gathers 136 traces this allows her (on average) to perform
136/4 = 34 bit tests, i.e. just as much as key bits were
guessed. For the small amount of candidate keys that
pass these tests (typically 2 or 3), the adversary performs
an exhaustive search for the remaining 14 bits of the key.
A precise description of this attack follows.
1. The attacker uses a transponder emulator (like the
Proxmark III) to initiate 136 authentication attempts
with the car using a xed transponder id. In this
way the attacker gathers 136 traces of the form
{n
R
}{a
R
}. Next the attacker starts searching for
the secret key. For this we split the key k in three
parts k =
k
k where
k =k
0
. . . k
15
,
k =k
16
. . . k
33
, and
k = k
34
. . . k
47
.
2. for each
k = k
0
. . . k
15
F
16
2
the attacker builds a
table T
k
containing entries
y b
0
. . . b
17
, b
32
,
ky
for all y F
18
2
such that P(
ky0
14
) =1. Note that the
expected size of this table is 2
18
1/4 = 2
16
which
easily ts in memory.
3. For each
k = k
16
. . . k
33
F
18
2
and for each
trace {n
R
}{a
R
}, the attacker sets z :=
k
{n
R
}
0
. . . {n
R
}
17
. If there is an entry in T
k
for which
y b
0
. . . b
17
equals z but b
32
= {a
R
}
0
then the at-
tacker learns that
k is a bad guess, so he tries the
next one. Otherwise, if b
32
= {a
R
}
0
then
k is still
a viable guess and therefore the adversary tries the
next trace.
4. Each
k
k = k
34
. . . k
47
. For each
full candidate key, the adversary decrypts two traces
and checks whether both {a
R
} decrypt to all ones as
specied in the authentication protocol. If a candid-
ate passes this test then it is the secret key. If none
of them passes then the adversary goes back to Step
2 and tries the next
k.
Complexity and time. In step 1, the adversary needs to
gather 136 partial authentication traces. This can be done
within 1 minute using the Proxmark III. In steps 2 and 3,
the adversary needs to build 2
16
tables. For each of these
tables the adversary needs to compute 2
18
encryptions
plus 2
18
table lookups. Step 4 has negligible complex-
ity thus we ignore it. This adds to a total complexity of
2
16
(2
18
+2
18
) = 2
35
encryptions/lookups. Note that
it is straightforward to split up the search space of
k in
as many processes as you wish. On an standard quad-
core laptop this computation takes less than ve minutes.
Therefore, the whole attack can be performed in less than
360 seconds which explains the title of the paper.
This attack is faster than other practical attacks pro-
posed in [14, 45]. The following table shows a com-
parison between this attack and other attacks from the
literature.
Attack Description Practical Computation Traces Time
[45] brute-force yes 2102400 min 2 4 years
[14] sat-solver yes 2880 min 4 2 days
[42] sat-solver no
1
386 min N/A N/A
[44] cube no
2
1 min 500 N/A
Our cryptanalytic yes 5 min 136 6 min
1
Soos et al. require 50 bits of contiguous keystream.
2
Sun et al. require control over the encrypted reader nonce {n
R
}
Figure 15: Comparison of attack times and requirements
10
Figure 16: Left: Authentication failure message
Right: Successful authentication using a Proxmark III
6 Starting a car
In order to elaborate on the practicality of our attacks,
this section describes our experience with one concrete
vehicle. For this we have chosen a German car, mainly
due to the fact that it has keyless ignition. Instead of
the typical mechanical key, this car has a hybrid re-
mote control which contains a Hitag2 transponder. In
the dashboard of the car there is a slot to insert the re-
mote and a button to start the engine. When a piece
of plastic of suitable size is inserted in this slot the car
repeatedly attempts to authenticate the transponder (and
fails). This car uses an identier white-list as described
in Section 7.5. The same section explains how to wire-
lessly pickpocket a valid identier from the victims re-
mote. As soon as the car receives a valid identier, the
dashboard lights up and the LCDscreen pops-up display-
ing the message shown in Figure 16-Left. Note also the
sign on the dashboard. At this point we used the Prox-
mark to quickly gather enough traces and execute the at-
tack from Section 5.3 to recover the secret key. This car
is one of the few that we tested that does not have a pre-
dictable password so we wirelessly read it from the vic-
tims remote. Then we use the Proxmark to emulate the
transponder. Figure 16-Right shows that the car accepts
the Proxmark as if it was the legitimate transponder. The
same picture shows (by looking at the tachometer) that at
this stage it is possible to start the engine.
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 miscongured and poorly integrated
in the cars. Most of the cars we tested use a default
or predictable transponder password. Some generate
nonces with a very low entropy. Most car keys have
vehicle-dependant information stored in the user dened
memory of the transponder, but none of the tested cars
actually check this data. Some cars use Hitag2 for key-
less ignition systems, which are more vulnerable because
they lack a physical key. This section summarizes some
of the weaknesses we found during our practical experi-
ments. Especially, Section 7.4 shows the implications of
the attack described in Section 5.3 when the transponder
uses a predictable password. Section 7.5 describes how
to circumvent identier white-listing. This is an addi-
tional security mechanism which is often used in vehicle
immobilizers.
7.1 Weak random number generators
From the cars we tested, most pseudo-random number
generators (PRNG) use the time as a seed. The time in-
tervals do not have enough precision. Multiple authen-
tication attempts within a time frame of one second get
the same random number. Even worse, we came across
two cars which have a PRNG with dangerously low en-
tropy. The rst one, a French car (A), produces nonces
with only 8 bits of entropy, by setting 24 of the 32 bits
always to zero as shown in Figure 17.
Origin Message Description
CAR 18 authenticate
TAG 39 0F 20 10 id
CAR 0A 00 00 00 23 71 90 14 {n
R
}{a
R
}
TAG 27 23 F8 AF {a
T
}
CAR 18 authenticate
TAG 39 0F 20 10 id
CAR 56 00 00 00 85 CA 95 BA {n
R
}{a
R
}
TAG 38 07 50 C5 {a
T
}
Figure 17: Random numbers generated by car A
11
Another French car (B), produced random looking
nonces, but in fact, the last nibble of each byte was de-
termined by the last nibble of the rst byte. A subset of
these nonces are shown shown in Figure 18.
{n
R
} {a
R
}
20 D1 0B 08 56 36 F3 66
70 61 1B 58 1B 18 F3 38
B0 A1 5B 98 1E 94 62 3A
D0 41 FB B8 01 3B 54 10
25 1A 3C AD 15 88 5E 19
05 7A 9C 8D F7 4D F7 70
C5 3A 5C 4D 30 B1 4A D4
E5 DA FC 6D D8 BD 79 C3
Figure 18: Random numbers generated by car B
7.2 Low entropy keys
Some cars have repetitive patterns in their keys which
makes them vulnerable to dictionary attacks. Recent
models of a Korean car (C) use the key with the lowest
entropy we came across. It tries to access the transpon-
der in password mode as well as in crypto mode. For this
it uses the default password MIKR and a key of the form
0xFFFF FFas shown in Figure 19.
Origin Message Description
CAR 18 authenticate
TAG E4 13 05 1A id
CAR 4D 49 4B 52 password = MIKR
CAR 18 authenticate
TAG E4 13 05 1A id
CAR DA 63 3D 24 A7 19 07 12 {n
R
}{a
R
}
TAG EC 2A 4B 58 {a
T
}
Figure 19: Car C authenticates using the default pass-
word and secret key 0xFFFF814632FF
7.3 Readable keys
Section 5.1 shows how to recover the memory dump
of a Hitag2 transponder. Almost all makes protect the
secret key against read operations by setting the bits of
the conguration in such a way that block one and two
are not readable. Although there are some exceptions.
For example, experiments show that most cars from a
French manufacturer have not set this protection bit. This
enables an attacker to recover the secret key in an in-
stant. Even more worrying, many of these cars have
the optional feature to use a remote key-less entry sys-
tem which have a much wider range and are therefore
more vulnerable to wireless attacks. The combination
of a transponder that is wirelessly accessible over a dis-
tance of several meters and a non protected readable key
is most worrying.
7.4 Predictable transponder passwords
The transponder password is encrypted and sent in the
transponder answer a
T
of the authentication protocol.
This is an additional security mechanism of the Hitag2
protocol apart from the cryptographic algorithm. Be-
sides the fact that the transponder proves knowledge of
the secret key, it sends its password encrypted. In general
it is good to have some fall back scenario and counter-
measure if the used cryptosystem gets broken. Section
5.3 demonstrates how to recover the secret key from a
vehicle. But to start the engine, it is necessary to know
the transponder password as well. Experiments show
that at least half of the cars we tested on use default or
predictable passwords.
7.5 Identier pickpocketing
The rst generation of vehicle immobilizers were
not able to compute any cryptographic operations.
These transponders were simply transmitting a constant
(unique) identier over the RF channel. Legitimate
transponder identiers were white-listed by the vehicle
and only those transponders in the white-list would en-
able the engine to start. Most immobilizer units in cars
still use such white-listing mechanism, which is actually
encouraged by NXP. These cars would only attempt to
authenticate transponders in their white-list. This is an
extra obstacle for an attacker, namely recovering a genu-
ine identier fromthe victimbefore being able to execute
any attack. There are (at least) two ways for an adversary
to wirelessly pickpocket a Hitag2 identier:
One option is to use the low-frequency (LF) inter-
face to wirelessly pickpocket the identier from the
victims key. This can be done within proximity
distance and takes only a few milliseconds. Accord-
ing to the Hitag2 datasheet [36], the communication
range of a transponder is up to one meter. Although,
Hitag2 transponders embedded into car keys are op-
timized for size and do not achieve such a commu-
nication distance. However, an adversary can use
tuned equipment with big antennas that ignore ra-
diation regulations (e.g., [17]) in order to reach a
larger reading distance. Many examples in the lit-
erature show the simplicity and low-cost of such a
setup [24, 30, 31, 43].
Another option is to use the wide range ultra-high
frequency (UHF) interface. For this an adversary
needs to eavesdrop the transmission of a hybrid
12
Hitag2 transponder [39] when the victim presses a
button on the remote (e.g. to close the doors). Most
keyless entry transponders broadcast their identier
in the clear on request (see for example [39]).
With respect to the LF interface, the UHF interface has
a much wider transmission range. As shown in [18] it
is not hard to eavesdrop such a transmission from a dis-
tance of 100 meters. Froma security perspective, the rst
generation Hitag2 transponders have a physical advant-
age over the hybrid transponders since they only support
the LF interface.
8 Mitigation
This section briey discusses a simple but effective au-
thentication protocol for car immobilizers and it also de-
scribes 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 straightfor-
ward mutual authentication protocol is sketched in Fig-
ure 20. The random nonces n
R
, n
T
, secret key k and
transponder password PWD
T
should be at least 128 bits
long. Comparable schemes are proposed in the literat-
ure [32, 33, 46, 48, 49].
authenticate
id, n
T
{n
R
, n
T
}
k
{n
R
, PWD
T
}
k