# What Is Man-in-the-Middle Attack (MITM, on-path attack)?

> A man-in-the-middle attack is one where an attacker secretly relays, and may alter, traffic between two parties who each believe they talk directly.

Source: https://ssl.sh/glossary/man-in-the-middle/
Last updated: 2026-11-10

In a man-in-the-middle (MITM) attack, also called an on-path attack, the attacker gets into the communication path, for example through a rogue Wi-Fi access point, ARP spoofing on a LAN, DNS spoofing or a BGP route hijack, and relays traffic between client and server. Against unencrypted protocols this gives full read and write access. TLS is designed to defeat it: the server must prove possession of the private key for a certificate that covers the requested name and chains to a CA the client trusts, and the handshake transcript is authenticated so that tampering is detected.

## Why it matters
Practical MITM against TLS therefore targets the edges of that model. Attackers rely on users clicking through certificate warnings, on clients that skip verification (`curl -k`, `verify=False`), on [SSL stripping](https://ssl.sh/glossary/ssl-stripping/) before TLS starts, on [downgrade attacks](https://ssl.sh/glossary/downgrade-attack/) to weak protocol versions, or on a fraudulently issued certificate. The 2011 compromise of the Dutch CA DigiNotar, which issued a fake certificate for google.com and was then removed from browser trust stores, is the classic example of the last case. [HSTS](https://ssl.sh/glossary/hsts/), [Certificate Transparency](https://ssl.sh/glossary/certificate-transparency/) and CAA records exist largely to close these gaps.

## Example
The most common self-inflicted MITM exposure is disabled verification:

```bash
curl -k https://api.example.com/                         # accepts ANY certificate: avoid
curl --cacert internal-ca.pem https://api.example.com/   # trust a specific CA instead
```

## Common misconceptions
- **HTTPS makes MITM impossible.** Only if the client validates the certificate and the user does not override warnings.
- **An attacker has to be physically nearby.** DNS spoofing and route hijacks work remotely, and a compromised router or proxy sits on the path permanently.
- **Skipping verification is fine for internal APIs.** Skipping verification removes exactly the protection against MITM; trust the internal CA explicitly instead.

## Related terms

- [SSL 剥离](https://ssl.sh/zh/glossary/ssl-stripping/): SSL 剥离是一种中间人攻击，攻击者截获本应把用户引向 HTTPS 的跳转或链接，让用户一直停留在明文 HTTP 上。
- [SSL 解密检测](https://ssl.sh/zh/glossary/ssl-inspection/): SSL 解密检测是企业安全网关借助受管设备信任的私有 CA，对 TLS 流量进行解密、检查后再重新加密的做法。
- [HSTS](https://ssl.sh/zh/glossary/hsts/): HSTS 是一个 HTTP 响应头，告诉浏览器在指定时间内只通过 HTTPS 访问该站点，并且遇到证书错误时不允许用户继续访问。
- [证书透明度](https://ssl.sh/zh/glossary/certificate-transparency/): 证书透明度（CT）是一套公开、只可追加的日志系统，记录所有公开信任的 TLS 证书，让任何人都能审计 CA 签发了什么。
- [降级攻击](https://ssl.sh/zh/glossary/downgrade-attack/): 降级攻击是指攻击者迫使客户端和服务器协商出比双方实际支持的更旧的协议版本或更弱的算法，从而利用其中的弱点。
- [错误签发](https://ssl.sh/zh/glossary/misissuance/): 错误签发是指 CA 违反 Baseline Requirements 或根证书计划政策签发证书，从验证缺陷到字段格式错误都算在内。
- [CAA 记录](https://ssl.sh/zh/glossary/caa/): CAA 记录是一种 DNS 记录，用来声明哪些证书颁发机构可以为该域名签发证书，所有公共 CA 签发前都必须检查。
