# SAML XML 签名包装攻击：攻击者注入绕过签名验证的恶意断言

- **ID:** `security/saml-xml-signature-wrapping-bypass`
- **领域:** security
- **类别:** protocol_error
- **错误码:** `SAML_SIGNATURE_WRAPPING`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

SAML 响应解析器验证原始断言的签名，但处理通过 XML 包装（例如使用 ID 重复或 SOAP 信封操作）注入的未签名断言，从而允许攻击者控制的属性。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| OpenSAML 4.3.0 | active | — | — |
| Shibboleth IdP 4.3.0 | active | — | — |
| SimpleSAMLphp 1.19.0 | active | — | — |
| Microsoft AD FS 2019 | active | — | — |
| Okta SAML 1.0.0 | active | — | — |

## 解决方案

1. ```
   Enforce strict assertion ID uniqueness and reject responses with duplicate IDs. Example in Java using OpenSAML: set `strictValidation=true` and configure `IdAttributeResolver` to check for duplicates.
   ```
2. ```
   Use a whitelist of allowed assertion IDs or require that the signed assertion is the only one processed, ignoring any wrapped content.
   ```

## 无效尝试

- **** — Attackers can place the malicious assertion before the signed one; parser may process the first unsigned assertion. (85% 失败率)
- **** — Wrapping attacks use well-formed XML that passes schema validation; the attack is structural, not syntactic. (75% 失败率)
- **** — Attackers can sign the malicious assertion with a stolen or self-signed certificate if the trust store is misconfigured. (80% 失败率)
