Skip to content

fix(security): auth/session hardening from the pentest - #46

Merged
ClaraVnk merged 1 commit into
mainfrom
feat/sec-auth-hardening
Jun 30, 2026
Merged

fix(security): auth/session hardening from the pentest#46
ClaraVnk merged 1 commit into
mainfrom
feat/sec-auth-hardening

Conversation

@ClaraVnk

Copy link
Copy Markdown
Contributor

Pentest remediation (auth/session). Findings #2, #4, #6, #7, #8.

Tests for each. Full suite 226 passed; ruff + mypy(strict) green.

Address the cookie-auth and login findings:

- is_active on the web surface: `resolve_current_user` now rejects a deactivated
  account (it only re-fetched the user before), matching the API — deactivation
  revokes web access immediately instead of lingering until the JWT expires.
- Constant-time login: `authenticate_local` runs an Argon2 verify (against a dummy
  hash) even when the email is unknown, removing the user-enumeration timing oracle.
- CSRF defense-in-depth: the security middleware rejects state-changing (POST/PUT/
  PATCH/DELETE) requests whose `Origin` doesn't match the host. Browser forms send a
  matching Origin; the agent/curl/Bearer API omit it (and carry no ambient cookie).
- Cookie `Secure` everywhere except local dev (new `settings.cookie_secure`), so a
  non-production HTTPS deployment no longer ships cookies over plaintext.
- `/docs`, `/redoc`, `/openapi.json` are disabled in production (info disclosure).

Tests: cross-origin POST blocked / no-Origin allowed, the cookie_secure matrix, a
deactivated user losing web access, and the login unknown/wrong/inactive paths. Full
suite 226 passed; ruff + mypy(strict) green.
@ClaraVnk
ClaraVnk merged commit 2f17123 into main Jun 30, 2026
4 checks passed
@ClaraVnk
ClaraVnk deleted the feat/sec-auth-hardening branch June 30, 2026 21:05
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