CVE-2026-103604 Bouncy Castle bc-csharp 算法复杂度拒绝服务漏洞
影响远程未认证攻击者可致 CPU 耗尽拒绝服务
Bouncy Castle bc-csharp 在 X.509 可分辨名称字符串转换(X509Name.ToString 与 IetfUtilities.ValueToString)中存在算法复杂度问题。当名称属性值包含大量需转义字符(如逗号)或首尾空格时,转义反斜杠被插入正在扫描的缓冲区,导致处理工作量随值长度呈平方级增长。远程未认证攻击者可通过构造恶意证书、CRL 或认证请求触发 CPU 耗尽,造成拒绝服务。
影响范围
Legion of the Bouncy Castle Inc. bc-csharp 2.7.0 之前的版本。
漏洞详情
漏洞类型为算法复杂度(二次复杂度)导致的拒绝服务。成因是转义处理时把反斜杠写入正在遍历的缓冲区,使每次转义都增加后续扫描量,整体复杂度由线性退化为平方级。利用方式是构造名称属性值含大量逗号或首尾空格的证书、CRL、认证请求等结构,当应用将其转换为字符串(如日志、显示)或通过 IetfUtilities.RdnAreEqual 比较(如 PKIX 路径校验中的 directoryName 名称约束)时触发。
利用条件与风险
利用前提是目标应用会对攻击者可控的 X.509 名称执行字符串转换或 RDN 比较,且无需认证即可投递恶意结构。实战中可造成服务线程长时间占用 CPU、响应变慢甚至不可用,风险等级为中。
修复建议
官方修复方案为升级至 bc-csharp 2.7.0 或更高版本。临时缓解措施包括限制可接受的证书/CRL 大小与名称属性长度、对名称转换操作设置超时或资源限制,并避免对不可信名称直接进行字符串化或 RDN 比较。
Inefficient algorithmic complexity in X.509 distinguished name string conversion (X509Name.ToString and IetfUtilities.ValueToString) in Legion of the Bouncy Castle Inc. bc-csharp before 2.7.0 allows a remote unauthenticated attacker to cause a denial of service through CPU exhaustion via a certificate, CRL, certification request or other structure whose name contains a long attribute value made up of characters that must be escaped, such as commas, or of leading or trailing spaces, because each escaping backslash was inserted into the buffer being scanned, so the work grew quadratically with the length of the value. Applications are exposed when they convert such a name to a string, for example to log or display it, or compare it with IetfUtilities.RdnAreEqual, as PKIX path validation does for directoryName name constraints.