WSTG - Latest

OpenID Connect Relying Party

ID
WSTG-ATHN-14

Summary

OpenID Connect (OIDC) layers identity on top of OAuth 2.0. An OAuth client that accepts an ID Token, UserInfo claims, or a social-login assertion to create or recover a local session is an OpenID Connect relying party (RP), not only an OAuth client.

OAuth chapters in this guide cover delegated authorization: grant types, PKCE, redirect URIs, and token leakage. They do not provide a procedure for authenticating a user from an ID Token. Failures in relying-party validation lead to account takeover, account linking to the wrong local user, and login with unverified identity claims.

This scenario evaluates the RP. Treat the OpenID Provider (OP) as a separate system unless the engagement also includes that OP. Cross-link OAuth Weaknesses for grant-type and PKCE issues, and JSON Web Tokens for other JWT issues.

Test Objectives

  • Confirm the RP validates issuer discovery and authentication claims before creating a session.
  • Confirm account identity is bound to (iss, sub), not to email alone.
  • Confirm account-linking and recovery flows cannot attach an attacker-controlled identity to another user’s account.
  • Confirm mix-up defenses when the RP can use more than one OP.
  • Confirm the RP enforces requested authentication strength claims when it asks for MFA or recent authentication.

How to Test

Use only tester-owned accounts at both the RP and any lab identity provider. Do not target production users.

Map the OIDC Surface

  1. Identify authorization requests that include scope=openid or that return an id_token.
  2. Capture the discovery document when present (/.well-known/openid-configuration) and record issuer, jwks_uri, authorization_endpoint, and token_endpoint.
  3. Distinguish:
    • Login with an external OP.
    • Linking an external identity to an already authenticated local account.
    • Account recovery that trusts an OP email claim.

Discovery and Issuer Binding

  1. If the RP performs discovery from a client-supplied issuer or identifier, point discovery at a tester-controlled HTTPS metadata document only.
  2. Serve a discovery document whose issuer value differs from the expected issuer, even slightly (a different path, a trailing slash, a different scheme or case, or an attacker-controlled host). The RP must compare the issuer in the document with the expected issuer using an exact string match, and with the issuer URL it used to retrieve the document, and reject any mismatch before using the metadata.
  3. Confirm the RP pins the expected issuer and does not follow attacker-controlled authorization_endpoint or token_endpoint values from untrusted metadata.
  4. When dynamic registration or multi-OP login is supported, start a login toward OP A and complete the callback as if it came from OP B. The RP must detect the mismatch. See RFC 9207 and RFC 9700 Section 4.4.

ID Token Validation Matrix

Obtain a legitimate ID Token for a tester account, then mutate one claim or condition at a time before the RP consumes it. Prefer a lab OP or a replay against a local RP build. Do not attempt to forge production OP signatures. Signature algorithm allowlists, alg=none, and wrong-key failures belong in JSON Web Tokens; keep this matrix on OIDC authentication claims.

Mutation Expected secure result
Wrong iss Reject
Wrong or missing aud / unexpected azp Reject
Expired exp Reject
Replayed nonce or missing nonce when the RP sent one Reject
Token substituted from another tester account Session for the substituted subject must not be created under the victim’s local account

iat validation is optional in OIDC Core. Prefer testing exp and nonce first. Do not treat nbf as an ID Token requirement unless the deployment documents it.

Also send the access token to the UserInfo endpoint, then present UserInfo claims for subject B while the ID Token subject is A. The RP must correlate UserInfo sub with the authenticated ID Token sub.

Email and Account-Linking Lifecycle

OIDC email claims are not a stable account primary key.

  1. Unverified email: With a lab OP that can omit or set email_verified=false, attempt login or linking. The RP must not create or merge an account solely from an unverified email.
  2. Pre-account collision: Register a local account using tester B’s email if the RP allows unverified registration. Before B verifies, attach tester A’s OP identity to that account. After B verifies or recovers the account, A’s OP login must not remain attached unless B explicitly re-links it.
  3. Login CSRF / confused-deputy linking: Authenticate to the RP as victim account V. In a separate browser (or private profile) authenticate to the OP as attacker A and start “connect external identity” or an OP login that produces an authorization code and state bound to A’s OP session. Deliver that callback URL to V’s browser so V’s RP session completes the redirect. Secure behavior rejects the callback itself, because its state (and nonce or PKCE verifier) belongs to a transaction started in a different browser or session. Check the callback response, not only the final account association: it should be an error, with no session change and no identity attached. Also repeat the test with the callback delivered to a browser that has no RP session. The linking or login transaction must be bound to the same user agent and RP session that started it, not only to a bearer state value an attacker can move between browsers.
  4. Identifier change: Change the local account email from address X to Y, then attempt old email-verification, reset, or linking tokens minted for X. They must be invalid after the identity transition.
  5. Stable subject: Prefer (iss, sub). Two OPs asserting the same email must not merge accounts automatically.

Session Creation and Step-Up

  1. Confirm the RP creates its own session after validating the ID Token, and that logout or password change invalidates that session.
  2. If MFA is required for local password login, attempt OP login paths that skip MFA. See Multi-Factor Authentication (MFA).
  3. If the RP requests step-up with acr_values or a recent login with max_age, inspect the resulting ID Token. The RP must reject tokens that omit or under-assert the required acr / amr values, or whose auth_time is older than max_age.
  4. Confirm logout at the RP does not leave a reusable RP-side artifact that silently re-creates a session from a still-valid OP cookie without revalidation when that behavior is not intended.

Remediation

  • Validate ID Tokens per OIDC Core: iss, aud, exp, and nonce when used. Apply JWT signature and algorithm checks as in JSON Web Tokens.
  • When requesting acr_values or max_age, enforce acr / amr / auth_time in the ID Token before creating or elevating a session.
  • Key local accounts on (iss, sub). Treat email as a contact attribute that requires verification before linking or recovery.
  • Bind account-linking and login transactions to the user agent and RP session that started them.
  • Invalidate outstanding verification, reset, and linking artifacts when the primary identifier changes.
  • Implement mix-up defenses when more than one OP is supported.

Tools

References