🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

feat: add INSECURE oidc email fallback flag for IdP brokers - #26751

Merged
Emyrk merged 4 commits into
mainfrom
stevenmasley/oidc-insecure-email-fallback
Jun 26, 2026
Merged

feat: add INSECURE oidc email fallback flag for IdP brokers#26751
Emyrk merged 4 commits into
mainfrom
stevenmasley/oidc-insecure-email-fallback

Conversation

@Emyrk

@Emyrk Emyrk commented Jun 26, 2026

Copy link
Copy Markdown
Member

Adds an opt-in CODER_DANGEROUS_OIDC_EMAIL_FALLBACK flag (alias --dangerous-oidc-email-fallback) for IdP brokers that do not issue a stable sub for the same user across connections.

When the flag is on and an OIDC login's linked_id (issuer||subject) does not match an existing user_link, the code falls back to email matching, lets the login proceed, and preserves the original linked_id. The existing subject still resolves via the primary linked_id path on subsequent logins.

The flag is hidden, defaults to false, and weakens the linked_id check restored in #25712 (PLAT-229).

Scope is OIDC only. The GitHub callsite continues to pass false and behaves exactly as before.

Implementation notes
  • findLinkedUser now takes allowInsecureLinkedIDMismatch bool. When true, the errLinkedIDAlreadyBound check is skipped and the email-matched user + existing link are returned.
  • oauthLoginParams.AllowInsecureLinkedIDMismatch gates the defense-in-depth linked_id mismatch check inside oauthLogin so the existing linked_id is preserved. UpdateUserLink already does not touch linked_id; only the OAuth token and claims are refreshed.
  • New subtests under TestUserOIDC:
    • OIDCInsecureEmailFallbackAllowed: mismatched sub + matching email succeeds with the flag on; original linked_id is preserved.
    • OIDCInsecureEmailFallbackPreservesOriginalLogin: after a fallback login, the original subject still resolves via the primary path.
    • OIDCInsecureEmailFallbackDoesNotCreateUsers: the flag does not bypass the signup gate for brand-new emails.

Coder Agents on behalf of @Emyrk.

Adds CODER_DANGEROUS_OIDC_EMAIL_FALLBACK (--dangerous-oidc-email-fallback)
as an opt-in escape hatch for IdP brokers (e.g. Auth0) that emit
different OIDC subjects for the same user across connections (passwordless
email vs SAML SSO). With the flag on, an OIDC login whose linked_id
(issuer+subject) does not match an existing user_link but whose email
does match is allowed through; the existing linked_id is preserved.

The flag is hidden and defaults to false. It re-opens the email-based
account-takeover vector closed by PLAT-229, so a warn log is emitted
every time the fallback resolves a login.

Implementation:
- findLinkedUser takes allowInsecureLinkedIDMismatch and skips
  errLinkedIDAlreadyBound on mismatch (OIDC callsite passes the flag,
  GitHub callsite passes false).
- oauthLoginParams.AllowInsecureLinkedIDMismatch gates the
  defense-in-depth check in oauthLogin so the existing linked_id is not
  overwritten.

Authored by Coder Agents on behalf of @Emyrk.
@github-actions

Copy link
Copy Markdown

Docs preview

📖 View docs preview for docs/reference/api/general.md

@Emyrk
Emyrk marked this pull request as ready for review June 26, 2026 16:19
@Emyrk
Emyrk requested a review from sreya June 26, 2026 16:20
@Emyrk
Emyrk merged commit ad355ae into main Jun 26, 2026
45 of 46 checks passed
@Emyrk
Emyrk deleted the stevenmasley/oidc-insecure-email-fallback branch June 26, 2026 16:23
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants