Summary
CVE-2026-82761 is a Time-of-check Time-of-use (TOCTOU) race condition (CWE-367) in the ash_authentication library (Ash Authentication for the Elixir/Ash Framework ecosystem) that allows a magic-link sign-in token, which is designed to be redeemable exactly once, to be replayed multiple times when redemption requests are sent concurrently. An attacker who obtains a leaked or intercepted magic link (e.g., via a mail-scanning gateway, browser history, proxy log, or shared inbox) can exploit the race to authenticate as the targeted user and obtain a full authenticated session. The issue carries a CVSS v4.0 base score of 9.1 (Critical).
Technical details
- Root cause: Magic link sign-in verifies the JWT and completes authentication before the token is revoked.
AshAuthentication.Strategy.MagicLink.SignInPreparationperforms revocation inside aQuery.after_actioncallback, andAshAuthentication.Strategy.MagicLink.SignInChangeperforms it inside anafter_transactionhook — both of which run only after the sign-in has already succeeded. - Concurrency flaw:
AshAuthentication.TokenResource.Actions.revoke/3writes the revocation record as an upsert rather than an insert that would conflict on duplicates. This means concurrent revocation attempts for the same token silently succeed instead of one of them failing, so nothing prevents multiple simultaneous redemptions of the same "single-use" token. - Trigger conditions: The attacker needs access to a valid, unexpired magic-link token (via leakage, interception, or a link-scanning security appliance that pre-fetches URLs) and must send multiple sign-in requests for that token in close succession to win the race.
- Attack vector: Network — no authentication or special privileges required to exploit the race itself, only possession of the token; default configuration (
single_use_token?enabled) is affected. - Impact: Full authentication bypass/session hijack for the targeted account — each successful race participant receives a valid user session token, resulting in high confidentiality and integrity impact.
Affected software
ash_authentication(team-alembic/ash_authentication):>= 3.9.0, <= 4.14.2>= 5.0.0-rc.0, <= 5.0.0-rc.13
- Affected components:
AshAuthentication.Strategy.MagicLink.SignInPreparation,AshAuthentication.Strategy.MagicLink.SignInChange,AshAuthentication.TokenResource.Actions
Severity
- CVSS v4.0 Base Score: 9.1 (Critical)
- Vector:
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:H/VI:H/VA:N/SC:N/SI:N/SA:N - (The vendor advisory additionally scores the issue as CVSS v3.1 6.8,
AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:N, reflecting the added complexity of the race-timing requirement under that scoring model.)
Mitigation and recommended actions
- Immediate: Upgrade
ash_authenticationto version 4.15.0 (for the 4.x line) or 5.0.0-rc.14 (for the 5.0 release-candidate line), both of which fix the token revocation race condition. - If immediate patching is not possible:
- On 5.0 release candidates, set
store_all_tokens?tofalseto serialize the affected read paths (note this has other implications for token storage behavior). - Shorten magic-link token lifetimes to reduce the exploitation window.
- Configure email/security gateways to avoid automatically following or pre-fetching links inside authentication emails, which can otherwise trigger unintended token consumption/leakage.
- On 5.0 release candidates, set

