Reading a SAML XML signature's structure
Trust in a SAML response starts with the XML signature. But 'signed' and 'valid' are different statements. This article is not about verifying a signature; it is about reading the signature element's structure to see what was signed.
A signature can sit in two places
Response/ds:Signaturesigns the whole response, status and assertion included.Assertion/ds:Signaturesigns one assertion. Even when the response is unsigned, a signed assertion protects the identity data.- Both can be present, and then they carry different References.
Which one is signed decides what the SP verifies and with which key. Check the placement first when reading a log.
Structure of an enveloped signature
ds:Signature → SignedInfo → (CanonicalizationMethod, SignatureMethod, Reference* → (Transforms, DigestMethod, DigestValue)), SignatureValue, KeyInfo
| Element | What to check | Common problem |
|---|---|---|
| CanonicalizationMethod | whether exc-c14n is used | signer and verifier disagree on C14N |
| SignatureMethod | rsa-sha256, ecdsa-sha256 and so on | rsa-sha1 in use |
| DigestMethod | sha256, sha384 | sha1 |
| Reference/@URI | whether #ID matches the signed target | confusing #_abc with #abc |
| Transforms | enveloped-signature and exc-c14n present | missing transform |
What the Reference URI points at
The URI of Reference points at the ID of the signed element. In SAML it is # followed by the Response or Assertion ID. If it does not match the actual ID, verification fails with 'target not found'. A related failure is an XML parser that does not treat the ID attribute as an ID type.
This tool compares the Reference URI with the actual ID as a string and reports a match. It does not check ID-type declarations or schema validation.
SHA-1 and weak algorithms
Since the 2010s most SAML implementations use rsa-sha256. A leftover rsa-sha1 signature points to an old IdP configuration or a compatibility option. It carries a real risk of signature forgery and should be moved to SHA-256 or stronger where possible. samlview marks a SHA-1 SignatureMethod or DigestMethod as a warning.
The embedded X.509 certificate
KeyInfo/ds:X509Certificate holds the signing certificate in Base64. This tool decodes the DER and shows the subject, issuer, validity and serial number. It does not check whether that certificate matches the one in the IdP metadata or whether the chain is trusted; that belongs to the SP's validation.
- Check by eye that the subject matches the IdP's domain.
- Look at whether the certificate's validity has passed.
- If it is self-signed, compare its key with the metadata separately.
In short, a structure check tells you quickly what was signed, and cryptographic verification decides whether the signature is correct. Confusing the two lets expired keys or wrong References slip through.
Frequently asked questions
Is a signature always safe?
No. If it targets the wrong element, uses a weak algorithm or a certificate nobody trusts, it means little. Look at both structure and verification.
What if the Reference URI has no #?
In XML Signature a same-document identifier uses #. Without it the value may be read as an external URI, which deserves attention.
Does this tool verify the signature?
No. It inspects structure. Verification belongs to the SP's SAML library or a dedicated verifier.
Load the SHA-1 sample and see which warnings appear.
Open the toolThis article follows OASIS SAML 2.0 Core (2005), SAML 2.0 Bindings, SAML 2.0 Profiles, XML Signature 1.1 and RFC 1951 (DEFLATE). Every example is synthetic data.