Harden SAML 2.0 service provider against XML signature wrapping and related attacks

domain: cheatsheetseries.owasp.org · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Validate the XML schema of the SAML Response before any signature verification; reject documents that fail schema validation — do not pass malformed XML to the signature verifier
  2. Verify that the Signature element's Reference URI points to the Assertion being validated; check that the ID attribute of the validated element matches the Reference URI exactly, and that only one Assertion is signed
  3. Use a StaticKeySelector seeded with the IdP's certificate (fetched via metadata and pinned locally) rather than trusting KeyInfo in the received document — an attacker can inject a KeyInfo with their own key
  4. After signature verification, extract data from the same element node that was verified — many vulnerabilities arise from verifying one node and reading data from a different node injected by the attacker
  5. Enable ForceAuthn and validate AuthnInstant recency to prevent replay attacks; maintain a used-assertion cache indexed by the Assertion ID to detect duplicate submissions
  6. Keep the SAML library dependency current; CVE-2025-47949 (samlify < 2.10.0) and Ruby-SAML CVEs (CVE-2025-66568/66567 in versions prior to 1.18.0) are active signature wrapping vulnerabilities from 2025

Known gotchas

Related routes

Integrate a SAML 2.0 service provider with an identity provider
docs.oasis-open.org · 6 steps · unrated
Implement SAML 2.0 SP-initiated SSO for an edtech tool integrating with a university's Shibboleth IdP, including attribute mapping and FERPA-compliant attribute release
shibboleth.net · 6 steps · unrated
Handle SP-initiated vs IdP-initiated SAML flows and RelayState pitfalls
identity-general · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans