Foxcolab

Glossary

Man-in-the-middle attack

Definition

Man-in-the-middle attack: An attack in which someone positions themselves between two communicating parties, relaying traffic in both directions so that they can read or alter it while each side believes it is talking directly to the other.

Also known asMITMMitMperson-in-the-middle attackmanipulator-in-the-middle attack

In short

A man-in-the-middle attack (MITM) is one where an attacker places themselves between two parties who believe they are talking directly, and relays the traffic so they can read or alter it. TLS defeats it by authenticating the server with a certificate, which works only when the certificate is actually validated. Phishing proxies and swapped encryption keys are the same attack at other layers.

Key takeaways

  • The attacker relays traffic in both directions, so both sides see a working connection.
  • Encryption alone does not stop the attack. You can be encrypting to the attacker. Authentication of the other end is what stops it.
  • TLS protects you only if certificates are validated, the connection can't be downgraded to plaintext, and the device's trusted authorities are sound.
  • Mail servers that use opportunistic STARTTLS can be downgraded by an attacker who removes the STARTTLS offer; MTA-STS exists to prevent that.
  • A phishing page that relays your password and one-time code to the real site is a man-in-the-middle attack too.

Last reviewed 30 November 2026

A man-in-the-middle attack (MITM) is one where an attacker places themselves between two parties who believe they are talking directly to each other. The attacker relays the traffic in both directions, so everything appears to work, while reading it, changing it or both. NIST's glossary gives the purpose as "to intercept and/or alter data traveling between them".

Getting into the middle#

The attacker first needs your traffic to pass through a machine they control. RFC 6797 gives examples: "impersonating a user's DNS server" or, on Wi-Fi, "offering a similarly named evil twin access point". Picture a café network called Cafe-Guest. An attacker nearby broadcasts the same name, your laptop joins theirs, and every request now passes through their machine. In OWASP's words, the attacker "acts as a proxy, being able to read, insert and modify the data".

Why TLS helps only when certificates are checked#

Encryption alone doesn't solve this, because you may be setting up an encrypted connection with the attacker. Authentication does. In TLS, the server presents a certificate, and your browser checks that a trusted authority issued it for the name you asked for. An attacker in the middle can't get one for your bank's name.

That protection has three conditions:

  1. The certificate is validated. RFC 8446 says certificates "should always be verified". An app that skips the check to silence errors accepts anyone's certificate, and OWASP notes that browser users "may ignore these warnings".
  2. TLS is used at all. An attacker can try to keep you on plain HTTP. HSTS (RFC 6797) makes browsers refuse insecure connections to a site and removes the option to click past certificate errors. Mail has the same weakness: RFC 8461 notes that an attacker who deletes the "250 STARTTLS" response can downgrade delivery between mail servers, which is what MTA-STS is for.
  3. The trusted authorities are sound. Anyone who can add a root certificate to your device can pass the check. RFC 8446 warns that adding trust anchors "should be done very carefully".

The same attack at other layers#

  • Sign-in. A phishing page on a lookalike domain can relay your password and TOTP code to the real site. TLS is valid on both legs, and the attacker is still in the middle. A passkey is tied to the real domain and won't answer the fake one.
  • End-to-end encryption. End-to-end encryption keeps even the server out of the middle, but only if you encrypt to the right public key. Whoever can swap in their own key can read every message, which is why apps let two people compare security codes.

Keep exploring

All terms

Foxcolab

Private work tools, without the ads.

Mail, files, documents, spreadsheets and meetings in one account. Files, documents and spreadsheets are end-to-end encrypted.

Jump to