Harden the login flow: new session at sign-in, signed ID tokens, same-origin requests, headers
From an audit of the Authentik login, run against a fake OIDC provider: - Session fixation: the session id wasn't changed at sign-in, so one planted beforehand (from another page on the domain) became signed in as the victim. It is regenerated now. - Requests from another origin: SameSite=Lax doesn't stop another app on the same parent domain, and a body-less POST (stop a guest, rotate a token) needs no preflight. Every POST/PUT/PATCH/DELETE, and GET /auth/logout, is refused when Sec-Fetch-Site (or, for older browsers, Origin) says it came from elsewhere. The agent endpoint is exempt: it uses a token. - ID token signature: openid-client checks a token's claims but, as OIDC allows for a token from the token endpoint, not its signature, so the login rested on HTTPS to Authentik alone. The signature is now verified against the provider's published keys (jose, now a declared dependency). - SESSION_SECRET: production refuses to start without one (the fallback is in the source code) and warns when it is the .env.example placeholder or short. - Response headers: frame-ancestors 'none', X-Frame-Options, nosniff, Referrer-Policy; the framework name is no longer sent. - A failed sign-in shows a plain page and is audited (session / login_failed, with address and reason, no tokens); sign-in is limited to 20 attempts a minute per address so the audit log and session store can't be flooded. - A failed OIDC discovery (provider down at the first sign-in) was remembered until restart; it is retried now. Tests run the real app against the fake provider; switching each fix off in turn makes the matching tests fail. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
73b86d88de
commit
2dac273b1d
12 files changed
+681
-18
No files matched your search
@@ -3,6 +3,8 @@ APP_BASE_URL=https://homelab.example.lan
|
||||
|
||||
# Random long string used to sign session cookies. Generate with:
|
||||
# node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
||||
# Required in production: without it the app refuses to start (the alternative is a value that is
|
||||
# in the source code). Changing it signs everyone out.
|
||||
SESSION_SECRET=change-me-to-a-random-64-char-hex-string
|
||||
|
||||
# 32-byte (64 hex char) key used to encrypt stored integration API tokens, and the
|
||||
|
||||
Reference in new issue
Block a user