Wrong current passwords on a password or e-mail change are rate limited per account #284

Closed
opened 2026-11-05 04:42:53 -05:00 by claude · 1 comment
Owner
  • Priority: medium (lets someone who holds a stolen access token guess the account password without limit)
  • Agent: coder
  • Depends on: #66
  • Decisions: none

Why

UsersController.ChangeMyPassword and the new ChangeMyEmail (#66) check the current password with UserManager.CheckPasswordAsync. That call does not count failures toward Identity's lockout. Someone holding a stolen access token can therefore guess the password through either endpoint without limit, which defeats the point of asking for the current password.

What changes

  • Check the current password in a way that counts failures toward lockout, for example SignInManager.CheckPasswordSignInAsync(user, password, lockoutOnFailure: true).
  • When the account is locked out, return 400 or 423 with a clear message, matching what sign-in reports.
  • Keep the error code PasswordMismatch for a wrong password.
  • Cover both endpoints.

Acceptance

  • Web.Tests, red first: after the configured number of wrong current passwords on either endpoint, the account is locked out, and the correct password is refused until the lockout ends.
  • dotnet test src/dotnet/tests/Ninlil.Web.Tests passes.

Source

Found while implementing #66.

- **Priority:** medium (lets someone who holds a stolen access token guess the account password without limit) - **Agent:** coder - **Depends on:** #66 - **Decisions:** none ### Why `UsersController.ChangeMyPassword` and the new `ChangeMyEmail` (#66) check the current password with `UserManager.CheckPasswordAsync`. That call does not count failures toward Identity's lockout. Someone holding a stolen access token can therefore guess the password through either endpoint without limit, which defeats the point of asking for the current password. ### What changes - Check the current password in a way that counts failures toward lockout, for example `SignInManager.CheckPasswordSignInAsync(user, password, lockoutOnFailure: true)`. - When the account is locked out, return 400 or 423 with a clear message, matching what sign-in reports. - Keep the error code `PasswordMismatch` for a wrong password. - Cover both endpoints. ### Acceptance - [ ] Web.Tests, red first: after the configured number of wrong current passwords on either endpoint, the account is locked out, and the correct password is refused until the lockout ends. - [ ] `dotnet test src/dotnet/tests/Ninlil.Web.Tests` passes. ### Source Found while implementing #66.
Author
Owner

Changing the approach, following owner decision Q-REL-6 (#260): Ninlil has no account lockout. Sign-in is rate limited (AdminLoginRateLimitOptions) instead, and the Identity lockout fields are being deprecated (#32, #33) and will be removed (#234). Counting wrong current passwords toward Identity lockout would bring those fields back to life and contradict that decision.

The problem still holds: someone holding a stolen access token can guess the current password on change-password and me/email without limit. The fix is therefore a rate limit on wrong current-password attempts, counted per account, in the same style as the sign-in limit. Over the limit the endpoints answer 429. No lockout, no change to the lockout fields, and sign-in is unchanged.

Changing the approach, following owner decision Q-REL-6 (#260): Ninlil has no account lockout. Sign-in is rate limited (`AdminLoginRateLimitOptions`) instead, and the Identity lockout fields are being deprecated (#32, #33) and will be removed (#234). Counting wrong current passwords toward Identity lockout would bring those fields back to life and contradict that decision. The problem still holds: someone holding a stolen access token can guess the current password on `change-password` and `me/email` without limit. The fix is therefore a rate limit on wrong current-password attempts, counted per account, in the same style as the sign-in limit. Over the limit the endpoints answer 429. No lockout, no change to the lockout fields, and sign-in is unchanged.
claude changed title from Changing your own password or e-mail address counts wrong current passwords toward account lockout to Wrong current passwords on a password or e-mail change are rate limited per account 2026-11-05 05:19:50 -05:00
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
lantea-one/ninlil#284
No description provided.