Migrate OIDC to ash_authentication identity_resource (UserIdentity) and unpin to 4.15+ #557

Closed
opened 2026-07-11 16:37:15 +02:00 by simon · 0 comments
Owner

Why — this changed on 2026-10-06

A disclosure of 18 advisories in ash_authentication / ash_authentication_phoenix
landed today. The previous version of this issue said there was "no live gap" because
our custom design already resolves sign-in by the provider's sub. That statement is
still true for the advisory it referred to, and no longer true for the issue as a whole:
several of the new advisories are not avoided by sub-based resolution.

Priority therefore moves from "maintenance before the requirement becomes hard" to
"security work ahead of the refactoring milestone".

What applies to us

Verified as not applicable (gated out by our configuration):

Advisory Why it cannot reach us
OAuth2/OIDC account takeover via email matching (2 entries) sign-in filters on oidc_id == user_info.sub (`lib/accounts/user.ex:287
), register_with_oidcupserts onunique_oidc_id` (:316, :606)
Purpose-limited JWT accepted as full bearer require_token_presence_for_authentication is true in config/dev.exs:107 and `confi
g/prod.exs:24, and retrieve_from_bearer/3` is not wired anywhere
Reflected XSS in confirmation / magic-link interaction forms needs require_interaction? true; no confirmation add-on, no magic-lin
k strategy
Remember-me sign-in guard reads an unwritten session key remember_me strategy not enabled
Confirmation token accepted on any record; require_confirmed_with fails open no confirmation add-on
Audit log stores actor password digest; reversible IP pseudonymisation no audit_log add-on configured
Superlinear base62 decoding in API key sign-in no api_key strategy
Magic link single-use tokens replayable via TOCTOU no magic_link strategy
Sign-in token minted for one resource accepted by another only one authenticated resource exists (Mv.Accounts.User)

Likely applicable — confirm each against the 4.15 source during analysis, do not take
this table on trust:

  • Replayable OAuth2 CSRF state retained after a failed callback. Lives in
    AshAuthentication.Strategy.OAuth2.Plug.callback/2, which our oidc strategy uses.
    sub-based resolution does not protect against it.
  • Session id is not renewed on authentication, allowing session fixation.
  • Revoked session accepted because the session jti is never checked. Relevant given
    store_all_tokens? true and a configured session_identifier.
  • Token revocation record built from unverified JWT claims.
  • Log injection via an unescaped password reset identity. Our password strategy has
    resettable with a sender.
  • Single-use sign-in token placed in a redirect query string. This one is in
    ash_authentication_phoenix, fixed in 2.17.4; mix.exs pins ~> 2.10, so that part
    is a lockfile-only bump.

Scope

  1. Raise mix.exs to {:ash_authentication, "~> 4.15"} and update mix.lock; bring
    ash_authentication_phoenix to at least 2.17.4 in the lock.
  2. Generate the user-identity scaffolding (mix ash_authentication.upgrade) and wire
    identity_resource into the :oidc strategy. 4.14+ fails
    mix compile --warnings-as-errors until this exists.
  3. Decide and implement the email_verified handling: a confirmation add-on monitoring
    :email, or trust_email_verified? true if the IdP is trusted to assert ownership.
  4. Migrate existing accounts: move users.oidc_id into user_identities as the
    provider's iss/sub pair. See open questions — this is the step that can lock every
    existing member out of SSO.
  5. Adapt the custom flows: register_with_oidc, link_oidc_id, OidcEmailCollision,
    LinkOidcAccountLive, OidcRoleSync.
  6. Remove the GHSA-777c-2fxx-qr28 entry and its comment block from .deps_audit_ignore.
  7. Re-test against the Rauthy deployment; Authentik and Keycloak if available.

Open questions

  • Existing users. With identity_resource configured, what does 4.15 do on the first
    login of a user who has no user_identities row — link the existing user, create a
    duplicate, or reject? This decides whether step 4 is a one-line backfill or a careful
    migration. Verify against the 4.15 source, not the changelog.
  • Backfill key. We store sub in users.oidc_id but not iss. Can iss be derived
    from our single configured provider for the backfill, or does the first post-upgrade
    login have to establish the pair?
  • Provider trust. Does our Rauthy deployment reliably assert email_verified?
    rauthy-bootstrap/clients.json does not say; this needs checking against the instance.
  • Session renewal. Does 4.15 renew the session id itself, or does the host application
    have to do it? Determines whether the session-fixation advisory is closed by the bump
    alone.

Acceptance criteria

  • just ci green with no GHSA-777c-2fxx-qr28 entry in .deps_audit_ignore, and
    mix deps.audit --ignore-file .deps_audit_ignore reporting no findings.
  • An existing member who previously signed in via OIDC can still sign 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.
  • The session id changes across authentication (regression test for session fixation).
  • A failed or cancelled OIDC callback leaves no reusable session_params entry behind
    (regression test for the replayable-state advisory).
  • Migration applies cleanly on a database holding existing users.oidc_id values, and
    rolls back cleanly.

Notes

  • Renovate PR #568 raises the constraint to ~> 4.15.0 but carries no mix.lock, because
    its artifact step cannot compile 4.15 against the current code. Close it, or let this
    issue supersede it.
  • #564 duplicates this issue and states the exposure incorrectly; close it in favour of
    this one.
## Why — this changed on 2026-10-06 A disclosure of 18 advisories in `ash_authentication` / `ash_authentication_phoenix` landed today. The previous version of this issue said there was "no live gap" because our custom design already resolves sign-in by the provider's `sub`. That statement is still true for the advisory it referred to, and no longer true for the issue as a whole: several of the new advisories are not avoided by `sub`-based resolution. Priority therefore moves from "maintenance before the requirement becomes hard" to "security work ahead of the refactoring milestone". ## What applies to us Verified as **not applicable** (gated out by our configuration): | Advisory | Why it cannot reach us | |---|---| | OAuth2/OIDC account takeover via email matching (2 entries) | sign-in filters on `oidc_id == user_info.sub` (`lib/accounts/user.ex:287 `), `register_with_oidc` upserts on `unique_oidc_id` (:316, :606) | | Purpose-limited JWT accepted as full bearer | `require_token_presence_for_authentication` is `true` in `config/dev.exs:107` and `confi g/prod.exs:24`, and `retrieve_from_bearer/3` is not wired anywhere | | Reflected XSS in confirmation / magic-link interaction forms | needs `require_interaction? true`; no confirmation add-on, no magic-lin k strategy | | Remember-me sign-in guard reads an unwritten session key | `remember_me` strategy not enabled | | Confirmation token accepted on any record; `require_confirmed_with` fails open | no confirmation add-on | | Audit log stores actor password digest; reversible IP pseudonymisation | no `audit_log` add-on configured | | Superlinear base62 decoding in API key sign-in | no `api_key` strategy | | Magic link single-use tokens replayable via TOCTOU | no `magic_link` strategy | | Sign-in token minted for one resource accepted by another | only one authenticated resource exists (`Mv.Accounts.User`) | **Likely applicable — confirm each against the 4.15 source during analysis, do not take this table on trust:** - Replayable OAuth2 CSRF state retained after a failed callback. Lives in `AshAuthentication.Strategy.OAuth2.Plug.callback/2`, which our `oidc` strategy uses. `sub`-based resolution does not protect against it. - Session id is not renewed on authentication, allowing session fixation. - Revoked session accepted because the session `jti` is never checked. Relevant given `store_all_tokens? true` and a configured `session_identifier`. - Token revocation record built from unverified JWT claims. - Log injection via an unescaped password reset identity. Our `password` strategy has `resettable` with a sender. - Single-use sign-in token placed in a redirect query string. This one is in `ash_authentication_phoenix`, fixed in `2.17.4`; `mix.exs` pins `~> 2.10`, so that part is a lockfile-only bump. ## Scope 1. Raise `mix.exs` to `{:ash_authentication, "~> 4.15"}` and update `mix.lock`; bring `ash_authentication_phoenix` to at least `2.17.4` in the lock. 2. Generate the user-identity scaffolding (`mix ash_authentication.upgrade`) and wire `identity_resource` into the `:oidc` strategy. 4.14+ fails `mix compile --warnings-as-errors` until this exists. 3. Decide and implement the `email_verified` handling: a confirmation add-on monitoring `:email`, or `trust_email_verified? true` if the IdP is trusted to assert ownership. 4. Migrate existing accounts: move `users.oidc_id` into `user_identities` as the provider's `iss`/`sub` pair. See open questions — this is the step that can lock every existing member out of SSO. 5. Adapt the custom flows: `register_with_oidc`, `link_oidc_id`, `OidcEmailCollision`, `LinkOidcAccountLive`, `OidcRoleSync`. 6. Remove the `GHSA-777c-2fxx-qr28` entry and its comment block from `.deps_audit_ignore`. 7. Re-test against the Rauthy deployment; Authentik and Keycloak if available. ## Open questions - **Existing users.** With `identity_resource` configured, what does 4.15 do on the first login of a user who has no `user_identities` row — link the existing user, create a duplicate, or reject? This decides whether step 4 is a one-line backfill or a careful migration. Verify against the 4.15 source, not the changelog. - **Backfill key.** We store `sub` in `users.oidc_id` but not `iss`. Can `iss` be derived from our single configured provider for the backfill, or does the first post-upgrade login have to establish the pair? - **Provider trust.** Does our Rauthy deployment reliably assert `email_verified`? `rauthy-bootstrap/clients.json` does not say; this needs checking against the instance. - **Session renewal.** Does 4.15 renew the session id itself, or does the host application have to do it? Determines whether the session-fixation advisory is closed by the bump alone. ## Acceptance criteria - `just ci` green with no `GHSA-777c-2fxx-qr28` entry in `.deps_audit_ignore`, and `mix deps.audit --ignore-file .deps_audit_ignore` reporting no findings. - An existing member who previously signed in via OIDC can still sign 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. - The session id changes across authentication (regression test for session fixation). - A failed or cancelled OIDC callback leaves no reusable `session_params` entry behind (regression test for the replayable-state advisory). - Migration applies cleanly on a database holding existing `users.oidc_id` values, and rolls back cleanly. ## Notes - Renovate PR #568 raises the constraint to `~> 4.15.0` but carries no `mix.lock`, because its artifact step cannot compile 4.15 against the current code. Close it, or let this issue supersede it. - #564 duplicates this issue and states the exposure incorrectly; close it in favour of this one.
moritz changed title from Migrate OIDC to ash_authentication identity_resource (UserIdentity) and unpin to 4.14+ to Migrate OIDC to ash_authentication identity_resource (UserIdentity) and unpin to 4.15+ 2026-10-06 15:34:53 +02:00
moritz self-assigned this 2026-10-06 16:20:49 +02:00
Sign in to join this conversation.
No assignees
1 participant
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#557
No description provided.