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
- Identify authorization requests that include
scope=openidor that return anid_token. - Capture the discovery document when present (
/.well-known/openid-configuration) and recordissuer,jwks_uri,authorization_endpoint, andtoken_endpoint. - 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
- If the RP performs discovery from a client-supplied issuer or identifier, point discovery at a tester-controlled HTTPS metadata document only.
- Serve a discovery document whose
issuervalue 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 theissuerin 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. - Confirm the RP pins the expected issuer and does not follow attacker-controlled
authorization_endpointortoken_endpointvalues from untrusted metadata. - 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.
- 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. - 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.
- 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
codeandstatebound 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 itsstate(andnonceor 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 bearerstatevalue an attacker can move between browsers. - 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.
- Stable subject: Prefer
(iss, sub). Two OPs asserting the same email must not merge accounts automatically.
Session Creation and Step-Up
- Confirm the RP creates its own session after validating the ID Token, and that logout or password change invalidates that session.
- If MFA is required for local password login, attempt OP login paths that skip MFA. See Multi-Factor Authentication (MFA).
- If the RP requests step-up with
acr_valuesor a recent login withmax_age, inspect the resulting ID Token. The RP must reject tokens that omit or under-assert the requiredacr/amrvalues, or whoseauth_timeis older thanmax_age. - 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.
Related Test Cases
- OAuth Weaknesses
- OAuth Authorization Server Weaknesses
- OAuth Client Weaknesses
- JSON Web Tokens
- Weak Password Change or Reset Functionalities
- Multi-Factor Authentication (MFA)
- SAML Authentication
- Passkeys and WebAuthn
Remediation
- Validate ID Tokens per OIDC Core:
iss,aud,exp, andnoncewhen used. Apply JWT signature and algorithm checks as in JSON Web Tokens. - When requesting
acr_valuesormax_age, enforceacr/amr/auth_timein 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.