Skip to content
SprecherEast
Issue 282

enhancement: Robot check, rate limit and even timing on forgot password

Back to our plan
Done
enhancementauthpriority: high

Problem

From the review of #277 (forgot/reset password on Payload's built-ins):

  • No robot check on forgot password. /forgot-password and Payload's own POST /api/users/forgot-password accept requests without Turnstile. The only limit is Payload's one email per account every 15 seconds, so someone could make the site send many reset emails across accounts.
  • Timing difference. Both answer measurably slower for an existing account, because Payload waits for the email to send. The words are identical, but the delay can reveal whether an account exists. Payload's own endpoint has the same behavior.

Proposed fix (native first, #262)

  1. Check what Payload offers: a beforeOperation hook on forgotPassword, auth.forgotPassword options, or disabling the REST endpoint in favor of the site's page.
  2. Then the tools the site already uses: the same Turnstile check as the contact form (decision 0003) on the page, and a per-IP limit (the existing SlidingWindowCounter, or Caddy, as for the form endpoint in #124).
  3. For timing: send the email after responding (Next's after(), already used in #260), or add a fixed minimum delay.

Record the findings per step on this issue before building.

Acceptance criteria

  • Not done: Forgot password has a robot check, on the page and the API route (or the API route is closed)
  • Not done: Requests are limited per IP
  • Not done: An existing and an unknown email take about the same time to answer
  • Not done: Tests cover each

Area

auth

Priority

Medium


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab