Join our Newsletter — 33% off our NHI Course
Home› Guides› Top 10 SAML and OIDC Implementation Flaws: A…
Top 10 Authentication

Top 10 SAML and OIDC Implementation Flaws: A Ranked Checklist for Code Reviewers

PDF for newsletter subscribers · free to read online

← All guides
By NHI Mgmt Group, under the editorial direction of Lalit Choda Updated 27 November 2026 14 min read
On this page

Most single sign-on breakages are not protocol weaknesses but relying party code that skips one validation step, and SAML and OpenID Connect (OIDC) fail in remarkably similar ways. This list ranks the ten implementation flaws a code reviewer is most likely to find when an application consumes SAML assertions or OIDC ID tokens, from signature handling through to how the user account is finally looked up. Each entry names the flaw in both protocols, what to look for in code or configuration, and the fix. It is written for developers, application security reviewers and penetration testers working on service providers and relying parties, not identity provider operators. For protocol background see the SAML Security Guide and OAuth 2.0 vs OIDC; for authorisation server and token risks see Top 10 OAuth Security Risks.

The Top 10 at a glance

RankFlawSAML formOIDC formTypical impact
1Signature checked on the wrong dataXML signature wrapping, comment truncation, tag-name element lookupClaims read from a token before or without verificationLog in as any user
2Unsigned or downgraded tokens acceptedUnsigned Response or Assertion accepted, SHA-1 allowedalg "none", RSA to HMAC confusion, no algorithm allowlistForged identity
3Trusting keys supplied in the messageCertificate in KeyInfo used for verificationjwk, jku, x5u or kid header followed without allowlistForged identity, SSRF
4Missing audience bindingAudienceRestriction not checkedaud not checked against client_id, azp ignoredToken for another app accepted
5Missing issuer binding and IdP mix-upIssuer not tied to the tenant or connectioniss not matched exactly, no mix-up defenceCross-tenant or cross-IdP login
6Replay and freshness gapsNo InResponseTo, no assertion ID cache, loose time windownonce missing or unchecked, exp and iat skew too wideCaptured token reused
7Missing recipient and destination checksDestination and Recipient not matched to ACS URLHybrid flow c_hash and at_hash not checkedToken or code substitution
8Loose redirect and RelayState handlingRelayState used as an unvalidated URLPattern-matched redirect_uri, open redirect after loginToken or code theft, phishing
9Login CSRF and unsafe flowsIdP-initiated SSO enabled without needNo state or PKCE, implicit flow still in useVictim logged into attacker account
10Identity mapped from mutable claimsEmail attribute or transient NameID used as the keyemail or preferred_username used instead of iss plus subAccount takeover via another IdP or reused address

The ranking weighs how often the flaw appears in reviews against impact: the first three lead directly to authentication bypass with no user interaction, so they come first even where they are less common than redirect mistakes.

1. Signature checked on the wrong data

The signature verifies, but the application reads identity from a different element or a different parse of the message. In SAML this is XML signature wrapping: an attacker moves the signed assertion and adds an unsigned one that the application's lookup finds first. A related class, documented by CERT/CC in VU#475445 (2018), affected several SAML libraries where XML comments inside a NameID caused text after the comment to be dropped by one API and kept by another, so content could be changed without breaking the signature.

  • Look for: getElementsByTagName or relative XPath to find the Assertion or NameID; signature verification and attribute extraction done by different libraries or parsers; schemas fetched from remote locations.
  • Fix: select elements with absolute XPath or use the library's "verified assertion" object only; confirm the signature Reference URI points to the exact Response or Assertion you consume; schema-validate against local, hardened schemas, as the OWASP SAML Security Cheat Sheet advises; keep SAML libraries patched.
  • OIDC equivalent: decoding the JWT payload for routing or logging and later trusting those claims without verification. Verify first, then read claims only from the verified result.

2. Unsigned or downgraded tokens accepted

The relying party accepts a token that is not signed, or is signed with an algorithm it should not allow.

  • SAML: accepting a Response where neither the Response nor the Assertion is signed, or accepting SHA-1 signatures and digests. The OWASP cheat sheet recommends rejecting SHA-1 and requiring at least RSA-SHA256.
  • OIDC: accepting alg "none", or letting the token header choose the algorithm so an RSA public key is used as an HMAC secret. RFC 8725 (JWT Best Current Practices, BCP 225) section 3.1 requires libraries to let callers specify allowed algorithms and to use each key with exactly one algorithm. OIDC Core forbids "none" for ID tokens unless the client explicitly registered for it and receives no ID token from the authorisation endpoint.
  • Look for: verify calls without an algorithm parameter, a shared verification function used for several token types, configuration flags such as "want assertions signed" set to false.
  • Fix: pin the expected algorithm per issuer (the one registered as id_token_signed_response_alg, or RS256 by default), and require signatures on every assertion you consume.

3. Trusting keys supplied in the message

