Repository navigation
Open
Description
Password-reset email codes currently have no database-backed guess budget, and reset initiation has no per-account email cap. This predates the recovery-code feature; the shared proof verifier introduced by #1470 makes the user reset paths a practical place to add durable limits. Platform/developer password resets need the same protection.
Implement both limits inside OpenSecret with PostgreSQL coordination across enclave processes. The edge sees the encrypted /v2/request carrier rather than the logical route, and there is no trusted client IP inside the enclave. A process-local limiter is insufficient.
Proposed policy, to confirm during implementation:
- Permit at most five incorrect email-code guesses per reset request. Charge failures only to active requests for the submitted account/project whose stored reset-secret hash matches the submitted secret; random secrets must not let an attacker exhaust someone else's real request. A correct code with a wrong secret must not consume the victim's guess budget either.
- Permit about five reset emails per account per rolling hour. Once capped, return the ordinary generic initiation response without creating another request or sending email. Preserve account-enumeration protections for unknown, OAuth-only, throttled and valid accounts.
- Apply the policy consistently to legacy user confirmation, V2 options/completion, and platform/developer reset initiation and verification. Valid repeated options checks must remain non-consuming and must not count as bad guesses.
- Use atomic database updates/transactions so concurrent requests and multiple enclave processes cannot exceed either budget. Define expiry, cleanup, exact fifth-attempt behavior, project/account scoping and interaction with completion/credential-change invalidation.
Acceptance coverage:
- Boundary and rolling-window tests for both budgets, including simultaneous initiation and simultaneous incorrect guesses over separate DB connections.
- Correct code/secret behavior before exhaustion, expiry, exhausted requests, several open requests, and completion races.
- Requests with an unrelated secret or account/project cannot burn another request's budget; guessing the secret and guessing the emailed code remain distinct.
- Throttled initiation sends no email and cannot be distinguished by status/body from other normal initiation outcomes.
- Tests cover user and platform resets, plus the real encrypted Transport V2 user paths.
- No plaintext email codes, reset secrets, passwords or sensitive payloads in logs or public errors.
Follow-up to Anthony's review: #1470 (review)
Metadata
Metadata
Assignees
Labels
No labels
Activity
AnthonyRonning commentedon Nov 10, 2026
I think we probably want a generic solution for this as well. Something where we can apply rate limits across the board for all of our API requests, and some config (hard coded directly in rust is fine) that specifies this?
We have other things too that likely benefit from rate limits we can apply on an api level. Whether we use postgresql for this or move it to some KV-style store. A naive v1 approach would be to keep it internal to the enclave for now, we only have a few distributed ones.
Add a generic request limiter and limit password resets (#1546)
Bind the durable reset budget to the code-selected request; narrow 42…
Add database-backed password-reset guess and email limits (MaplePriva…
Bind the durable reset budget to the code-selected request; narrow 42…