Skip to content

rbac: use constant-time comparison in SecretKeyFilter - #24888

Merged
rissson merged 1 commit into
goauthentik:mainfrom
bunlongheng:fix/secret-key-constant-time-compare
Aug 10, 2026
Merged

rissson merged 1 commit into
goauthentik:mainfrom
bunlongheng:fix/secret-key-constant-time-compare

Conversation

@bunlongheng

Copy link
Copy Markdown
Contributor

Noticed SecretKeyFilter compares the incoming token against settings.SECRET_KEY with a plain ==. That filter hands back the full queryset (bypassing object-level perms) when the key matches, and it's wired into the crypto and brands APIs, so the comparison is worth doing in constant time to avoid leaking anything through timing.

The rest of the codebase already does this - token_secret_key in authentik/api/authentication.py uses hmac.compare_digest for the exact same SECRET_KEY check, so this just brings the filter in line with that.

Behavior is unchanged for a correct key, and the None guard stays in front so we never hand compare_digest a null token.

@bunlongheng
bunlongheng requested a review from a team as a code owner August 7, 2026 20:44
@netlify

netlify Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit 5b817f6
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6a7643b08a123f0008266c50
😎 Deploy Preview https://deploy-preview-24888--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Aug 7, 2026

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 5b817f6
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6a7643b0b47d2e0008b31553
😎 Deploy Preview https://deploy-preview-24888--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@rissson rissson changed the title Use constant-time comparison for secret key in SecretKeyFilter rbac: use constant-time comparison in SecretKeyFilter Aug 10, 2026
@rissson rissson self-assigned this Aug 10, 2026
@rissson rissson added area:backend backport/version-2026.2 Add this label to PRs to backport changes to version-2026.2 backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5 backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8 labels Aug 10, 2026
@codecov

codecov Bot commented Aug 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.33%. Comparing base (1c4e990) to head (5b817f6).
⚠️ Report is 36 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24888      +/-   ##
==========================================
- Coverage   91.37%   91.33%   -0.04%     
==========================================
  Files        1137     1137              
  Lines       71591    71592       +1     
  Branches     3875     3875              
==========================================
- Hits        65416    65391      -25     
- Misses       6140     6166      +26     
  Partials       35       35              
Flag Coverage Δ
conformance 34.83% <50.00%> (+<0.01%) ⬆️
e2e 39.54% <50.00%> (+<0.01%) ⬆️
integration 30.95% <50.00%> (-0.46%) ⬇️
rust 38.89% <ø> (ø)
unit 93.03% <100.00%> (+<0.01%) ⬆️
unit-migrate 93.06% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.2 created: #24946

@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.5 created: #24947

@authentik-cherry-pick

Copy link
Copy Markdown
Contributor

🍒 Cherry-pick to version-2026.8 created: #24948

rissson pushed a commit that referenced this pull request Aug 10, 2026
…4888 to version-2026.5) (#24947)

rbac: use constant-time comparison in SecretKeyFilter (#24888)

Co-authored-by: Bunlong Heng <[email protected]>
rissson pushed a commit that referenced this pull request Aug 10, 2026
…4888 to version-2026.2) (#24946)

rbac: use constant-time comparison in SecretKeyFilter (#24888)

Co-authored-by: Bunlong Heng <[email protected]>
rissson pushed a commit that referenced this pull request Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend backport/version-2026.2 Add this label to PRs to backport changes to version-2026.2 backport/version-2026.5 Add this label to PRs to backport changes to version-2026.5 backport/version-2026.8 Add this label to PRs to backport changes to version-2026.8

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants