XML Signature Wrapping (XSW) is an attack against XML digital signatures where the attacker manipulates the document structure to make the application process unsigned content while signature validation passes on different content.
XML signatures reference specific elements by ID. If an application validates the signature on one element but processes a different element with the same ID (or in an expected location), attackers can inject malicious content.
<Response>
<Signature>
<Reference URI="#original"/> <!-- Validates this -->
</Signature>
<Assertion ID="original">
<Subject>admin@example.com</Subject> <!-- MALICIOUS -->
</Assertion>
<Assertion ID="original"> <!-- Original moved here -->
<Subject>user@example.com</Subject>
</Assertion>
</Response>
<Response>
<MaliciousAssertion>
<Subject>admin@example.com</Subject>
</MaliciousAssertion>
<OriginalWrapper>
<Signature>...</Signature>
<Assertion ID="legit">
<Subject>user@example.com</Subject>
</Assertion>
</OriginalWrapper>
</Response>