#3825·sure

SSO account creation trusts the IdP email without checking email_verified, although the docs say it must be verified

Author: gfr-freeCreated Sep 28, 2026Updated Sep 28, 2026

Summary

docs/hosting/oidc.md states that the IdP must report the user's email as verified:

The IdP must report the user's email as verified, and it must match an existing user or be allowed for JIT creation. (L60)

When empty, JIT SSO account creation is allowed for any verified email. (L133)

The code never reads the email_verified claim; the string does not appear anywhere under app/, lib/ or config/. The unverified auth.info.email alone decides two things during JIT account creation:

  1. Which pending invitation is redeemed. The new user joins the inviting family with the invited role, which can be admin.
  2. Whether ALLOWED_OIDC_DOMAINS lets the account be created.

Where

Links are at 5e9e3b1.

  • SessionsController#openid_connect stores auth.info&.email in session[:pending_oidc_auth] for an unlinked identity (L346).
  • OidcAccountsController#create_user looks up Invitation.pending.find_by(email: email) and checks AuthConfig.allowed_oidc_domain?(email) with that value (L114, L119). With an invitation it sets family_id and role from it. #link makes the same decision for the UI (L20-L24).
  • Mobile: SessionsController#handle_mobile_sso_onboarding computes allow_account_creation from the same email (L492). Api::V1::AuthController#sso_create_account redeems the invitation by that email (L241).
  • AuthConfig.allowed_oidc_domain? compares only the part after @ (L73).

Not affected:

  • Existing users: login resolves identities by provider + uid.
  • Linking an SSO identity to an existing account: this requires that account's password.
  • OidcIdentity#sync_user_attributes!: it does not change the user's email.

Impact

This only matters with an IdP where someone can hold an account whose email they typed in but never confirmed. Examples are Keycloak or Authentik with open self-registration or editable profile emails and no email verification. Google and Microsoft organisational accounts report verified emails and are not affected in practice.

With such an IdP, and the default AUTH_JIT_MODE=create_and_link:

  • Invitation takeover. Family A invites [email protected], possibly as admin. While the invitation is pending (3 days), someone registers at the IdP with the unverified email [email protected] and signs in to Sure via SSO. create_user redeems Alice's invitation, and they join family A with the invited role. Alice can no longer accept it.
  • Domain restriction bypass. With ALLOWED_OIDC_DOMAINS=example.com, anyone who can set an unverified @example.com email at the IdP gets a JIT account.

Severity depends entirely on the IdP. Operators who rely on the documented behavior have no reason to expect this.

Proposed fix

  1. Read email_verified from the IdP response in openid_connect and handle_mobile_sso_onboarding (e.g. auth.extra.raw_info), and keep it next to the email in the pending auth and the mobile linking-code cache.
  2. Only let a verified email redeem an invitation by address or satisfy allowed_oidc_domain?, in create_user, link and sso_create_account. With an unverified email:
    • invitations can still be accepted through the emailed invitation link, which is token-based;
    • the domain check fails.
  3. Cover the web and mobile paths with tests for verified and unverified emails.

Open question for maintainers: some IdPs don't send email_verified at all. Should a missing claim count as unverified, which is safe but could block JIT on such setups after upgrading? Or should there be a per-provider opt-out (e.g. trust_unverified_email: true in config/auth.yml / the SSO provider settings), with the docs updated accordingly?

Happy to open a PR once there's a preference on that.