A signature is only meaningful if the verifying key comes from configuration, not from the attacker.

  • SAML: verifying with the X.509 certificate embedded in KeyInfo rather than the pinned IdP certificate from metadata. A self-signed certificate then "verifies" a forged assertion.
  • OIDC: following the jku or x5u header to fetch keys, accepting an embedded jwk, or passing kid unsanitised into a file path or database query. RFC 8725 section 3.10 calls for sanitising kid and allowlisting jku and x5u URLs, which also prevents server-side request forgery.
  • Fix: load keys only from the issuer's configured metadata or JWKS URI, cache them, and refresh on unknown kid from that same trusted URI. Plan key rollover so the pinned set includes the next certificate. See How to rotate a SAML signing certificate in Entra ID without breaking SSO.

Stolen or attacker-added signing keys are a separate, IdP-side problem: see the Golden SAML and Federation Trust Abuse Defence Guide.

4. Missing audience binding

A validly signed token issued to a different application is accepted. Where one IdP signs tokens for many applications with the same key, this turns any low-value app into a source of tokens for high-value ones.

  • SAML: the Audience inside AudienceRestriction must equal your SP entity ID.
  • OIDC: OIDC Core section 3.1.3.7 requires the aud claim to contain the client's client_id and the token to be rejected if it lists audiences the client does not trust; when azp is present the client should check it equals its client_id. OWASP ASVS 5.0 V10.5.4 states the same requirement.
  • Look for: audience checks disabled to "fix" an integration error, or an allowlist containing several client IDs from different applications.

5. Missing issuer binding and IdP mix-up

Multi-tenant and multi-IdP applications must tie each response to the issuer the login started with.

  • SAML: the Issuer must match the IdP configured for this connection or tenant, and the signing key must belong to that IdP. Checking that "some trusted IdP" signed it lets tenant A's IdP log in users of tenant B.
  • OIDC: the iss claim must exactly match the issuer from discovery. Clients using more than one authorisation server need a mix-up defence: RFC 9700 (OAuth 2.0 Security BCP, BCP 240) prefers checking the issuer, via the iss authorisation response parameter from RFC 9207 or the ID token iss claim, with distinct redirect URIs per issuer as a fallback. RFC 9207 states clients must reject a response whose iss does not match the expected issuer.
  • Look for: a single global key set across tenants, issuer compared with "startsWith" or case-insensitively, issuer looked up from the token rather than from the login session. ASVS 5.0 V6.8.1 covers spoofing via another supported IdP.

6. Replay and freshness gaps

  • SAML: check InResponseTo against the request ID stored in the user's session, enforce NotBefore and NotOnOrAfter with small clock skew, and keep a cache of consumed assertion IDs for the validity period. ASVS 5.0 V6.8.3 requires SAML assertions to be processed only once within their validity period.
  • OIDC: send a nonce bound to the session and require the ID token nonce to match (OIDC Core 3.1.3.7; ASVS 5.0 V10.5.1); reject expired tokens and set a client-specific iat window; check auth_time when you sent max_age.
  • Look for: nonce generated but never compared, clock skew set to hours, assertion ID caches that are per-node in a load-balanced cluster.

7. Missing recipient and destination checks

  • SAML: the Response Destination must exactly match your Assertion Consumer Service URL, and the SubjectConfirmationData Recipient must match too; reject when either is missing or different. Without these, an assertion captured at one SP of the same IdP may be replayed at another.
  • OIDC: in the hybrid flow, validate c_hash against the authorisation code and at_hash against any access token returned from the authorisation endpoint, which binds them to the ID token and stops substitution.
  • Look for: ACS URLs compared after normalisation that strips paths or ports; hybrid response types enabled with no hash checks.

8. Loose redirect and RelayState handling

  • OIDC and OAuth: RFC 9700 says authorisation servers should compare redirect URIs by exact string match (with a port exception for native app localhost redirects), and ASVS 5.0 V10.4.1 requires a client-specific allowlist with exact comparison. On the relying party, the post-login return URL must not be an open redirect that leaks codes or tokens via the Referer or fragment.
  • SAML: RelayState that carries a URL must be validated against an allowlist, as the OWASP cheat sheet advises, or replaced with an opaque key to server-side state.
  • Look for: wildcard or prefix redirect patterns, a "returnUrl" parameter passed straight to a redirect. See the Open Redirect Guide.

9. Login CSRF and unsafe flows

  • OIDC: use the authorisation code flow with PKCE (S256), and a state value bound to the browser session; RFC 9700 recommends PKCE for confidential clients too and says clients should not use the implicit grant. If the server does not support PKCE, state or nonce must provide CSRF protection. See Client Secret vs PKCE.
  • SAML: IdP-initiated SSO has no request to correlate, so it lacks login CSRF protection. Disable it unless a business need exists, and then apply the extra checks in the SAML 2.0 Profiles specification section 4.1.5 that the OWASP cheat sheet points to.
  • Look for: state that is static, predictable or not compared; response_type values containing "token" in new code.

10. Identity mapped from mutable claims

