XML Signature Wrapping Attacks
What you'll learn: How attackers exploit weak XML signature validation to forge or modify SAML assertions.
The Core Problem
In SAML authentication (which we just learned uses XML-based assertions and claims), the Service Provider verifies the Identity Provider's signature to ensure assertions haven't been tampered with. However, XML's flexibility creates a dangerous vulnerability: attackers can manipulate the structure of a signed XML document without invalidating the signature itself.
Think of it like a signed letter in an envelope. The signature proves the letter is authentic, but if someone can add extra pages around the signed letter while keeping the original intact, a careless reader might trust the forged pages instead.
How the Attack Works
When a SAML assertion is signed, the signature references specific elements by their ID. An attacker intercepts the legitimate, signed assertion and:
- Copies the original signed assertion to keep the signature valid
- Wraps or injects a modified assertion elsewhere in the XML structure
- Manipulates IDs so the application processes the forged assertion while the signature validator checks the original
The signature validation passes (the original is still there, untouched), but the application reads the attacker's modified version — perhaps elevating privileges, changing the username, or extending session validity.
Real-World Impact
This attack can completely bypass SAML authentication security. An attacker might transform a low-privilege user assertion into an administrator account, granting unauthorized access to critical systems.
Prevention
Secure implementations must validate that the exact element being processed is the same element that was signed — not just that some signed element exists in the document.
Key Takeaway: XML Signature Wrapping exploits the gap between signature validation and document processing, allowing attackers to inject malicious content into legitimately signed SAML assertions by manipulating XML structure.