SAML security: signature validation, XML wrapping, and Golden SAML

SAML single sign-on depends on the service provider validating signed XML assertions correctly. How signature wrapping and comment-injection bugs bypassed validation, what Golden SAML means for identity provider signing keys, and how to review an integration.

Lesson 7 of 10 · 12 min read · practice only with authorization

Diagram

What a service provider must check

Follow the path. One example at a time.

Step 1 of 4

Response

The identity provider posts a signed assertion through the browser.

Illustration: Response
<saml:Assertion ID="_a7f3" IssueInstant="2026-11-03T10:02:11Z">
  <saml:Issuer>https://idp.example.test</saml:Issuer>
  <ds:Signature>...</ds:Signature>
  <saml:Subject><saml:NameID>ana@example.test</saml:NameID></saml:Subject>
  <saml:Conditions NotOnOrAfter="2026-11-03T10:07:11Z"><saml:AudienceRestriction><saml:Audience>https://app.example.test</saml:Audience></saml:AudienceRestriction></saml:Conditions>
</saml:Assertion>

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Signature wrapping

    What fails
    A signed element is moved and an unsigned one is read instead.
    Who is affected
    Every account on the service provider.
    What you would notice
    Custom code that finds NameID with a generic XPath.
    What you change
    Use a maintained library and read identity from the verified node.
  2. Parser differences

    What fails
    In 2018, comment handling in several libraries let NameID be truncated.
    Who is affected
    Users of affected libraries.
    What you would notice
    Old versions of SAML libraries.
    What you change
    Keep SAML libraries patched.
  3. Golden SAML

    What fails
    With the IdP’s token-signing key, an attacker can forge assertions for any user.
    Who is affected
    Every federated application.
    What you would notice
    Exports of AD FS token-signing certificates or unusual key access.
    What you change
    Protect signing keys in HSMs, monitor access, and rotate after compromise.

Seen in the wild

Golden SAML was described by CyberArk in 2017 and used in the 2020 SolarWinds-related intrusions, where attackers took AD FS signing material. Microsoft’s guidance since then is to move federation to Entra ID where possible, and to watch for token-signing certificate changes.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

What does an XML signature wrapping attack exploit?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

  1. MapCryptography basics: hashes, symmetric and public-key encryption, and signaturesThe four primitives security work depends on, what each guarantees, and the common mistakes: encoding mistaken for encryption, fast hashes for passwords, and encryption without integrity.

Practice

  1. LabControl benchA failure is described. Choose the control that changes the outcome.