CVE-2026-71887 Bouncy Castle OpenPGP 签名验证绕过漏洞
影响攻击者可利用缺失交叉认证的签名子密钥伪造签名归属
Bouncy Castle for Java 1.86 之前版本的高层 OpenPGP API 在处理签名子密钥时存在逻辑不一致。当子密钥绑定签名缺少 Key Flags 子包时,isSigningKey() 会回退继承主密钥的 SIGN_DATA 标志,将子密钥判定为可签名;而 verifyEmbeddedPrimaryKeyBinding() 读取绑定签名自身的子包,未发现 SIGN_DATA 便提前返回,未强制要求内嵌的主密钥绑定(交叉认证)签名。
影响范围
Bouncy Castle for Java 1.86 之前的版本,具体受影响版本范围暂无公开信息。
漏洞详情
该漏洞属于签名验证绕过。RFC 9580 要求任何可签发签名的子密钥,其绑定签名中必须内嵌主密钥绑定(交叉认证)签名,以证明该子密钥确实属于其绑定的主密钥。由于代码中两处对子密钥密钥标志的解析路径不一致,导致缺少交叉认证的子密钥仍被当作可签名密钥,其签名被归属到证书及 OpenPGPSignature。
利用条件与风险
利用前提是攻击者能构造或提供缺少 Key Flags 子包且无内嵌交叉认证签名的签名子密钥。实战中可能导致签名归属被错误信任,破坏 OpenPGP 证书的信任模型。
修复建议
建议升级至 Bouncy Castle for Java 1.86 或更高版本。临时缓解措施暂无公开信息。
In Bouncy Castle for Java before 1.86, the high-level OpenPGP API accepted a data signature made by a signing subkey whose Subkey Binding signature carried no embedded Primary Key Binding (cross-certification) signature, in the case where that binding omits a Key Flags subpacket. RFC 9580 sec. 5.2.1.8 and sec. 10.1.3 require the embedded Primary Key Binding signature on any subkey that can issue signatures; it is the subkey’s own statement that it belongs to the primary key it is bound under. OpenPGPCertificate resolved the subkey’s key flags two different ways. isSigningKey() goes through getKeyFlags() and getApplyingSubpacket(), which falls back to the primary key’s direct-key or primary User ID self-signature when the binding signature omits the subpacket, so the subkey inherited the primary’s SIGN_DATA and counted as signing-capable; verifyEmbeddedPrimaryKeyBinding(), which enforces the requirement, reads the binding signature’s own hashed subpackets, found no SIGN_DATA there, and returned early as a non-signing key without ever demanding the back signature. The same subkey was therefore signing-capable – so its signatures were attributed to the certificate and OpenPGPSignature.OpenPGPDocumentSignature.isValid() returned true – while being exempt from cross-certification, where GnuPG refuses the identical certificate and message. An attacker needs only the victim’s public signing subkey, which is public material: they bind it to their own primary key with a Subkey Binding signature they are able to make, carrying no Key Flags and no embedded Primary Key Binding signature, which they cannot make without the subkey’s private key, and a relying party verifying one of the victim’s genuinely signed messages against that certificate is told the signature is valid and given the attacker’s certificate as its issuer. Because a certificate’s User IDs are self-asserted, a verifier that pins on the subkey’s fingerprint or key ID while taking the identity from the enclosing certificate reports a real signature under an attacker-chosen identity. This is misattribution of a genuine signature rather than forgery of a new one: no private key is recovered, and the signature must be one the grafted subkey actually made. The low-level PGPSignature / PGPPublicKeyRing API performs no binding checks by design and is unaffected. Key Flags are a statement about the key the carrying signature refers to (RFC 9580 sec. 5.2.3.29), so a subkey no longer inherits them from the certificate-wide signatures of the primary key: a Subkey Binding signature that omits the subpacket now leaves the subkey with no capabilities rather than the primary’s, which makes the flags the cross-certification check consults the same flags every other decision consults. Preferences and the other subpackets a direct-key signature carries are inherited as before, and the primary key itself, whose flags legitimately come from its own direct-key or User ID self-signature, is unaffected.