# 中间人攻击

中间人攻击（man-in-the-middle attack，简称MitM，亦写作MITM，MDN将其扩展为“中间的操纵者”）是指攻击者置身于两个通信方之间，以拦截和/或篡改双方之间传输的数据的攻击方式。在身份验证场景中，攻击者位于声称方与验证方之间，在注册过程中位于注册者与凭证服务提供者之间，或在认证器绑定过程中位于订阅者与提供者之间。<sup>[1](https://csrc.nist.gov/glossary/term/man_in_the_middle_attack)</sup> 在网络上，这种攻击通常发生在用户的浏览器与服务器之间，使攻击者能够查看并可能修改通过HTTP交换的任何流量。<sup>[2](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/MITM)</sup>

| 关键事实 | 详情 |
|---|---|
| 定义 | 攻击者置身于两个通信方之间，以拦截和/或篡改双方之间的数据（NIST）<sup>[1](https://csrc.nist.gov/glossary/term/man_in_the_middle_attack)</sup> |
| 典型网络目标 | 用户浏览器与服务器之间通过HTTP传输的流量<sup>[2](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/MITM)</sup> |
| 主要防御手段 | HTTPS（基于TLS的HTTP），可阻止攻击者读取流量或以可预测的方式修改流量<sup>[2](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/MITM)</sup> |
| TLS条件 | 只要服务器经过身份验证，通道即可安全抵御中间人攻击；完全匿名的会话本质上容易受到攻击<sup>[3](https://www.rfc-editor.org/rfc/rfc5246.html)</sup> |
| 加固标头 | HTTP严格传输安全（HSTS）强制使用HTTPS，并消除点击绕过证书错误的可能性<sup>[4](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Strict-Transport-Security?view=Schedule)</sup> |
| 已知缺口 | HSTS仅在浏览器至少见过一次该标头后才提供保护；除非主机已预加载，否则首次访问可能被拦截或剥离<sup>[5](https://wstg.owasp.org/latest/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management/07-HTTP_Strict_Transport_Security/)</sup> |
| 常见局域网技术 | ARP欺骗，由Ettercap、Dsniff和Cain & Abel等工具实现<sup>[6](https://community.owasp.org/attacks/Manipulator-in-the-middle_attack)</sup> |

## 攻击原理

攻击者将自己插入试图通信的两个实体之间。在网络上，这意味着攻击者可以读取和修改浏览器与用户所连接站点之间交换的HTTP数据，而HTTPS则保护其所保护的流量不被攻击者读取或可预测地修改。<sup>[2](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/MITM)</sup><sup> • </sup><sup>[17](https://ssd.eff.org/module/what-should-i-know-about-encryption)</sup> 一种常用的方法是，攻击者在公共场所（如咖啡馆或机场）建立一个无线热点，然后等待受害者接入；一旦受害者接入，攻击者便可以读取和修改通过HTTP交换的数据，而HTTPS则保护其所保护的流量不被攻击者读取或可预测地修改。<sup>[2](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/MITM)</sup><sup> • </sup><sup>[17](https://ssd.eff.org/module/what-should-i-know-about-encryption)</sup>

**局域网技术。** 攻击工具在局域网环境中尤为高效，因为它们实现了[ARP欺骗](https://www.edgepedia.org/zh/arp-spoofing)等额外功能，可以拦截主机之间的通信。被提及的工具包括PacketCreator、Ettercap、Dsniff和Cain & Abel。WebScarab、Paros Proxy、Burp Proxy、Fiddler和mitmproxy等代理工具可以与HTTP协议的某些部分（如事务的标头和正文）交互，但本身无法拦截客户端与服务器之间的TCP连接。<sup>[6](https://community.owasp.org/attacks/Manipulator-in-the-middle_attack)</sup>

**针对HTTPS的攻击。** 这种攻击也可以在HTTPS连接上实施。主要区别在于建立两个独立的TLS会话，每个TCP连接上各一个：浏览器与攻击者建立TLS连接，攻击者再与Web服务器建立另一个TLS连接，在中间终止并重新加密流量。<sup>[6](https://community.owasp.org/attacks/Manipulator-in-the-middle_attack)</sup> 这通常需要受害者接受攻击者出示的证书，例如通过点击绕过证书警告。<sup>[5](https://wstg.owasp.org/latest/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management/07-HTTP_Strict_Transport_Security/)</sup>

**降级与剥离。** 处于网络特权位置的攻击者可以在用户访问HTTP站点时拦截流量，并操纵流量以获取中间人位置，即使目标站点同时提供HTTPS也是如此。OWASP描述了攻击者利用接受不受信任证书的用户，或通过降级或剥离到HTTPS的重定向（SSL剥离）来实施中间人攻击。<sup>[5](https://wstg.owasp.org/latest/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management/07-HTTP_Strict_Transport_Security/)</sup><sup> • </sup><sup>[7](https://wstg.owasp.org/v4.1/4-Web_Application_Security_Testing/09-Testing_for_Weak_Cryptography/01-Testing_for_Weak_SSL_TLS_Ciphers_Insufficient_Transport_Layer_Protection/)</sup> 当服务器同时在HTTP和HTTPS上暴露应用，或页面混合使用HTTP和HTTPS资源时，也会出现相关弱点。<sup>[7](https://wstg.owasp.org/v4.1/4-Web_Application_Security_Testing/09-Testing_for_Weak_Cryptography/01-Testing_for_Weak_SSL_TLS_Ciphers_Insufficient_Transport_Layer_Protection/)</sup>

## 身份验证为何能击退攻击

加密本身并非决定性因素；服务器身份验证才是。根据TLS规范，当服务器经过身份验证时，中间人攻击无法突破通道，而完全匿名的会话本质上仍然容易受到此类攻击，未经身份验证的服务器也无法验证客户端。<sup>[3](https://www.rfc-editor.org/rfc/rfc5246.html)</sup> 同样的要求也出现在[TLS 1.3](https://www.edgepedia.org/zh/tls-1-3)中：使用公钥但未进行证书验证的连接，或缺少外部机制（如服务器公钥的带外验证、首次使用即信任或通道绑定）的连接，无法抵御主动中间人攻击，应用程序不得在缺乏明确配置的情况下以这种方式使用TLS。<sup>[8](https://www.rfc-editor.org/info/rfc8446/)</sup>

证书验证是使身份验证真正发挥作用的机制。在LDAP over TLS中，客户端必须验证服务器在证书消息中呈现的身份，将参考身份与相应类型的subjectAltName值进行比较。<sup>[9](https://www.rfc-editor.org/info/rfc4513/)</sup> 当在EAP-TLS中部署公共根CA而不验证服务器名称时，基本上每台服务器都能获取对等方在EAP身份验证中视为可信的证书，从而削弱了服务器确实代表该网络的保证。<sup>[10](https://www.rfc-editor.org/rfc/rfc9190.html)</sup> 反过来，密钥泄露也可以击败验证：在2012年CISA的一份公告中，西门子S7-1200 PLC的HTTPS证书颁发机构私钥存储不安全，使攻击者能够创建伪造证书，用于对已信任该设备CA的浏览器实施中间人攻击。<sup>[11](https://www.cisa.gov/news-events/ics-advisories/icsa-12-263-01)</sup>

## 网络上的防御

抵御中间人攻击的主要防御手段是通过HTTPS提供站点服务，这可阻止攻击者读取流量或以可预测的方式修改流量。站点运营者应通过HTTPS提供所有页面，而不仅是被视为敏感的页面，使用安全的TLS配置，实施服务器身份验证，通过TLS提供所有子资源（如脚本、样式表、图像和字体），并在将HTTP重定向到HTTPS时实施严格传输安全。<sup>[2](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/MITM)</sup> MDN的防御概述指出，HTTPS是网络上抵御中间的操纵者攻击的唯一真正防御手段。<sup>[12](https://developer.mozilla.org/en-US/docs/Web/Security/Defenses)</sup>

**HSTS。** `Strict-Transport-Security`标头指示浏览器仅通过HTTPS访问站点，即使请求的URL使用的是HTTP，并且它通过消除点击绕过证书错误页面的选项，使浏览器更严格地执行TLS和证书错误处理。<sup>[13](https://developer.mozilla.org/en-US/docs/Web/Security/Practical_implementation_guides/TLS)</sup> 主机只能通过HTTPS发送该标头；如果通过HTTP发送，浏览器会忽略它，以防止中间的操纵者篡改标头使其过早过期，或为不支持HTTPS的主机添加该标头。<sup>[4](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Strict-Transport-Security?view=Schedule)</sup> 该标头包含一个`max-age`指令（以秒为单位），指定浏览器重定向到HTTPS的持续时间，以及一个可选的`includeSubDomains`指令，用于升级所有子域上的请求。<sup>[13](https://developer.mozilla.org/en-US/docs/Web/Security/Practical_implementation_guides/TLS)</sup>

HSTS存在已知的首次连接缺口：它仅保护浏览器此前已收到该主机标头后发送的请求，这意味着用户的初始连接，或在存储策略失效后建立的任何连接，如果主机未预加载，仍然通过明文HTTP进行，攻击者可能在浏览器感知到HSTS之前拦截或剥离该初始请求或重定向。预加载将策略内置到浏览器中，完全弥补了这一缺口。<sup>[5](https://wstg.owasp.org/latest/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management/07-HTTP_Strict_Transport_Security/)</sup>

**服务器端配置。** OWASP的加固清单将不安全的TLS重协商视为必须禁用的中间人风险，同时禁用SSLv2等弱协议，并避免使用不提供身份验证的匿名Diffie-Hellman密码套件。<sup>[14](https://owasp.org/www-project-web-security-testing-guide/assets/archive/OWASP_Testing_Guide_v4.pdf)</sup>

## 网络之外的场景

同样的攻击模式出现在任何两方建立通道但未相互验证身份的场景中。相互匿名的隧道协议容易受到中间人攻击，攻击者建立两条隧道——一条连接到对等方，另一条连接到身份验证服务器——双方都误以为直接连接到了对方；两条隧道建立后，攻击者可以监听通过它们传输的所有内容，包括内部身份验证方法中交换的标识符。<sup>[15](https://www.rfc-editor.org/rfc/rfc6678.html)</sup> 如果隧道协议支持任何可被在线破解的密钥建立算法，它们也容易受到降级攻击。<sup>[15](https://www.rfc-editor.org/rfc/rfc6678.html)</sup>

对于最终用户而言，随着加密技术的普及，实际情况已经发生了变化。美国[联邦贸易委员会](https://www.edgepedia.org/zh/federal-trade-commission)指出，过去使用公共Wi-Fi网络会使信息面临风险，因为大多数网站不使用加密，而如今大多数网站都使用加密，因此通过公共Wi-Fi连接通常是安全的；它建议寻找地址栏中的锁形符号或https。<sup>[16](https://consumer.ftc.gov/articles/are-public-wi-fi-networks-safe-what-you-need-know)</sup> 剩余风险正是协议设计所预见的：未经身份验证的连接，或用户无视安全警告而建立的连接，在任何网络上，都是中间人攻击者所需的机会。<sup>[3](https://www.rfc-editor.org/rfc/rfc5246.html)</sup><sup> • </sup><sup>[4](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Strict-Transport-Security?view=Schedule)</sup>

## References

1. [man-in-the-middle attack (MitM), NIST CSRC Glossary](https://csrc.nist.gov/glossary/term/man_in_the_middle_attack)
2. [Manipulator in the Middle (MITM), MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Security/Attacks/MITM)
3. [RFC 5246: The Transport Layer Security (TLS) Protocol Version 1.2, RFC Editor](https://www.rfc-editor.org/rfc/rfc5246.html)
4. [Strict-Transport-Security header, MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Strict-Transport-Security?view=Schedule)
5. [OWASP Web Security Testing Guide: HTTP Strict Transport Security](https://wstg.owasp.org/latest/4-Web_Application_Security_Testing/02-Configuration_and_Deployment_Management/07-HTTP_Strict_Transport_Security/)
6. [Manipulator-in-the-Middle attack, OWASP Foundation](https://community.owasp.org/attacks/Manipulator-in-the-middle_attack)
7. [OWASP WSTG v4.1: Testing for Weak SSL/TLS Ciphers, Insufficient Transport Layer Protection](https://wstg.owasp.org/v4.1/4-Web_Application_Security_Testing/09-Testing_for_Weak_Cryptography/01-Testing_for_Weak_SSL_TLS_Ciphers_Insufficient_Transport_Layer_Protection/)
8. [RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3, RFC Editor](https://www.rfc-editor.org/info/rfc8446/)
9. [RFC 4513: LDAP Authentication Methods and Security Mechanisms, RFC Editor](https://www.rfc-editor.org/info/rfc4513/)
10. [RFC 9190: EAP-TLS 1.3, RFC Editor](https://www.rfc-editor.org/rfc/rfc9190.html)
11. [CISA ICS Advisory ICSA-12-263-01: Siemens S7-1200 Insecure Storage of HTTPS CA Certificate](https://www.cisa.gov/news-events/ics-advisories/icsa-12-263-01)
12. [Defenses, MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Security/Defenses)
13. [Transport Layer Security (TLS) configuration, MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/Security/Practical_implementation_guides/TLS)
14. [OWASP Testing Guide v4: Testing for Weak SSL/TLS Ciphers/Protocols/Keys](https://owasp.org/www-project-web-security-testing-guide/assets/archive/OWASP_Testing_Guide_v4.pdf)
15. [RFC 6678: Requirements for Client-Server Tunnel Protocols, RFC Editor](https://www.rfc-editor.org/rfc/rfc6678.html)
16. [Are Public Wi-Fi Networks Safe? What You Need To Know, FTC Consumer Advice](https://consumer.ftc.gov/articles/are-public-wi-fi-networks-safe-what-you-need-know)
17. [What Should I Know About Encryption?](https://ssd.eff.org/module/what-should-i-know-about-encryption)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Security governance and internet policy › Cryptographic protocols

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/man-in-the-middle-attack

English original: https://www.edgepedia.org/man-in-the-middle-attack
