Files
sim/apps
Waleed 31bfcdd640 fix(auth): rate limit the password reset endpoints (#6553)
`/api/auth/forget-password` calls `auth.api.requestPasswordReset` without
headers, which bypasses Better Auth's rate limiter entirely — that limiter
lives in the HTTP router, not the endpoint. The route was an unthrottled
email-send amplifier keyed on any address a caller chose.

Add two dimensions via the existing route-helper family: a per-IP budget
before parsing (cheap pre-parse gate), and a per-recipient budget, since no
per-IP limit can stop a distributed attempt to bomb one mailbox. The recipient
key is normalized and hashed, so the bucket store never holds an address and
long inputs cannot inflate key cardinality. It is enforced before any user
lookup and identically whether or not the account exists, so a 429 is not an
account-existence oracle.

Also throttle `/api/auth/reset-password`, which had none and is an online
token-guessing surface.

Passing headers to `auth.api.*` is deliberately not the fix: Better Auth's
limiter throws an APIError that these routes' catch blocks project as a 500,
and it cannot express the per-recipient dimension.
2026-08-11 12:36:21 -07:00
..
…