Repository navigation
fix(server): rate-limit change-password guesses - #343
Merged
Merged
Conversation
BaaRai
approved these changes
Nov 18, 2026
BaaRai
left a comment
Owner
There was a problem hiding this comment.
Reviewed: IP and token buckets, 429 with Retry-After, reset on success, and unauthenticated attempts are not counted. CI green.
POST /api/auth/change-password checked the current password with bcrypt and had no limiter. A stolen session could guess without backoff. Reuse the login limiter, keyed by client IP and by the session token, so rotating the source address with the same token still blocks. A successful change clears both buckets.
BaaRai
force-pushed
the
fix/change-password-limit
branch
from
November 18, 2026 21:41
17ee5da to
389825a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
POST /api/auth/change-passwordcomparedold_passwordwith bcrypt and did not use the login limiter. A stolen session could guess the current password without backoff.The handler now records each authenticated attempt on the same limiter type as login, keyed by client IP and by the session token. Either bucket can block and doubles up to the existing cap. A successful change clears both. Unauthenticated requests still return 401 and are not counted.
Tested:
go test ./server -run TestPasswordChangeWaitBlocksByIPAndTokenpass. Handler tests skip here withoutARTEX_PG_DSN(same as the other change-password tests); CI runs them.