Reading a SAML Response Step by Step (Debugging Guide)

When an enterprise SSO login fails, the error your SAML library prints is usually a summary: “invalid signature,” “assertion expired,” “audience mismatch.” The real answer is sitting in the SAML response the IdP posted to your ACS endpoint, and reading it takes about five minutes once you know the order. This guide shows how to capture and decode a SAML response, then walks through it element by element in the same order a service provider validates it, with what each field must contain according to the SAML 2.0 specifications and what it looks like when it is wrong. Keep it open the next time a customer’s Okta, Entra ID or ADFS login breaks.
Key Takeaways
- A SAML response sent over HTTP-POST is plain base64 of XML. Decode it with
base64 -dand format it withxmllint; only AuthnRequests sent over HTTP-Redirect are also DEFLATE-compressed.- Read it in validation order:
Status,Issuer, signature,SubjectandSubjectConfirmationData,Conditions,AuthnStatement, then attributes. The first element that fails is your bug.- The SAML Web Browser SSO profile requires assertions to be signed when the response is delivered by HTTP-POST, and requires the SP to reject replayed assertion IDs.
- Most failures come from five fields: the signing certificate,
Recipient,Audience,NotOnOrAfterwith clock skew, andInResponseTo.
Step 0: Capture the SAML response
The IdP returns the response through the user’s browser as a form POST to your Assertion Consumer Service (ACS) URL, in a field named SAMLResponse. Three ways to get it:
- Browser devtools. Open the Network tab, enable “Preserve log,” sign in, and find the POST to your ACS URL. Copy the
SAMLResponsevalue from the request payload. - A SAML tracer extension. Browser add-ons that log SAML traffic decode it for you, which is the fastest option during a live session with a customer’s admin.
- Your own logs. Log the raw
SAMLResponseat debug level in non-production environments only. It contains personal data and, until it expires, a bearer credential.
Treat a captured response like a password until its NotOnOrAfter has passed. Do not paste production responses into online decoders.
Step 1: Decode it
Per the SAML 2.0 Bindings specification, the HTTP-POST binding base64-encodes the XML message. If you copied the value from a raw request body, it may also be URL-encoded. On macOS or Linux:
# Save the value to a file first, then:
python3 -c "import sys, urllib.parse; print(urllib.parse.unquote(sys.stdin.read().strip()))"
< samlresponse.txt | base64 -d | xmllint --format - > response.xml
The AuthnRequest your app sends with the HTTP-Redirect binding is different: it is DEFLATE-compressed before base64 and URL encoding. To read one:
python3 -c 'import sys, zlib, base64, urllib.parse
print(zlib.decompress(base64.b64decode(urllib.parse.unquote(sys.argv[1])), -15).decode())' "$SAMLRequest"
If xmllint reports that the document is not well-formed, you probably truncated the value when copying, or decoded a URL-encoded string without unquoting it first.
If the response contains <saml:EncryptedAssertion> instead of <saml:Assertion>, the IdP encrypted it with your SP certificate and you will need your private key to see the contents. Your SAML library’s debug mode is the safest place to do that. The trade-offs are covered in encrypted SAML assertions: when and what they cost.
A response, annotated
Here is a trimmed response with the parts that matter. Numbers in comments match the steps below.
<samlp:Response xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
ID="_r1a2b3" Version="2.0" IssueInstant="2026-12-03T14:02:11Z"
Destination="https://auth.yourapp.com/saml/acme/acs"
InResponseTo="_req9f8e7"> <!-- 2 -->
<saml:Issuer>http://www.okta.com/exk1abc</saml:Issuer> <!-- 3 -->
<samlp:Status>
<samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/> <!-- 2 -->
</samlp:Status>
<saml:Assertion ID="_a4d5e6" Version="2.0" IssueInstant="2026-12-03T14:02:11Z">
<saml:Issuer>http://www.okta.com/exk1abc</saml:Issuer> <!-- 3 -->
<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">...</ds:Signature> <!-- 4 -->
<saml:Subject>
<saml:NameID Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent">00u1xyz</saml:NameID> <!-- 5 -->
<saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
<saml:SubjectConfirmationData NotOnOrAfter="2026-12-03T14:07:11Z"
Recipient="https://auth.yourapp.com/saml/acme/acs"
InResponseTo="_req9f8e7"/> <!-- 5 -->
</saml:SubjectConfirmation>
</saml:Subject>
<saml:Conditions NotBefore="2026-12-03T13:57:11Z" NotOnOrAfter="2026-12-03T14:07:11Z"> <!-- 6 -->
<saml:AudienceRestriction>
<saml:Audience>https://auth.yourapp.com/saml/acme</saml:Audience>
</saml:AudienceRestriction>
</saml:Conditions>
<saml:AuthnStatement AuthnInstant="2026-12-03T14:02:09Z" SessionIndex="_s123"
SessionNotOnOrAfter="2026-12-03T22:02:09Z"> <!-- 7 -->
<saml:AuthnContext>
<saml:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml:AuthnContextClassRef>
</saml:AuthnContext>
</saml:AuthnStatement>
<saml:AttributeStatement> <!-- 8 -->
<saml:Attribute Name="email"><saml:AttributeValue>[email protected]</saml:AttributeValue></saml:Attribute>
<saml:Attribute Name="groups">
<saml:AttributeValue>Engineering</saml:AttributeValue>
<saml:AttributeValue>Admins</saml:AttributeValue>
</saml:Attribute>
</saml:AttributeStatement>
</saml:Assertion>
</samlp:Response>
Step 2: Check the Status and the Response envelope
Start at the top. If StatusCode is not urn:oasis:names:tc:SAML:2.0:status:Success, stop reading: the IdP is telling you it refused. The SAML Web Browser SSO profile says that when the IdP returns an error, it “MUST NOT include any assertions.”
The top-level code says who is at fault (Requester means your request, Responder means the IdP). A nested second-level StatusCode usually says why. Common ones, defined in SAML 2.0 Core:
InvalidNameIDPolicy: your AuthnRequest asked for a NameID format the IdP will not issue. See the InvalidNameIDPolicy fixes.RequestDenied: the IdP refused, often because the user is not assigned to the app.NoPassive: you sentIsPassive="true"and the user had no session.AuthnFailed: the user did not authenticate.
On the Response element itself, check Destination. It should equal the ACS URL that received the POST. A mismatch usually means the IdP has the wrong ACS URL configured, or your app sits behind a proxy that changes the scheme or host it sees.
Step 3: Check the Issuer
The profile says each assertion’s Issuer “MUST contain the unique identifier of the issuing identity provider.” Compare it, character for character, with the IdP entity ID you stored for this customer. Trailing slashes, http versus https, and Entra’s tenant-specific issuer (https://sts.windows.net/<tenant-id>/) are the usual differences.
Then use that issuer to select the connection and its certificate. Never pick the certificate based on anything the IdP could change after the fact, and never fall back to “try every certificate we have.” That turns one compromised customer IdP into access to every tenant.
Step 4: Check the signature
The profile is strict here: “If the HTTP POST binding is used to deliver the <Response>, the enclosed assertion(s) MUST be signed.” Many IdPs sign only the outer Response by default, and many SP libraries accept that. If your library demands a signed assertion, ask the customer to enable assertion signing (in Okta and JumpCloud it is a setting on the app).
What to look at inside <ds:Signature>:
<ds:Reference URI="#_a4d5e6">must point at the ID of the element the signature sits in. If the reference points elsewhere, you may be looking at a signature-wrapping attempt.SignatureMethodandDigestMethodshould be SHA-256 (rsa-sha256,xmlenc#sha256). SHA-1 still appears from older IdP configurations.<ds:X509Certificate>is the certificate the IdP says it used. Do not trust it on its own; compare it with the certificate you stored from the customer’s metadata.
To inspect the embedded certificate:
{
echo "-----BEGIN CERTIFICATE-----"
xmllint --xpath 'string(//*[local-name()="X509Certificate"])' response.xml | tr -d ' n' | fold -w 64
echo
echo "-----END CERTIFICATE-----"
} > embedded.pem
openssl x509 -in embedded.pem -noout -subject -enddate -fingerprint -sha256
If the fingerprint differs from the one you stored, the customer rotated their signing certificate. That is the most common cause of a sudden “signature validation failed” across every user of one tenant. The nine fixes for signature validation failures and the deeper post on XML canonicalization issues cover the rest.
To verify the signature yourself with the stored certificate, xmlsec1 works. The exact flags vary by version, so check xmlsec1 --help:
xmlsec1 --verify --pubkey-cert-pem stored-idp-cert.pem
--id-attr:ID urn:oasis:names:tc:SAML:2.0:assertion:Assertion response.xml
Signature handling is where most SAML library vulnerabilities live. The 2026 SAML CVE wave post lists checks worth running against your own stack.
Step 5: Check the Subject and SubjectConfirmationData
The NameID is who the user is. Check its Format and value against what your app keys users on. A transient format gives a different value at every login, which breaks any app that expects to find the same user again. An emailAddress format will break when the person’s email changes.
Then check the bearer SubjectConfirmationData. The profile’s processing rules require the SP to verify:
Recipient“matches the assertion consumer service URL to which the<Response>or artifact was delivered.”NotOnOrAfter“has not passed, subject to allowable clock skew between the providers.”InResponseTo“equals the ID of its original<AuthnRequest>message, unless the response is unsolicited,” in which case it must not be present.
InResponseTo failures are the confusing ones. They happen when the user opens two login tabs, when your app stores the request ID in a session cookie that the browser drops on the cross-site POST (check SameSite), or when the user starts from the IdP’s dashboard, which produces an unsolicited response with no InResponseTo. If you accept IdP-initiated logins, handle that case explicitly rather than turning off the check.
The same section requires the SP to prevent replay “by maintaining the set of used ID values” for as long as the assertion would be valid. Store each assertion ID until its NotOnOrAfter and reject repeats.
Step 6: Check the Conditions
NotBefore and NotOnOrAfter on Conditions bound the assertion’s validity. If logins fail only for some users, or only right after a server deploy, compare the timestamps with your server clock. Allow a small skew, a few minutes at most, and make sure your servers run NTP.
AudienceRestriction must include your SP entity ID for this connection. The profile requires the IdP to include “the service provider’s unique identifier as an <Audience>.” An audience mismatch almost always means the customer pasted the wrong SP entity ID, or your app uses a different entity ID per environment. The audience restriction errors guide goes through the variants.
Step 7: Check the AuthnStatement
The AuthnStatement says when and how the user authenticated:
AuthnInstantis when the user actually signed in at the IdP, which can be hours before the response if they had an existing session. If you require recent authentication for sensitive actions, check it.SessionIndexidentifies the IdP session. The profile requires it when the IdP supports Single Logout. Store it if you implement SLO.SessionNotOnOrAfter, if present, is when the IdP wants your session to end. The profile says the SP “SHOULD” discard the security context once it passes.AuthnContextClassRefdescribes the method, for examplePasswordProtectedTransport. Values for MFA vary by IdP, so do not hard-code one without agreeing it with the customer.
Step 8: Read the attributes
Finally, the AttributeStatement. Check that every attribute your app requires is present and uses the exact Name your mapping expects. Attribute names are case-sensitive, and IdPs differ in style: Entra ID sends long URI names such as http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress, while Okta and JumpCloud often send short names that the admin chose.
For multi-valued attributes such as groups, each value is a separate AttributeValue. If your code reads only the first one, users get a subset of their roles. If a large group list is missing entirely, the IdP may have hit a limit and sent a reference instead. Microsoft documents a groups overage at 150 groups for SAML tokens.
Build a repeatable check
Once you have done this by hand a few times, script the steps above so support can run them on a decoded response: print status codes, issuer, certificate fingerprint and expiry, NameID and format, Recipient, Audience, all timestamps against current UTC time, and attribute names. Most tickets are answered by that one printout.
To test your own SP against a controllable IdP before involving a customer, the SSOJet SAML tester simulates a SAML 2.0 identity provider you can point your app at. If you would rather not maintain per-customer SAML parsing at all, SSOJet runs enterprise SAML and OIDC connections alongside your existing auth and hands your app a normalized profile; the SAML troubleshooting docs list the errors it surfaces. For background on what an assertion is before you debug one, see what a SAML assertion is in SSO.
Sources
- Profiles for the OASIS Security Assertion Markup Language (SAML) V2.0, OASIS, 15 March 2005. https://docs.oasis-open.org/security/saml/v2.0/saml-profiles-2.0-os.pdf (retrieved 2026-10-20)
- Assertions and Protocols for the OASIS SAML V2.0 (SAML Core), OASIS. https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf (retrieved 2026-10-20)
- Bindings for the OASIS SAML V2.0, OASIS. https://docs.oasis-open.org/security/saml/v2.0/saml-bindings-2.0-os.pdf (retrieved 2026-10-20)
- ID token claims reference (groups overage limits), Microsoft identity platform. https://learn.microsoft.com/en-us/entra/identity-platform/id-token-claims-reference (retrieved 2026-10-20)
- xmlsec1 command-line tool, XML Security Library. https://www.aleksey.com/xmlsec/xmlsec-man.html (retrieved 2026-10-20)
Frequently Asked Questions
How do I decode a SAML response?
Copy the SAMLResponse form value from the POST to your ACS URL, URL-decode it if needed, then base64-decode it. On macOS or Linux, base64 -d | xmllint --format - gives readable XML. Responses sent with the HTTP-POST binding are not compressed; only HTTP-Redirect messages such as AuthnRequests are DEFLATE-compressed.
What should I check first in a SAML response?
Check the StatusCode. If it is not Success, the IdP refused the login, and the nested status code usually says why. If it is Success, check the issuer, then the signature against the certificate you stored, then Recipient, NotOnOrAfter, InResponseTo and the audience.
Why does my SAML response fail with InResponseTo errors?
The response’s InResponseTo must match the ID of the AuthnRequest your app sent. It fails when the request ID was lost, often because a session cookie was not sent on the cross-site POST, when the user started two logins, or when the login started at the IdP dashboard and the response is unsolicited.
Must the SAML assertion be signed, or is a signed response enough?
The SAML Web Browser SSO profile says assertions delivered over HTTP-POST must be signed. Many IdPs sign only the outer response by default and many SP libraries accept that, but if your library requires a signed assertion, ask the customer to enable assertion signing in their IdP.
How much clock skew should a SAML service provider allow?
A few minutes at most. The profile allows for clock skew when checking NotOnOrAfter but does not set a number. Larger tolerances extend the window in which a stolen assertion can be replayed, so keep servers on NTP rather than widening the skew.

