SAML Message Validation
What you'll learn: How to properly validate SAML messages to prevent authentication bypass and privilege escalation attacks.
The Core Idea
When your application receives a SAML assertion (the signed XML document that says "this user is authenticated"), you can't just trust it at face value. SAML message validation is the critical process of thoroughly checking every security property of incoming SAML responses before granting access. Think of it like a bank teller carefully verifying multiple security features on a check before cashing it—signature, date, amount, and payee must all be correct.
What Must Be Validated
Signature Verification
The XML signature on the assertion and/or response must be cryptographically valid using the Identity Provider's public certificate. This proves the message actually came from your trusted IdP and hasn't been tampered with (remember XML Signature Wrapping from lesson 779).
Certificate Trust
Verify the signing certificate is:
- Issued by a trusted Certificate Authority
- Not expired or revoked
- Matches the expected IdP certificate
Audience Restrictions
The assertion's Audience element must contain your application's entity ID. This prevents an attacker from reusing an assertion meant for a different application.
Assertion Conditions
- NotBefore/NotOnOrAfter: Ensure the assertion is being used within its valid time window
- SubjectConfirmation: Verify the recipient URL matches your Assertion Consumer Service URL
- OneTimeUse: Check if the assertion has already been processed (prevents replay attacks from lesson 780)
Issuer Validation
Confirm the Issuer element matches your expected Identity Provider's entity ID.
Key Takeaway: SAML message validation requires checking signatures, certificates, audience restrictions, time windows, and assertion uniqueness—skipping any step creates exploitable authentication bypass vulnerabilities.