liveBook · Manning

Man-in-the-middle attack

As explained in Real-World Cryptography

A man-in-the-middle attack is an active attack in which an adversary intercepts and alters communication between two parties while impersonating each party to the other.

Imagine Alice connecting to Bob over an untrusted network. An attacker silently intercepts their messages, presents the attacker’s public key to Alice as Bob’s, and presents another key to Bob as Alice’s. Each party may believe the attacker is the other party. section 1.4.1 section 9.1

A man-in-the-middle attack is an active attack on communication: the adversary intercepts, alters, reorders, or relays messages while impersonating both endpoints. Passive recording alone is different; without an active substitution during setup, later decryption may be impossible. section 10.2 section 9.1

An unauthenticated Diffie–Hellman exchange creates the opening:

  • Alice sends a public key, but accepts any received key as Bob’s. section 1.4.1
  • The attacker replaces Alice’s and Bob’s public keys, establishing separate shared secrets with each endpoint. section 1.4.1
  • The attacker can then relay or modify traffic between the two protected connections while remaining hidden. section 9.1

The core remedy is authentication: participants must obtain or verify the other party’s public key through a trusted mechanism. Public-key cryptography simplifies trust establishment but does not eliminate the need for a root of trust. section 1.4.1 section 10.2

Practical defenses include:

  • Use an authenticated key exchange or a trusted certificate-based system rather than accepting arbitrary public keys. section 1.4.1 section 10.2
  • For device pairing, compare fingerprints or a short authenticated string (SAS) through an out-of-band channel. section 11.3.3
  • Treat short SAS values carefully: commitment before disclosure prevents an attacker from choosing keys adaptively to force matching values. section 11.3.3

Phone-to-car pairing

A phone and car can display the same short authenticated string for the negotiated connection. Matching values help the user detect that the key exchange was not intercepted, although the cited Bluetooth warning advises caution about relying on its security protocols.

How Real-World Cryptography covers it

How deep it goes
Works through public-key substitution and defenses, stopping short of implementation-level transport details.
Examples
Uses Alice-and-Bob key substitution, browser HTTPS traffic, and Bluetooth phone-to-car pairing to illustrate interception and verification.
What it assumes
Assumes basic public and private keys, then builds the trust problem from an unauthenticated Diffie–Hellman exchange.
What you can do after
Diagnose/debug with it by distinguishing passive observation from active key substitution and checking authentication or SAS verification.
How it connects
Connects Diffie–Hellman key exchange, public-key cryptography, authentication, root of trust, TLS, certificates, and device pairing.

Also explained in

Compare how 4 books explain man-in-the-middle attack →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Real-World Cryptography. The section links point to the parts of the book it draws on.