CodePark/ questions / OAuth 2.0 & OpenID Connect
START PRACTICINGPRACTICE
Backend question · Auth & security › OAuth 2.0 & OpenID Connect

In an OIDC Authorization Code flow, what do the state and nonce parameters protect against?

state ties the callback to the browser session that started the flow (CSRF on the redirect); nonce binds the ID token to that request so it can't be replayed

state stops CSRF on the redirect, and nonce stops ID token replay.

state: The client creates state and stores it. It rejects any callback whose state doesn't match. So an attacker can't push their own authorization code into the victim's session.

nonce: The server copies the nonce inside the signed ID token. So the client rejects a token captured from another login.

"
nonce replaces PKCE; state replaces the client secret" is wrong. Neither one replaces PKCE, which protects the code itself.