Limit password reset requests and sign-in attempts closes #681 #687

Merged
simon merged 8 commits from issue/mitgliederverwaltung-681 into main 2026-11-14 14:03:15 +01:00
Owner

closes #681

Description of the implemented changes

The changes were:

  • Bugfixing
  • New Feature
  • Breaking Change
  • Refactoring

Sign-in security: password reset mails and password sign-in attempts are limited, and the reset page gives the same answer for every address.

What has been changed?

  • Key client IP on the proxy-appended X-Forwarded-For entry
  • Limit password reset mails per address and requests per client IP
  • Run the reset request in the background so timing hides known addresses
  • Limit password sign-in attempts per client IP and address
  • Count the password check when linking an OIDC account against the sign-in limit
  • Confirm a password reset request on the page in plain words
  • Note the limits on password reset and sign-in

Definition of Done

Code Quality

  • No new technical depths
  • Linting passed
  • Documentation is added were needed

Accessibility

  • New elements are properly defined with html-tags
  • Colour contrast follows WCAG criteria
  • Aria labels are added when needed
  • Everything is accessible by keyboard
  • Tab-Order is comprehensible
  • All interactive elements have a visible focus

Testing

  • Tests for new code are written
  • All tests pass
  • axe-core dev tools show no critical or major issues

Additional Notes

  • Release 1.6.0.
  • Larger commits: "Limit password reset mails per address and requests per client IP" (10 files, +410) adds Mv.Accounts.AuthRateLimit (Hammer, ETS, sliding window) and the LimitAuthAttempts preparation; "Limit password sign-in attempts per client IP and address" (8 files, +316); "Confirm a password reset request on the page in plain words" (10 files, +250, incl. translations); "Key client IP on the proxy-appended X-Forwarded-For entry" (+158).
  • Behavior a reviewer might not expect:
    • The real reset request (user lookup, token, mail) runs in a task under Mv.TaskSupervisor; the action itself always returns "no user", so known, unknown and limited addresses look the same from outside, including the response time.
    • Limits live in ETS per node; a restart resets them. Defaults are in Mv.Accounts.AuthRateLimit; config :mv, :auth_rate_limit, <bucket>: [scale_ms:, limit:] overrides one.
    • The per-client sign-in limit (30 per 5 minutes) can refuse a correct password for up to 5 minutes for everyone behind one shared IP (carrier NAT, a shared Wi-Fi) after 30 attempts from it. Accepted as a risk.
    • Behind a proxy, the client is X-Real-IP or the last X-Forwarded-For entry. The proxy must append to X-Forwarded-For (or set X-Real-IP), otherwise all clients share the proxy's budget. The /auth/* HTTP routes only see X-Forwarded-For.
    • The browser tab titles of /sign-in, /register and /reset now follow their heading; /register was titled "Sign in".
  • Field errors of the sign-in library (incl. the new limit message) are not linked to their field for screen readers; that is a library-wide gap, not new here.
closes #681 ## Description of the implemented changes The changes were: - [x] Bugfixing - [x] New Feature - [ ] Breaking Change - [ ] Refactoring Sign-in security: password reset mails and password sign-in attempts are limited, and the reset page gives the same answer for every address. ## What has been changed? - Key client IP on the proxy-appended X-Forwarded-For entry - Limit password reset mails per address and requests per client IP - Run the reset request in the background so timing hides known addresses - Limit password sign-in attempts per client IP and address - Count the password check when linking an OIDC account against the sign-in limit - Confirm a password reset request on the page in plain words - Note the limits on password reset and sign-in ## Definition of Done ### Code Quality - [ ] No new technical depths - [x] Linting passed - [x] Documentation is added were needed ### Accessibility - [ ] New elements are properly defined with html-tags - [ ] Colour contrast follows WCAG criteria - [ ] Aria labels are added when needed - [ ] Everything is accessible by keyboard - [ ] Tab-Order is comprehensible - [ ] All interactive elements have a visible focus ### Testing - [x] Tests for new code are written - [x] All tests pass - [ ] axe-core dev tools show no critical or major issues ## Additional Notes - Release 1.6.0. - Larger commits: "Limit password reset mails per address and requests per client IP" (10 files, +410) adds `Mv.Accounts.AuthRateLimit` (Hammer, ETS, sliding window) and the `LimitAuthAttempts` preparation; "Limit password sign-in attempts per client IP and address" (8 files, +316); "Confirm a password reset request on the page in plain words" (10 files, +250, incl. translations); "Key client IP on the proxy-appended X-Forwarded-For entry" (+158). - Behavior a reviewer might not expect: - The real reset request (user lookup, token, mail) runs in a task under `Mv.TaskSupervisor`; the action itself always returns "no user", so known, unknown and limited addresses look the same from outside, including the response time. - Limits live in ETS per node; a restart resets them. Defaults are in `Mv.Accounts.AuthRateLimit`; `config :mv, :auth_rate_limit, <bucket>: [scale_ms:, limit:]` overrides one. - The per-client sign-in limit (30 per 5 minutes) can refuse a correct password for up to 5 minutes for everyone behind one shared IP (carrier NAT, a shared Wi-Fi) after 30 attempts from it. Accepted as a risk. - Behind a proxy, the client is `X-Real-IP` or the **last** `X-Forwarded-For` entry. The proxy must append to `X-Forwarded-For` (or set `X-Real-IP`), otherwise all clients share the proxy's budget. The `/auth/*` HTTP routes only see `X-Forwarded-For`. - The browser tab titles of `/sign-in`, `/register` and `/reset` now follow their heading; `/register` was titled "Sign in". - Field errors of the sign-in library (incl. the new limit message) are not linked to their field for screen readers; that is a library-wide gap, not new here.
simon merged commit 83b4d4ec31 into main 2026-11-14 14:03:15 +01:00
simon deleted branch issue/mitgliederverwaltung-681 2026-11-14 14:03:15 +01:00
Sign in to join this conversation.
No description provided.