recovery: consume token in transaction#19967
Merged
BeryJu merged 1 commit intogoauthentik:mainfrom Feb 3, 2026
Merged
Conversation
Token validation, user login, and token deletion were performed as separate non-atomic operations, allowing concurrent requests to reuse a single recovery token. Wrapped the operation in transaction.atomic() with select_for_update() to ensure exclusive access during token use.
✅ Deploy Preview for authentik-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
BeryJu
approved these changes
Feb 3, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #19967 +/- ##
==========================================
- Coverage 93.26% 93.22% -0.04%
==========================================
Files 968 968
Lines 53332 53391 +59
==========================================
+ Hits 49738 49775 +37
- Misses 3594 3616 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
authentik-automation bot
pushed a commit
that referenced
this pull request
Feb 3, 2026
security: prevent recovery token reuse via race condition Token validation, user login, and token deletion were performed as separate non-atomic operations, allowing concurrent requests to reuse a single recovery token. Wrapped the operation in transaction.atomic() with select_for_update() to ensure exclusive access during token use. Co-authored-by: kolega.dev <faizan@kolega.ai>
BeryJu
pushed a commit
that referenced
this pull request
Feb 3, 2026
…-2025.10) (#19981) recovery: consume token in transaction (#19967) security: prevent recovery token reuse via race condition Token validation, user login, and token deletion were performed as separate non-atomic operations, allowing concurrent requests to reuse a single recovery token. Wrapped the operation in transaction.atomic() with select_for_update() to ensure exclusive access during token use. Co-authored-by: Kolega.dev <security@kolega.ai> Co-authored-by: kolega.dev <faizan@kolega.ai>
authentik-automation bot
pushed a commit
that referenced
this pull request
Feb 3, 2026
security: prevent recovery token reuse via race condition Token validation, user login, and token deletion were performed as separate non-atomic operations, allowing concurrent requests to reuse a single recovery token. Wrapped the operation in transaction.atomic() with select_for_update() to ensure exclusive access during token use. Co-authored-by: kolega.dev <faizan@kolega.ai>
Contributor
|
🍒 Cherry-pick to |
BeryJu
pushed a commit
that referenced
this pull request
Feb 3, 2026
…-2025.12) (#19986) recovery: consume token in transaction (#19967) security: prevent recovery token reuse via race condition Token validation, user login, and token deletion were performed as separate non-atomic operations, allowing concurrent requests to reuse a single recovery token. Wrapped the operation in transaction.atomic() with select_for_update() to ensure exclusive access during token use. Co-authored-by: Kolega.dev <security@kolega.ai> Co-authored-by: kolega.dev <faizan@kolega.ai>
kensternberg-authentik
added a commit
that referenced
this pull request
Feb 4, 2026
* main: (26 commits) providers/saml: auto pull signature algorithm options (#17614) core, web: bump @isaacs/brace-expansion from 5.0.0 to 5.0.1 in /packages/prettier-config (#19990) web: bump @isaacs/brace-expansion from 5.0.0 to 5.0.1 in /web (#19989) stages/authenticator_webauthn: fix double JSON encoding of webauthn options (#19952) core: bump django from 5.2.10 to 5.2.11 (#19988) ci: allow setting assignee to fail (#19985) root: revert enterprise loading behaviour (#19485) web/flows: update flow background (#19974) providers/oauth2: use compare_digest for client_secret comparison (#19979) recovery: consume token in transaction (#19967) core: ask for token duration on recovery link/email by admin (#19875) core: bump aws-cdk-lib from 2.236.0 to 2.237.0 (#19958) web: bump the storybook group across 1 directory with 5 updates (#19960) core: bump library/nginx from `c881927` to `7fe5dda` in /website (#19961) core: bump gunicorn from 25.0.0 to 25.0.1 (#19959) core: bump goauthentik.io/api/v3 to 3.2026.2.0-rc1-1770129730 (#19973) lifecycle: bump shm size (#19369) crypto: Add ED25519 and ED448 support to the certificate builder (#19465) web/admin: Register stage elements. Fix linter warnings (#19948) web: bump knip from 5.82.1 to 5.83.0 in /web (#19962) ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Vulnerability identified and fix provided by Kolega.dev
Summary
Fixed a race condition vulnerability in the recovery token view that allowed token reuse via concurrent requests.
Vulnerability
The
UseTokenView.get()method performed token existence check, retrieval, user login, and token deletion as separate non-atomic operations. An attacker with a valid recovery token could exploit the race window to authenticate multiple times using the same token before it was deleted.Fix
Wrapped the entire token validation and consumption flow in
transaction.atomic()withselect_for_update()to ensure exclusive database row locking. This prevents concurrent requests from accessing the same token simultaneously, eliminating the race condition.