Authentik Hardening
Authentik Hardening
Section titled “Authentik Hardening”Your identity provider is the crown jewel: it is the single key to every application that uses SSO, and (behind an identity-aware proxy) a foothold toward the internal network. A flaw in Authentik is not one app down — it is every app down. This guide is the hardening checklist for a self-hosted Authentik instance. For installation and day-to-day use see Authentik installation; for putting apps behind it, Identity-Aware Proxies.
1. Trusted proxies — the forwarded-header bypass (most important)
Section titled “1. Trusted proxies — the forwarded-header bypass (most important)”Authentik resolves the client IP from X-Forwarded-For, but only trusts it from sources named
in AUTHENTIK_LISTEN__TRUSTED_PROXY_CIDRS. Get this wrong and you re-open
CVE-2024-47070 / GHSA-7jxf-mmg9-9hg7 (CVSS 9.0): an unparsable X-Forwarded-For: a
skipped a policy stage and allowed passwordless login to any account whose username was known.
The official Traefik guide shipped trustForwardHeader: true, so many instances were exposed.
Patched in 2024.6.5 / 2024.8.3 — but the NVD notes it “is not reproducible from behind a
correctly-configured reverse proxy,” so the residual risk is entirely your CIDR config.
- Name only the real reverse proxy (loopback + the tunnel/ingress address). Never
0.0.0.0/0. A whole shared Docker range (e.g.172.23.0.0/16) is too broad — every container on that network can then spoofX-Forwarded-Forand defeat IP-based policies, rate limits and session IP logging. - The proxy must OVERWRITE, not append to,
X-Forwarded-For. If it appends, the attacker’s leftmost value survives. - Where the proxy actually connects from matters. If cloudflared reaches Authentik via
localhost:28080→ docker-proxy, the source Authentik sees is the Docker gateway (172.23.0.1), not loopback. Trust that/32, not the whole/16. Verify after changing: a request through the tunnel must resolve to a real client IP, not the gateway.
Verified example (this operator’s stack): narrowing 127.0.0.0/8,::1/128,172.23.0.0/16 →
127.23.0.1/32 (the gateway) kept the tunnel resolving real client IPs while removing 22
containers’ ability to spoof. See the full model in
Reverse-Proxy & IAP Hardening.
2. Admin mode and admin access
Section titled “2. Admin mode and admin access”- Enable admin mode and disable password sign-in (SSO only). Keep
rootas break-glass via the Django console (ak shell), not a daily login. - Admin API calls need a PAT with the
admin_modescope; a plainapiPAT returns 403. Mint short-lived admin tokens on demand and revoke them immediately after use. ak shellbypasses all permission checks — use it when the API refuses (bulk ORM edits, flow-binding fixes, token minting), then verify the change from the outside.
3. Sign-in: MFA and flows
Section titled “3. Sign-in: MFA and flows”- Require MFA / passkeys for admins (and ideally everyone). Authentik supports WebAuthn and TOTP.
PolicyBinding.targetmust be thepolicybindingmodel_ptr_id, not theFlowStageBinding.pk. The wrong one silently creates an ungated binding that lets everyone through. A policy bound to the binding (not the stage) is what gates the stage.authenticator-validatewithwebauthnfirst indevice_classesauto-fires WebAuthn and hides TOTP. Don’t rely onnot_configured_action: skipas a safety net — WebAuthn-only users silently skip MFA.
4. Signing keys and secrets
Section titled “4. Signing keys and secrets”- The
signing_keysigns ID tokens for every app — a leak lets an attacker forge tokens for all of them. Protect it like a root credential; rotate on any suspicion; never commit it. - Providers created via ORM/API start with empty
grant_types→ code exchange fails withinvalid_request. Set["authorization_code", "refresh_token"]. signing_keymust be set orjwks_urireturns{}. Refresh tokens needoffline_accessinproperty_mappings. Keepaccess_token_validitysane (5 min default is too short for mail bridges / IAPs — but long TTLs widen the blast radius of a stolen token).
5. Outposts
Section titled “5. Outposts”- Outposts (e.g. the LDAP outpost used by TAK) are separate containers holding an
AUTHENTIK_TOKEN. Their cached view of users/groups lags new memberships by ~2–3 min. - Binds fail with
operationsErrorwhen the provider’s bind/flow wiring and the outpost’s settings disagree (login attrcnvsuid,membervsuniqueMember, and a bind flow that actually grants a session). Check the outpost logs alongside the server.
6. Post-upgrade verification
Section titled “6. Post-upgrade verification”Point upgrades can reset default-* flow bindings, MFA order and orphan stage bindings. After
every upgrade:
- List bindings on
default-authentication-flow— check count and order. - Confirm each
*-mfa-requiredstage is bound, with its policy on the binding. - Confirm the identification stage still points at its passwordless / WebAuthn / password stages.
- Test sign-in as: normal user (password, passkey), admin (password + MFA, passkey).
- The
subclaim format changes across versions (UUID → SHA256). Compare against storedprovider_uidvalues; check for orphans (provider_name='oidc' AND user_id IS NULL). - Export changed flows to version control.
7. Backup
Section titled “7. Backup”Back up the database on a schedule (Authentik’s backup script dumps authentik_db). After a DB
restore, PostgreSQL sequences for authentik_core_user can desync and user creation silently
fails with HTTP 405 — setval(...) to fix.
Related
Section titled “Related”- Reverse-Proxy & IAP Hardening — the forwarded-header trust model
- Identity-Aware Proxies — putting apps behind Authentik
- Authentik installation · backup
- MFA & Passkeys