Skip to main content
security

Man-in-the-Middle (MITM)

A man-in-the-middle attack intercepts communication between two parties, reading or modifying traffic without either party's knowledge. TLS prevents MITM by authenticating the server via certificates and encrypting the channel. MITM succeeds when: TLS is absent (HTTP), certificate validation is disabled, or the attacker controls a trusted CA.

Definition

Man-in-the-middle attacks position the attacker between client and server, relaying and potentially modifying traffic. On a local network, ARP spoofing redirects traffic through the attacker's machine. On WiFi, a rogue access point with the same SSID captures all traffic. At the network level, BGP hijacking can redirect internet traffic through malicious routers. TLS defeats MITM by: verifying the server's certificate chain (proving identity), using authenticated encryption (detecting modification), and negotiating session keys via Diffie-Hellman (preventing key extraction from recorded traffic). MITM still succeeds when: applications skip certificate verification (verify=False in Python requests), users click through certificate warnings, or attackers have access to a trusted CA's signing key (corporate TLS inspection proxies operate this way deliberately).

Examples

  • mitmproxy -p 8080 (intercepts HTTP/HTTPS with custom CA)
  • ARP spoof + sslstrip: downgrades HTTPS to HTTP on local networks
  • HSTS + certificate pinning prevents MITM even with a compromised CA

Related Protocols

Related Terms