Skip to content
Crypto Disclosed report Advanced CVE-2017-13077CVE-2017-13078CVE-2017-13079CVE-2017-13080CVE-2017-13081CVE-2017-13082CVE-2017-13084CVE-2017-13086CVE-2017-13087CVE-2017-13088

Key Reinstallation Attacks: Breaking WPA2 by forcing nonce reuse

The WPA2 4-way handshake is vulnerable to key reinstallation attacks, where an attacker can force a victim to reinstall an already-in-use session key, resetting the nonce and causing nonce reuse. This allows the attacker to decrypt parts of encrypted Wi-Fi traffic.

Mathy Vanhoef Follow

Originally disclosed on HackerOne

Medium 6.8 View original
  • Fixed in 2 hours
  • Paid in 2 hours
  • Disclosed after 2 hours

Full background information is at krackattacks.com and all detailed information can be found in our research paper.

Key Reinstallation Attack: 4-way handshake example

We use the 4-way handshake to illustrate the idea behind key reinstallation attacks (CVE-2017-13077). Note that in practice, all protected Wi-Fi network rely on the 4-way handshake to derive a fresh session key (PTK) from some shared secret.

Step 1. Channel-based man-in-the-middle and initial handshake messages:

  • The adversary clones the access point (AP) on a different channel. Say the real AP is on channel 6, and it will be cloned on channel 1.
  • The adversary uses Channel Switch Announcements to force victims into connecting to the cloned AP on channel 1.
  • The adversary forwards the first three message of the 4-way handshake between the client and AP (i.e. the adversary fowards frames over the different channels).
  • After the client receives message 3 of the handshake, it will install the fresh session key (PTK) for the first time.

Step 2. Triggering a key reinstallation:

  • The attacker does not forward message 4 of the handshake to the AP, effectively blocking it.
  • As a result, the AP will retransmit message 3 to the client.
  • After the client receives message 3, it responds with message 4. In practice all clients encrypt this retransmitted message 4 at the link layer. Note that it's encrypted because message 4 an ordinary data frame, and the victim has already installed the session key to encrypt data frames (recall end of step 1). The victim will use a nonce value of 1 to encrypt message 4.
  • After sending message 4, the client will reinstall the session key. This resets the transmit nonce to zero.

Step 3. Abusing nonce reuse:

  • When the client now transmit a normal encrypted data frame, it will increment the nonce counter, and then reuse the nonce value 1 when encrypting the data frame.
  • We can derive known keystream from the encrypted retransmitted message 4 (recall step 2), and use this to decrypt parts of the just transmitted encrypted data frame.
  • Other predictable packets (ARP, DHCP, HTML, and so on) can be used to obtain additional known plaintext and keystream, which can in turn be used to decrypt more and bigger packets.

The above example attack against the 4-way handshake is also illustrated in my CCS'17 presentation.

Other handshakes

Other Wi-Fi handshakes or features that were found to be vulnerable to key reinstallation attacks are:

  • Reinstallation of group keys in the 4-way handshake: CVE-2017-13078 and CVE-2017-13079
  • The group key handshake: CVE-2017-13080 and CVE-2017-13081
  • The Fast BSS Transition (FT) handshake: CVE-2017-13082
  • The PeerKey handshake: CVE-2017-13084
  • The Tunneled Direct-Link Setup (TDLS) handshake: CVE-2017-13086
  • Handling of Wireless Network Management (WNM) Sleep Mode Response frame: CVE-2017-13087 and CVE-2017-13088.

Countermeasures

Implementations can be updated to prevent key reinstallation attacks in a backwards-compatible manner.

As an additional mitigation, an access point can also prevent most attacks against vulnerable clients. In particular, attacks against the 4-way handshake can be prevented by not retransmitting message 3. Similarly, attacks against the group key handshake can be prevented by not retransmitting message 1 of the group key handshake. Alternatively, the access point can retransmit these two handshake messages using the previously used EAPOL-Key replay counter.

Additional Contributions

The original report as published on HackerOne, by vanhoefm. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The Wi-Fi protocol allows retransmission of handshake messages that cause the client to reinstall an already-in-use session key, resetting the nonce and leading to nonce reuse.

Impact

An attacker within range could decrypt parts of the victim's Wi-Fi traffic, though the attack requires a man-in-the-middle position and specific conditions.

What the attacker needed

Attacker within Wi-Fi range; victim forced to connect to cloned AP; vulnerable client or AP implementation

The fix

Implementations should be updated to prevent key reinstallation, and access points can mitigate by not retransmitting message 3 of the 4-way handshake or by using the previously used replay counter.

How it was found

  1. The adversary clones the access point on a different channel and uses Channel Switch Announcements to force victims to connect to the cloned AP.
  2. The adversary forwards the first three messages of the 4-way handshake between the client and the real AP.
  3. The attacker blocks message 4 from reaching the AP, causing the AP to retransmit message 3.
  4. The client responds with message 4, encrypted with nonce value 1, and then reinstalls the session key, resetting the nonce to zero.
  5. When the client sends a normal data frame, it reuses nonce value 1, allowing the attacker to derive keystream from the earlier encrypted message 4 and decrypt parts of the data frame.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

Wi-Fi networks use a handshake to set up encryption keys. This research shows that an attacker can trick a device into reinstalling the same key, which makes the encryption reuse a number (nonce) that should never repeat. That lets the attacker decrypt some of the victim's traffic.

What is Crypto?

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.

More by Mathy Vanhoef

View all

5 more disclosed reports, best first.

More from Internet Bug Bounty

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cryptographic weaknesses

The lesson behind this report.

Encryption, signatures, randomness or certificate checks that do not protect what they claim to.