Skip to content

Use constant-time comparison for secret key in SecretKeyFilter - #24888

Open
bunlongheng wants to merge 1 commit into
goauthentik:mainfrom
bunlongheng:fix/secret-key-constant-time-compare
Open

Use constant-time comparison for secret key in SecretKeyFilter#24888
bunlongheng wants to merge 1 commit into
goauthentik:mainfrom
bunlongheng:fix/secret-key-constant-time-compare

Conversation

@bunlongheng

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant