Lesson 10 of 14 · 14m
OIDC Is Not OAuth
Access tokens authorize API calls; the ID token's aud and nonce are what actually prove a user authenticated for your client.
Two tokens, two different verbs
OIDC layers authentication on top of OAuth 2.0's authorization plumbing, and the layer is concrete: alongside the access token, the token endpoint returns an ID token — a JWT containing iss, sub, aud, exp, iat, and the nonce you sent at authorize time. The access token says "this bearer may call this API." The ID token says "this specific user just authenticated, for your client." The /userinfo endpoint and /.well-known/openid-configuration discovery document round out the profile.
The wrong mental model
"An access token proves who the user is." It does not — it proves the bearer was authorized by someone, for some client, at some time. Apps that "do login" by accepting an access token and calling /userinfo have shipped the same bug repeatedly: a token minted for any client of that provider validates. Attacker registers "Totally Legit Weather App" at the same OAuth provider, gets users to authorize it, and replays their access tokens against your login endpoint — your server sees a valid token, fetches a valid profile, and logs the attacker in as the victim. It's the confused-deputy problem wearing an OAuth costume.
The ID token fixes it because aud binds the assertion to your client_id, and nonce binds it to this authentication session. An access token carries no such promise to your app.
There's a subtler version worth naming: even your own access token isn't an identity assertion. Its aud names the API it was minted for — the resource server — not your login form. If your API's aud check passes but your session logic treats the token's bearer as "the logged-in user," you've rebuilt the same confused deputy one door down. Access tokens authorize calls; ID tokens assert identity. The verbs are different on purpose.
What validation actually looks like
// the checks that make an ID token an identity
const claims = await verifyIdToken(idToken, jwks);
assert(claims.iss === 'https://idp.example'); // who issued it
assert(claims.aud === 'my-client-id'); // minted for ME
assert(claims.exp > now); // still valid
assert(claims.nonce === storedNonce); // answer to MY challengeMiss aud and you're the weather-app victim. Miss iss and any issuer your JWKS fetch resolves can assert identities. Miss nonce and a replayed ID token logs in twice.
Evidence and nuance
at_hash binds the access token to the ID token — when the flow returns both, validate it, or a substituted access token sails through alongside a legitimate identity assertion. The /userinfo endpoint is for profile data, returned under access-token authorization — fine to call, wrong to authenticate with. And "Sign in with Google/Apple/GitHub" buttons are OIDC (or OIDC-shaped) authentication; "Allow X to read your calendar" is OAuth authorization. Apps that blur them get the deputy bug.
Three corners worth knowing. azp (authorized party) appears when aud holds multiple values — it names which client actually requested the token, and some providers use azp instead of stuffing aud. sub is scoped to the issuer — the same user has different sub values at different IdPs, so link on (iss, sub) pairs, never email (email is mutable, and not all IdPs verify it — trust email_verified only when the provider's claim means verification). And logout: OIDC's RP-initiated logout spec means signing a user out of your session doesn't sign them out of the IdP — if the IdP session survives, "logout" is a one-redirect inconvenience, which surprises people exactly once, after which they design for it.
What to actually do
Authenticate on the ID token only: signature, iss, aud, exp, nonce. Treat access tokens as API authorization — check their aud/scope at your API, never as proof of login. Keep /userinfo for profile freshness. If you're tempted to skip nonce because "the flow happens once," that one-time property is precisely what it's there to prove.
Keep reading
Related articles from the SudoSecurity blog.
A 257-Byte Password Is the Key: Inside the OpenSSH musl Bypass
CVE-2026-123158 lets an attacker log into a locked account on musl-based systems like Alpine by sending a password nobody set. The trigger is one number, 257, and the reason is a C library returning a single asterisk. I reproduced the exact boundary against musl 1.2.4 and read the fix.
Zero-Trust Access for Homelabbers: Teleport vs. Tailscale vs. WireGuard vs. Cloudflare Tunnel
Four tools solve four different problems that all get pitched as the same problem. Here's what each one does, where each one breaks, and the combination that covers a real homelab without paying an SSO tax you didn't see coming.
The SSO Tax: Why Self-Hosted Projects Are Gating Login Behind a Paywall
A growing list of open-core self-hosted projects, from Grafana to Planka, gate single sign-on behind an Enterprise tier. Here's which protocol actually gets paywalled, and what to check before you deploy.
Zero Trust Everything: The Complete Guide to Self-Hosting Teleport for Secure Infrastructure Access
SudoSecurity runs Teleport internally for everything — admin panel access, secure database connections, Kubernetes, and zero-trust philosophy across our entire team. This is the complete technical guide to installing, configuring, and running your own self-hosted Teleport cluster from scratch.