Lion Cipher Lab
Forge a SAML assertion with XML Signature Wrapping (XSW) — and stop it
- Identity & Access Management
- Advanced
- ~75 min
- Free · no account required
Why it matters
Single sign-on is the front door to everything, which makes the Service Provider's signature check one of the highest-value targets in an org. SAML's whole security rests on one idea: the SP trusts a user identity because an XML signature over the assertion validates against the Identity Provider's certificate. XML Signature Wrapping breaks that trust without ever breaking the signature. The attacker leaves the original signed assertion completely intact — so the crypto still checks out — and injects a SECOND, unsigned assertion positioned so the application's own lookup…
What you'll learn
- the SAML trust model in concrete terms: IdP, SP, assertion, and a signature that protects one element by Reference URI + ID
- the root cause of XML Signature Wrapping: validation and consumption looking at different XML nodes
- building and enveloped-signing a SAML-style assertion locally with your own throwaway IdP key/cert
- writing a deliberately-naive Service Provider that verifies a signature and then re-queries the tree for the user
- executing a real XSW attack: injecting an unsigned forged assertion the app reads first while the signature still validates
- the fix that generalizes beyond SAML: consume ONLY the exact node the signature covered, and reject anything but one assertion
- why production SPs must use a vetted library (python3-saml / pysaml2), schema-validate, disable XXE, and pin the IdP cert
- the judgment of when to hand-roll nothing, why OIDC is often the safer default, and the true/false-positive limits of your own checks
Steps in this lab
- The SAML trust model, in plain terms
- The bug class: XML Signature Wrapping (XSW)
- Set up your own throwaway IdP (authorized, local, disposable)
- Build and sign a legitimate assertion for alice
- Write the deliberately-naive Service Provider
- The attack: wrap the response and become admin
- The fix: validate and consume the SAME node
- How professionals ship this: don't hand-roll it
- The judgment: why this class is worth remembering