Validation can be perfect and the application still log the wrong person in if it keys accounts on a value that can change or be asserted by another IdP.

  • OIDC: OIDC Core defines sub as locally unique and never reassigned within the issuer, so iss plus sub identifies the user. ASVS 5.0 V10.5.2 requires the client to identify the user from a claim that cannot be reassigned, usually sub. Matching on email lets anyone who can get an IdP to assert that address, or who later receives a recycled address, take over the account.
  • SAML: use a persistent NameID or an immutable attribute agreed with the IdP, scoped to the issuer; never a transient NameID or display name.
  • Look for: account linking by email across IdPs without re-authentication, user tables with email as primary key, just-in-time provisioning that merges into existing accounts.

Mapping to OWASP

FlawOWASP ASVS 5.0 requirementOther OWASP source
1. Signature on wrong dataV6.8.2 (signature presence and integrity), V9.1.1SAML Security Cheat Sheet (XSW, absolute XPath, local schemas)
2. Unsigned or downgradedV6.8.2, V9.1.2 (algorithm allowlist)SAML Security Cheat Sheet (reject SHA-1)
3. Keys from the messageV9.1.3 (trusted pre-configured key sources)SAML Security Cheat Sheet (pinned IdP certificates)
4. AudienceV10.5.4, V9.2.3SAML Security Cheat Sheet (Audience)
5. Issuer and mix-upV6.8.1, V10.2.2, V10.5.3Covered by ASVS requirements
6. Replay and freshnessV6.8.3, V10.5.1, V9.2.1SAML Security Cheat Sheet (InResponseTo, time window)
7. Recipient and destinationV9.2.2 (correct type and purpose)SAML Security Cheat Sheet (Destination, Recipient)
8. Redirect and RelayStateV10.4.1SAML Security Cheat Sheet (RelayState allowlist)
9. Login CSRF and flowsV10.2.1, V10.4.4, V10.4.6SAML Security Cheat Sheet (IdP-initiated SSO)
10. Mutable identity claimsV10.5.2Covered by ASVS requirements

In the OWASP Top 10 these flaws sit under identification and authentication failures; on APIs that accept ID tokens directly, see the OWASP API Top 10 API2 Broken Authentication Guide.

Testing and detection

Test caseExpected resultCovers
Modify a claim or NameID after signingRejected1, 2
Strip the signature, or change alg to none or HS256Rejected2
Sign with a key not in configuration and embed itRejected3
Valid token issued to another app of the same IdPRejected4
Valid token from a second trusted IdP or tenantRejected for this connection5
Replay a consumed assertion or ID token; wrong or missing nonceRejected6
Assertion with a different Destination or RecipientRejected7
Off-allowlist redirect_uri or RelayStateRejected, no redirect8
Response without matching state, or unsolicited SAML responseRejected9
Second IdP asserting an existing user's emailNo access to existing account10

Run these as automated negative tests in CI against the relying party, using test IdPs and test keys only. In production, log every rejection with the reason (signature, audience, issuer, replay, destination) and alert when a single reason spikes or when a new issuer or signing certificate appears. Useful measures: share of relying parties with the full negative test suite passing; count of applications still using implicit or IdP-initiated flows; count keyed on email rather than iss plus sub; median days to patch SAML and JWT libraries after an advisory.

Where to start

  1. Inventory relying parties and record for each: protocol, library and version, flows enabled, and the claim used as the account key.
  2. Patch libraries first: many entries above have historically appeared as library bugs, so current versions remove a large share of the risk.
  3. Review entries 1 to 3 in code for every service provider and relying party, since they allow login as anyone.
  4. Add the negative test table to CI so regressions fail the build.
  5. Disable unneeded flows: implicit grant, IdP-initiated SSO, unsigned assertions and SHA-1.
  6. Migrate account keys from email to issuer plus subject, with a one-off linking step that re-authenticates the user.

Practitioner checklist

  • Read identity only from the verified assertion or token object.
  • Pin algorithms and keys per issuer; ignore KeyInfo, jwk, jku and x5u from the message.
  • Check audience, issuer, destination and recipient exactly, per connection.
  • Enforce nonce, InResponseTo, assertion ID replay caches and tight time windows.
  • Use exact redirect URI matching and allowlist any RelayState URL.
  • Use code flow with PKCE and state; turn off implicit and unneeded IdP-initiated SSO.
  • Key accounts on iss plus sub or a persistent NameID, never on email.
  • Run the negative test suite in CI and alert on rejection spikes.

Standards and references

Related NHI Mgmt Group resources: SAML Security Guide · Top 10 OAuth Security Risks · JWT Security Guide · OAuth 2.0 Security Best Current Practice (RFC 9700) Guide

PDF for subscribers

Take this guide with you

Every section, table and checklist in one PDF, with links to the sources and related guides. Subscribe to our weekly NHI & AI Identity Journal and we’ll email you a download link.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

PDF Downloads for Newsletter Subscribers

Get the guide

Enter your details and we’ll email you a download link.

The full guide is free to read online. The PDF is a thank you for subscribing.

Fill in all fields marked * and tick both boxes to continue.