Skip to content

Harden login: brute-force throttle, timing equalisation, first-run race - #1460

Open
Tim020 wants to merge 2 commits into
devfrom
feature/security-login-hardening
Open

Tim020 wants to merge 2 commits into
devfrom
feature/security-login-hardening

Conversation

@Tim020

@Tim020 Tim020 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Failed logins are now throttled in memory per client address (20 free attempts) and per submitted username (5 free attempts), whether or not the username exists, with exponential lockout (30s doubling, capped at 15 min) answered with 429 and a Retry-After header. Successful login clears the username counter. Tables are size-bounded and decay; state lives on the app instance (injectable clock) so it is test/xdist safe.
  • Unknown usernames now run a bcrypt check against a dummy hash so response time does not reveal which accounts exist.
  • Login no longer holds a per-username lock across the bcrypt check; NamedLockRegistry now discards locks once idle so it cannot grow from user-supplied names.
  • Minimum password length raised from 6 to 8 (server validation, both client/ and client-v3/ validators and hints); admin-reset temporary passwords now use 4 words.
  • First-run / user creation (/api/v1/auth/create and /api/v2/users) runs under a single lock with the has-any-users check inside it, so concurrent first-run requests cannot create two admins. A one-time setup token was not added to keep this PR contained; the residual risk (anyone who can reach a fresh server first can claim the admin account) is documented in the getting-started docs.
  • Docs updated (getting started, user config).

Tests

  • New backend tests: throttle unit tests (fake clock), 429/Retry-After flow, unknown-user throttling, dummy-hash path, min length, 4-word temp passwords, concurrent first-run on both endpoints, lock pruning. Existing tests updated for the new minimum.
  • Playwright: added throttle and short-password checks to the auth spec; full chromium suite passes (227). Client lint/typecheck/vitest pass for both clients; ruff and full pytest pass.

🤖 Generated with Claude Code

… serialise first-run user creation

- In-memory per-IP and per-username throttle with exponential lockout (429 + Retry-After)
- Verify against a dummy bcrypt hash for unknown usernames
- Login no longer holds a per-username lock; NamedLockRegistry prunes idle locks
- Minimum password length 8 (server and both clients); temporary passwords use 4 words
- First-run/user creation runs under one lock with the has-any-users check inside it
- Tests, docs and E2E coverage

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Tim020 Tim020 added the claude Issues created by Claude label Oct 19, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation client Pull requests changing front end code large-diff server Pull requests changing back end code client-v3 labels Oct 19, 2026
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Client V3 Test Results

216 tests   216 ✅  0s ⏱️
 17 suites    0 💤
  1 files      0 ❌

Results for commit b4cb012.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Client Test Results

98 tests   98 ✅  0s ⏱️
 7 suites   0 💤
 1 files     0 ❌

Results for commit b4cb012.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Python Test Results

    1 files      1 suites   1m 16s ⏱️
1 063 tests 1 063 ✅ 0 💤 0 ❌
1 068 runs  1 068 ✅ 0 💤 0 ❌

Results for commit b4cb012.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Playwright E2E Results (firefox)

227 tests   227 ✅  2m 24s ⏱️
 14 suites    0 💤
  1 files      0 ❌

Results for commit b4cb012.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Playwright E2E Results (chromium)

227 tests   227 ✅  2m 27s ⏱️
 14 suites    0 💤
  1 files      0 ❌

Results for commit b4cb012.

♻️ This comment has been updated with latest results.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
7.6% Duplication on New Code (required ≤ 3%)
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

This branch has not been deployed

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

Labels

claude Issues created by Claude client Pull requests changing front end code client-v3 documentation Improvements or additions to documentation large-diff server Pull requests changing back end code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant