Skip to content

fix(oidc): verify userinfo sub matches the ID Token sub - #4828

Merged
nabokihms merged 1 commit into
dexidp:masterfrom
kanywst:fix/oidc-userinfo-sub-verification
Nov 3, 2026
Merged

nabokihms merged 1 commit into
dexidp:masterfrom
kanywst:fix/oidc-userinfo-sub-verification

Conversation

@kanywst

@kanywst kanywst commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Verify the userinfo sub against the ID Token sub in the OIDC connector, as required by OpenID Connect Core 5.3.2.

What this PR does / why we need it

With getUserInfo: true, createIdentity merged the userinfo response into the verified ID Token claims and read sub from the result, so a userinfo sub that differed from the ID Token sub silently became the subject (Identity.UserID). OpenID Connect Core 5.3.2 requires the two to match.

This keeps the ID Token sub before the userinfo merge and returns an error on mismatch. When there is no ID Token (the access-token token exchange, where userinfo is itself the verification) the check is skipped, so that path is unchanged.

Closes #4827

Special notes for your reviewer

createIdentity merged the userinfo response into the verified ID Token claims and read sub from the result, so a userinfo sub that differed from the ID Token sub became the subject. OpenID Connect Core 5.3.2 requires the two to match. Keep the ID Token sub before the merge and error on mismatch; skip the check when there is no ID Token (access-token token exchange).

Signed-off-by: kanywst <[email protected]>
@kanywst
kanywst force-pushed the fix/oidc-userinfo-sub-verification branch from e953c0e to c7028e8 Compare October 23, 2026 19:54

@nabokihms nabokihms left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@nabokihms
nabokihms merged commit 0b9df1e into dexidp:master Nov 3, 2026
9 checks passed
@kanywst
kanywst deleted the fix/oidc-userinfo-sub-verification branch November 3, 2026 16:11
kanywst added a commit to dyokto/mustbreak that referenced this pull request Dec 3, 2026
e2e/run.sh starts dex (docker with host networking, or a local binary),
runs the cases dex can answer and compares each status with
e2e/expect. v2.46.1 must fail MB-17 and master, which has dexidp/dex#4828,
must pass it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

connector(oidc): userinfo sub is not verified against the ID Token sub

2 participants