Skip to content

chore: prevent authentication of non-unique oidc subjects #16498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 10, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: prevent non-unqiue oidc subjects from authenticating
Any IdP returning an empty field here breaks the assumption of a
unique subject id. This is defined in the OIDC spec.
  • Loading branch information
Emyrk committed Feb 7, 2025
commit c9599f28051e5ff5f941dc41c1ebc7f52676d20a
9 changes: 9 additions & 0 deletions coderd/userauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -1096,6 +1096,15 @@ func (api *API) userOIDC(rw http.ResponseWriter, r *http.Request) {
return
}

if idToken.Subject == "" {
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
Message: "OIDC token missing 'sub' claim field or 'sub' claim field is empty.",
Detail: "'sub' claim field is required to be unique for all users by a given issue, " +
"an empty field is invalid and this authentication attempt is rejected.",
})
return
}

logger := api.Logger.Named(userAuthLoggerName)

// "email_verified" is an optional claim that changes the behavior
Expand Down