Appendix F. Security Analysis (安全分析)
本附录提供 TLS 1.2 protocol 的安全分析.
F.1. Handshake Protocol (握手协议)
TLS handshake protocol 的核心安全目标包括:
- Authentication: 验证通信 peer 的身份.
- Key Agreement: 安全建立 shared secret.
- Integrity: 确保 handshake message 未被篡改.
F.1.1. Anonymous Key Exchange (匿名密钥交换)
anonymous key exchange NOT 推荐. Anonymous Diffie-Hellman (DH_anon) cipher suite 不提供认证, 易受 man-in-the-middle attack. 它只应在特定受控环境中使用, 生产环境应避免使用.
F.1.2. RSA Key Exchange and Authentication
RSA key exchange 提供 server authentication, 可选的 client authentication, 以及 pre-master secret 的机密传输. 其限制是不能提供 forward secrecy. 如果 server private key 泄露, 过去 session 可能被解密.
F.1.3. Diffie-Hellman Key Exchange with Authentication
DHE (Ephemeral Diffie-Hellman) 提供 server authentication, forward secrecy 和更强安全保证. 每个 session 使用新的 ephemeral key pair, 即使 long-term key 泄露, 过去 session 仍保持安全. 现代 TLS 部署推荐 DHE 和 ECDHE cipher suite.
F.1.4. Version Rollback Attacks
TLS 通过 ClientHello/ServerHello 中的 version, Finished message 对所有 handshake message 的 MAC, 以及 TLS_FALLBACK_SCSV (RFC 7507) 等机制防止 version rollback.
F.1.5. Detecting Attacks Against the Handshake Protocol
TLS 使用 Finished message 验证完整 handshake, 通过 PRF 保证密码强度, 并依赖完整 certificate chain verification, hostname checking 和 revocation checking 检测攻击. 实现还应使用 constant-time operation 和统一 error handling 防御 timing attack.
F.1.6. Resuming Sessions
session resumption 复用 master secret 并减少计算开销. 新 random number 确保 key 唯一性. 实现需要安全存储 session ticket, 保护 ticket encryption key, 设置适当 timeout, 限制 session lifetime, 并定期轮换 ticket encryption key.
F.2. Protecting Application Data (保护应用数据)
TLS 通过强 encryption algorithm, 每 record 唯一 key material, MAC 或 AEAD authentication tag, 以及 sequence number 提供 application data 的 confidentiality 和 integrity.
F.3. Explicit IVs (显式 IV)
TLS 1.2 使用 explicit IV 处理 TLS 1.0 中 BEAST attack 暴露的问题. TLS 1.0 使用前一 ciphertext block 作为下一 record 的 IV, 可预测 IV 会允许 chosen-plaintext attack. TLS 1.2 每个 record 包含随机生成的 explicit IV, IV 不再可预测.
F.4. Security of Composite Cipher Modes (组合密码模式安全性)
CBC mode 已知问题包括 padding oracle attack, Lucky 13 timing attack 和 TLS 1.0 中的 BEAST attack. 缓解措施包括 explicit IV, constant-time padding validation 和统一 error message.
AEAD mode 同时提供 confidentiality 和 authentication, 不受 padding oracle attack 影响, 实现更简单且通常性能更好. 现代部署应优先使用 AEAD cipher suite, 如 GCM, CCM 和 ChaCha20-Poly1305.
F.5. Denial of Service (拒绝服务)
TLS handshake 成本较高, 可被用于 DoS attack. server 侧可采用 rate limiting, client puzzle, 优先 session resumption 和 resource limit. network layer 可采用 SYN cookie, connection limit 和 firewall rule.
F.6. Final Notes (最终说明)
TLS 1.2 无法防止 endpoint compromise, Certificate Authority compromise, weak password selection 或 social engineering attack. 实践中应持续关注安全公告, 及时更新实现, 禁用弱算法, 审计配置, 记录安全事件并准备 incident response plan.
TLS 1.3 (RFC 8446) 提供更精简 handshake, 更强安全保证, 移除弱算法并改善性能. 新部署应考虑使用 TLS 1.3, 同时按需求维持 TLS 1.2 向后兼容性.