Course contentsShow
← Security
Lesson 133 of 3,0523. Symmetric Cryptography Deep DiveFree lesson

Nonce Reuse Attacks in CTR and GCM

Explore the catastrophic consequences of nonce reuse in counter mode and GCM, including plaintext recovery attacks.

Nonce Reuse Attacks in CTR and GCM

What you'll learn: Why reusing a nonce in CTR or GCM mode is a catastrophic failure that can expose your encrypted data.

The Fatal Flaw: Same Nonce, Same Keystream

Remember that CTR mode and GCM (which uses CTR internally) generate a keystream by encrypting a counter value that starts with the nonce. If you reuse the same nonce with the same key, you generate the exact same keystream for both messages.

Think of it like using the same one-time pad twice. The security evaporates instantly.

How the Attack Works

When two plaintexts (P1 and P2) are encrypted with the same nonce:

  • Ciphertext 1: C1 = P1 ⊕ Keystream
  • Ciphertext 2: C2 = P2 ⊕ Keystream

An attacker who captures both ciphertexts can XOR them together:

C1 ⊕ C2 = (P1 ⊕ Keystream) ⊕ (P2 ⊕ Keystream) = P1 ⊕ P2

Now the keystream cancels out! The attacker has P1 ⊕ P2, which reveals patterns and structure. With known-plaintext (like standard headers) or statistical analysis, they can often recover both original messages completely.

Even Worse for GCM

GCM mode adds authentication, but nonce reuse breaks that too. An attacker can:

  1. Recover the authentication key
  2. Forge valid ciphertexts
  3. Decrypt messages

This is why GCM specifications emphasize that nonce reuse is absolutely forbidden—it destroys both confidentiality and authenticity.

Real-World Impact

This isn't theoretical. Nonce reuse has broken TLS implementations, VPN systems, and disk encryption. Even a single collision in billions of messages can be catastrophic.

Key Takeaway: Nonce reuse in CTR or GCM mode allows attackers to XOR ciphertexts together, eliminating encryption protection and potentially recovering plaintexts or forging messages. Never reuse a nonce with the same key.