ash_authentication 4.14: store OIDC user identities instead of matching users by email #564

Closed
opened 2026-10-05 12:54:14 +02:00 by moritz · 1 comment
Owner

Why

GHSA-777c-2fxx-qr28 (severity: critical) — AshAuthentication is vulnerable to
OAuth2/OIDC account takeover via email-based user matching. Only the provider's
iss/sub claim combination identifies an end-user uniquely and stably; matching
a local user by the email address the provider reports is unsafe.

We are genuinely affected, not merely running an outdated version: the :oidc
strategy has no identity_resource, so a successful OIDC login is resolved against
the local user's email address.

The advisory is currently suppressed in .deps_audit_ignore so that it does not
block unrelated pull requests. That suppression is the reason this issue exists and
must be removed as part of it.

Current state

  • lib/accounts/user.ex — oidc :oidc do block has no identity_resource and no
    trust_email_verified?; there is no confirmation add-on on the email field.
  • No UserIdentity resource and no user_identities table exist in the project.
  • mix.exs pins {:ash_authentication, "~> 4.13.0"}. The first patched version is
    4.14.0, so the constraint has to move.
  • Under 4.14 the Spark verifier emits two warnings for the missing identity_resource
    and the untrusted email_verified claim. Both fail mix compile --warnings-as-errors,
    which is why the dependency cannot simply be bumped — this is the actual work.
  • Renovate PR #562 ("chore(deps): update mix dependencies") fails its artifact step for
    exactly this reason and will keep failing until this issue is done.

Scope

  1. Raise the mix.exs constraint to {:ash_authentication, "~> 4.14"} and update mix.lock.
  2. Generate the user-identity scaffolding (mix ash_authentication.upgrade creates the
    resource and the migration) and wire identity_resource into the :oidc strategy.
  3. Decide and implement the email_verified handling — either a confirmation add-on
    monitoring the :email field, or trust_email_verified? true if the IdP is trusted
    to assert email ownership. See open questions.
  4. Migrate existing accounts: users who authenticated via OIDC before this change have
    no identity row. Determine what happens on their first login afterwards and add a
    data migration or backfill if needed.
  5. Remove the GHSA-777c-2fxx-qr28 entry (and its comment block) from .deps_audit_ignore.
  6. Close Renovate PR #562 so it is recreated against the new constraint, or rebase it.

Open questions

  • Existing users. With identity_resource configured, what does AshAuthentication 4.14
    do on the first login of a user who has no user_identities row — link the existing user,
    create a duplicate, or reject? This determines whether step 4 is a one-line backfill or a
    careful migration, and getting it wrong locks every existing member out of SSO. Verify
    against the 4.14 source, not just the changelog.
  • Provider trust. Does our Rauthy deployment reliably assert email_verified? If yes,
    trust_email_verified? true is the smaller change; if not, we need the confirmation add-on,
    which introduces an email round-trip into the SSO flow.
  • Backfill key. If a backfill is needed, sub values have to come from the IdP. Can we
    derive them from Rauthy, or does the first post-upgrade login have to establish them?

Acceptance criteria

  • just ci is green with no GHSA-777c-2fxx-qr28 entry in .deps_audit_ignore.
  • An existing member who previously logged in via OIDC can still log in and stays linked to
    the same Member record.
  • A second IdP account carrying the email address of an existing user does not gain access to
    that user's account.
  • A login whose iss/sub pair is already known resolves to the same local user.
  • mix deps.audit --ignore-file .deps_audit_ignore reports no findings.
## Why GHSA-777c-2fxx-qr28 (severity: critical) — AshAuthentication is vulnerable to OAuth2/OIDC account takeover via email-based user matching. Only the provider's `iss`/`sub` claim combination identifies an end-user uniquely and stably; matching a local user by the email address the provider reports is unsafe. We are genuinely affected, not merely running an outdated version: the `:oidc` strategy has no `identity_resource`, so a successful OIDC login is resolved against the local user's email address. The advisory is currently suppressed in `.deps_audit_ignore` so that it does not block unrelated pull requests. That suppression is the reason this issue exists and must be removed as part of it. ## Current state - `lib/accounts/user.ex` — `oidc :oidc do` block has no `identity_resource` and no `trust_email_verified?`; there is no confirmation add-on on the email field. - No `UserIdentity` resource and no `user_identities` table exist in the project. - `mix.exs` pins `{:ash_authentication, "~> 4.13.0"}`. The first patched version is `4.14.0`, so the constraint has to move. - Under 4.14 the Spark verifier emits two warnings for the missing `identity_resource` and the untrusted `email_verified` claim. Both fail `mix compile --warnings-as-errors`, which is why the dependency cannot simply be bumped — this is the actual work. - Renovate PR #562 ("chore(deps): update mix dependencies") fails its artifact step for exactly this reason and will keep failing until this issue is done. ## Scope 1. Raise the `mix.exs` constraint to `{:ash_authentication, "~> 4.14"}` and update `mix.lock`. 2. Generate the user-identity scaffolding (`mix ash_authentication.upgrade` creates the resource and the migration) and wire `identity_resource` into the `:oidc` strategy. 3. Decide and implement the `email_verified` handling — either a confirmation add-on monitoring the `:email` field, or `trust_email_verified? true` if the IdP is trusted to assert email ownership. See open questions. 4. Migrate existing accounts: users who authenticated via OIDC before this change have no identity row. Determine what happens on their first login afterwards and add a data migration or backfill if needed. 5. Remove the `GHSA-777c-2fxx-qr28` entry (and its comment block) from `.deps_audit_ignore`. 6. Close Renovate PR #562 so it is recreated against the new constraint, or rebase it. ## Open questions - **Existing users.** With `identity_resource` configured, what does AshAuthentication 4.14 do on the first login of a user who has no `user_identities` row — link the existing user, create a duplicate, or reject? This determines whether step 4 is a one-line backfill or a careful migration, and getting it wrong locks every existing member out of SSO. Verify against the 4.14 source, not just the changelog. - **Provider trust.** Does our Rauthy deployment reliably assert `email_verified`? If yes, `trust_email_verified? true` is the smaller change; if not, we need the confirmation add-on, which introduces an email round-trip into the SSO flow. - **Backfill key.** If a backfill is needed, `sub` values have to come from the IdP. Can we derive them from Rauthy, or does the first post-upgrade login have to establish them? ## Acceptance criteria - `just ci` is green with no `GHSA-777c-2fxx-qr28` entry in `.deps_audit_ignore`. - An existing member who previously logged in via OIDC can still log in and stays linked to the same `Member` record. - A second IdP account carrying the email address of an existing user does not gain access to that user's account. - A login whose `iss`/`sub` pair is already known resolves to the same local user. - `mix deps.audit --ignore-file .deps_audit_ignore` reports no findings.
Owner

see #557

see #557
moritz self-assigned this 2026-10-13 12:25:44 +02:00
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
local-it/mitgliederverwaltung#564
No description provided.