How to fix: OIDC authorization request returns an ID token with no nonce
The scanned URL is an authorization request whose response_type includes id_token, but it carries no nonce parameter. OpenID Connect Core section 3.2.2.1 requires a nonce for every flow that returns an ID token from the authorization endpoint.
Why it matters
The nonce is what binds an ID token to the specific authentication request that asked for it. Without it, an ID token captured from one session can be replayed into another: an attacker who obtains a valid token for a victim, from browser history, a logged URL, or a different relying party, can present it at the callback and be logged in as that user.
state and nonce solve different problems and neither substitutes for the other. state protects the redirect against CSRF; nonce protects the token against replay, and it is the only one carried inside the token itself so the client can check it after the fact. The value must be unguessable, stored with the session that started the flow, and compared against the token's nonce claim on return.
How to fix it
- 1Generate a cryptographically random nonce per authorization request and include it in the request.
- 2Persist it against the user's session, not in a cookie the callback page can read from JavaScript.
- 3On callback, reject the ID token unless its nonce claim equals the stored value, then discard the stored value so it cannot be reused.
- 4Prefer the authorization code flow with PKCE, where the token is never exposed in the front channel at all.
Code examples
Generate and store the nonce
const nonce = crypto.randomUUID();
req.session.oidcNonce = nonce;
const authUrl = new URL('https://auth.example.com/authorize');
authUrl.searchParams.set('response_type', 'code id_token');
authUrl.searchParams.set('client_id', CLIENT_ID);
authUrl.searchParams.set('redirect_uri', CALLBACK);
authUrl.searchParams.set('scope', 'openid profile');
authUrl.searchParams.set('nonce', nonce);
authUrl.searchParams.set('state', crypto.randomUUID());Verify it on callback
const { payload } = await jose.jwtVerify(idToken, JWKS, {
issuer: ISSUER,
audience: CLIENT_ID,
algorithms: ['RS256'],
});
if (payload.nonce !== req.session.oidcNonce) {
throw new Error('nonce mismatch');
}
delete req.session.oidcNonce; // single useReferences
Detected automatically by VulnRadar. The check id is api-oauth-authorize-oidc-nonce-missing, stable across every scan so you can filter or diff on it.
More api checks
- LowTRACE method referenced in API response body
- InfoREST endpoint allows DELETE
- LowGraphQL introspection field suggestions
- MediumGraphQL endpoint has no rate-limit headers
- LowOpenAPI server URL leaks internal host
- LowCORS preflight result not cached
- HighBearer token in URL query string
- MediumJSONP callback parameter accepted
Questions
- How severe is OIDC authorization request returns an ID token with no nonce?
- VulnRadar rates this medium severity in the api category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id api-oauth-authorize-oidc-nonce-missing, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does OIDC authorization request returns an ID token with no nonce map to?
- It maps to CWE-294. In the OWASP Top 10 it falls under A07:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.