跳到主要内容

11. Security Considerations (安全考虑)

所有密码应用常见安全问题都适用于 JWE/JWS/JWK agent, 包括保护 asymmetric private key, symmetric secret key, key encryption key 和 CEK, 以及防御各种 side-channel 和 oracle attack. JWS 和 XML Encryption 1.1 中非 XML 专属的安全考虑也适用于 JWE.

11.1 Key Entropy and Random Values (密钥熵和随机值)​

CEK 和 IV 的随机性直接影响加密安全. 实现必须使用适合密码用途的随机数生成器, 并满足所选算法对 key length 和 IV size 的要求.

11.2 Key Protection (密钥保护)​

Key encryption key 泄露可能导致用该 key 保护的所有 content 泄露. CEK 泄露会导致对应 encrypted content 泄露. 实现应限制 key use, 保护 key storage, 并避免在日志或错误中泄露 key material.

11.3 Using Matching Algorithm Strengths (匹配算法强度)​

应尽量组合安全强度匹配的 key management algorithm 和 content encryption algorithm. 如果二者强度不同, 有效安全性由较弱者决定.

11.4 Adaptive Chosen-Ciphertext Attacks (自适应选择密文攻击)​

解密实现不能成为 oracle. 例如攻击者可能篡改 alg 从 RSA-OAEP 到 RSA1_5, 试图通过格式错误恢复 CEK. 实现应把 formatting error, CEK error, AAD error 和 ciphertext/tag error 作为统一失败报告, 并限制 key 只能用于允许的 algorithm set.

11.5 Timing Attacks (计时攻击)​

Recipient MUST NOT 区分 encrypted key 的 format, padding 和 length error. 强烈建议在收到 malformed key 时替换为随机生成的 CEK 并继续后续步骤, 以降低 timing attack 风险.