Man-in-the-middle attack

Also known as: MITM

On this page 7

A man-in-the-middle attack (MITM) is an attack in which an adversary secretly positions itself between two communicating parties, relaying their messages so that each side believes it is talking directly to the other, while the attacker reads, records or modifies the traffic. In cybersecurity, it belongs to the family of malware and attacks that target the communication channel rather than the endpoints, and it directly threatens confidentiality, integrity and authentication.

The attack has two phases: interception, in which the attacker diverts traffic through a system it controls, and decryption or manipulation, in which it defeats or bypasses the protection on that traffic. Modern defenses focus on making the second phase fail even when the first succeeds.

How a man-in-the-middle attack intercepts traffic

A man-in-the-middle attack starts by redirecting the victim’s traffic through an attacker-controlled point. On a local network the attacker can poison address resolution; on a wider scale it can manipulate name resolution or routing. Once traffic flows through the attacker, it can be forwarded transparently so that neither party notices any interruption.

The table below lists the most common interception techniques, the network layer they abuse and the typical attacker position they require.

TechniqueLayer abusedAttacker position needed
ARP spoofingData link (IPv4 address resolution)Same local network segment
Rogue access pointWireless associationPhysical proximity to victims
DNS spoofingName resolutionResolver path or local network
DHCP spoofingNetwork configurationSame broadcast domain
BGP hijackingInternet routingControl of an autonomous system
Malicious proxyApplication or OS settingsCode running on the victim device
Common interception techniques

Interception alone exposes only unencrypted traffic and metadata such as destination addresses and timing. To read protected content, the attacker must also break or sidestep the encryption, which is where the second phase begins.

Defeating encryption and authentication

Against encrypted channels, the attacker depends on weaknesses in authentication, not in the cipher itself. Transport Layer Security (TLS) prevents interception only when the client verifies the server certificate correctly, so most practical attacks aim to make that verification fail silently or be skipped.

  • SSL stripping downgrades a connection to plain HTTP when the user types an address without the https prefix and the site lacks HSTS.
  • Forged certificates succeed when a victim accepts a browser warning or when a malicious root certificate has been installed on the device.
  • Protocol downgrade forces the use of obsolete protocol versions or weak cipher suites with known flaws.
  • Session hijacking steals authentication cookies or tokens that are already in transit, bypassing passwords and often MFA.

A related variant, the adversary-in-the-middle (AiTM) phishing proxy, relays a real login page in real time. The victim completes multi-factor authentication on the genuine site through the proxy, and the attacker captures the resulting session cookie. This is why one-time codes and push approvals do not stop AiTM, while phishing-resistant authentication such as FIDO2 does.

A man-in-the-middle attack is defined by an active, real-time position in the communication path. Several neighboring attack types share techniques with it but differ in timing, goal or required access, as the following comparison shows.

AttackCore actionKey difference from MITM
EavesdroppingPassive capture of trafficNo relaying or modification
Replay attackResends captured messages laterNot live, reuses old data
PhishingLures users to a fake siteOften a delivery path for AiTM
Man-in-the-browserMalware alters pages on the deviceOperates inside the endpoint
Credential stuffingReuses leaked passwordsNo position in the channel
Man-in-the-middle attack compared with related attacks

The distinction matters for defense. Encryption with sound authentication defeats classic MITM, but man-in-the-browser malware operates after decryption, so it requires endpoint protection rather than transport security.

Detection signs and defensive controls

Effective defense against MITM combines strong channel authentication with network hygiene. Because users routinely ignore warnings, the strongest controls are those that fail closed automatically instead of asking a person to decide.

ControlWhat it blocksPractical note
TLS 1.3 with validationReading and altering web trafficDisable legacy protocol versions
HSTS and preloadSSL strippingForces HTTPS before the first request
Mutual TLSImpersonation of clients or servicesCommon in service-to-service traffic
FIDO2 passkeysAiTM credential and session theftBound to the genuine domain
Dynamic ARP inspectionARP spoofing on switched LANsRelies on DHCP snooping data
DNSSEC and encrypted DNSForged name resolutionValidate at the resolver
802.1X and WPA3Rogue devices and weak Wi-FiPrevents unauthorized network access
Controls that counter man-in-the-middle attacks

Useful detection signals include duplicate MAC addresses for the gateway, unexpected certificate issuers, sudden TLS version downgrades, logins from a new location seconds after a legitimate one, and certificate transparency entries for domains the organization did not request.

Common misconceptions about MITM

Several widespread beliefs about man-in-the-middle attacks lead to misplaced confidence or wasted effort. Correcting them helps prioritize the controls that actually work.

  • The padlock means safety: it proves encryption to some server, not that the domain is the intended one.
  • VPNs eliminate MITM: they protect the path to the VPN endpoint, but traffic beyond it still needs TLS.
  • MFA always stops it: codes and push prompts can be relayed by an AiTM proxy in real time.
  • Only public Wi-Fi is risky: compromised routers, malicious proxies and corporate inspection devices create the same position.
  • Certificate warnings are harmless: clicking through a warning is often the exact moment the attack succeeds.

Legitimate TLS inspection appliances in enterprises are, technically, an authorized man-in-the-middle. They must be tightly controlled, because a compromised inspection device or its private key gives an attacker visibility into all decrypted traffic.

Understanding it simply

Imagine passing notes to a friend through a classmate. If that classmate secretly reads every note, or rewrites some before passing them on, neither of you would know. A man-in-the-middle attack is the digital version: someone sits between you and the website or person you are talking to.

Encryption works like a sealed envelope that only the real recipient can open, and certificates are the ID check that confirms who that recipient is. The takeaway is simple: never ignore a security warning about a website’s certificate, because that warning is often the only sign that someone is in the middle.

Applied in practice

A finance employee at a mid-sized manufacturing company receives an email that appears to come from the company’s cloud office provider, asking her to review a shared invoice. The link opens a page that looks identical to the real sign-in screen, because it is the real screen relayed through an adversary-in-the-middle proxy.

She enters her password and approves the push notification on her phone. The proxy captures the authenticated session cookie and, within ten minutes, the attacker creates a mailbox rule that hides replies from a supplier, preparing a business email compromise.

The security team detects the session because it originates from a hosting provider in another country two minutes after her genuine login. They revoke all sessions, remove the rule and then roll out FIDO2 security keys for finance staff. In a later red-team test, the same proxy technique fails because the keys refuse to sign in for a domain other than the genuine one.