Course contentsShow
← Security
Lesson 156 of 3,0524. Asymmetric Cryptography and PKIFree lesson

Man-in-the-Middle Attacks on Diffie-Hellman

How unauthenticated Diffie-Hellman is vulnerable to active attackers and why authentication is essential.

Man-in-the-Middle Attacks on Diffie-Hellman

You'll learn why unauthenticated Diffie-Hellman key exchange is dangerously vulnerable to active attackers.

The Core Problem

Remember that Diffie-Hellman allows two parties (Alice and Bob) to establish a shared secret over an insecure channel. The math works beautifully—but there's a critical flaw: neither party proves who they actually are.

When Alice sends her public value g^a mod p to Bob, she has no way to verify it actually reaches Bob and not an attacker. Similarly, Bob can't verify the public value he receives truly came from Alice.

How the Attack Works

Imagine Eve sitting between Alice and Bob:

  1. Alice → Eve: Alice sends her public value, thinking it's going to Bob
  2. Eve → Bob: Eve intercepts it and sends her own public value to Bob instead
  3. Bob → Eve: Bob responds with his public value, thinking it's for Alice
  4. Eve → Alice: Eve sends a different public value to Alice

Result: Alice now shares a secret with Eve (not Bob), and Bob shares a different secret with Eve (not Alice). Eve can decrypt everything from Alice, read or modify it, re-encrypt it for Bob, and neither party knows they're compromised.

Why Authentication is Essential

Unauthenticated Diffie-Hellman is only secure against passive eavesdroppers. An active attacker who can intercept and modify traffic completely breaks the protocol. This is why real-world systems combine Diffie-Hellman with authentication mechanisms like digital signatures (TLS uses RSA or ECDSA signatures to authenticate DH exchanges) or pre-shared keys.

Key Takeaway: Diffie-Hellman without authentication is vulnerable to man-in-the-middle attacks where an attacker establishes separate shared secrets with each party, gaining complete control over the communication.