Skip to content

fix(server): rate-limit change-password guesses - #343

Merged
BaaRai merged 1 commit into
BaaRai:mainfrom
Coff0xc:fix/change-password-limit
Nov 18, 2026
Merged

BaaRai merged 1 commit into
BaaRai:mainfrom
Coff0xc:fix/change-password-limit

Conversation

@Coff0xc

@Coff0xc Coff0xc commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

POST /api/auth/change-password compared old_password with 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 TestPasswordChangeWaitBlocksByIPAndToken pass. Handler tests skip here without ARTEX_PG_DSN (same as the other change-password tests); CI runs them.

Copilot AI balanced review requested due to automatic review settings November 18, 2026 17:15

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@BaaRai BaaRai left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
BaaRai force-pushed the fix/change-password-limit branch from 17ee5da to 389825a Compare November 18, 2026 21:41
@BaaRai
BaaRai merged commit 12211c4 into BaaRai:main Nov 18, 2026
5 checks passed
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.

3 participants