Repository navigation
Conversation
al-maisan
added a commit
to al-maisan/Maple
that referenced
this pull request
Nov 25, 2026
…9s and expiry charges Review fixes on PR MaplePrivacyLabs#1684: - The guess budget is now checked on the request the submitted code selects, not on the newest request sharing the secret: a spent request stays closed even to its correct code, and a same-secret sibling can neither reopen it nor be shielded by it. Wrong-code guesses still charge the shared per-(account, secret) budget, per the MaplePrivacyLabs#1486 charging spec, with a regression covering several open requests sharing one secret. - Only a genuinely spent budget maps to the rate-limited response on both the user and platform paths; any other database failure propagates as an infrastructure error instead of a 24-hour 429. - Expired user requests are never charged: expiry returns before the charge, the guarded UPDATE filters to active rows, and a secret whose requests have all expired reports the failure without charging (new NoActivePasswordResetRequest distinction). Expiry coverage added. - The concurrent-initiation test now asserts the exact cap and that every initiation call itself succeeded, so a no-op path cannot pass.
…cyLabs#1486) Password-reset email codes previously had no durable guess budget, and reset initiation had no per-account email cap that survives restarts or holds across enclave processes: the process-local limiters in web/rate_limit.rs reset on restart and each replica kept its own allowance. Both limits now live in PostgreSQL, coordinated through the reset request rows themselves: - Guess budget: a failed_attempts counter on every reset request (user and platform). A wrong code charges the durable budget of the unconsumed requests carrying the submitted reset-secret hash, so a random secret cannot burn anyone else's budget; a correct code with the matching secret never charges. The budget is checked before the code is examined, so an exhausted request stays closed even to the correct code, mirroring the process-local limiter. - Email cap: creation counts the account's request rows inside a rolling hour under the user-row lock (the same serialization the credential-mutation flows use), and past the cap creates no request row and sends no email. Every response stays byte-identical to the ordinary generic initiation answer, preserving account-enumeration protections for unknown, OAuth-only, throttled and valid accounts. Both apply to legacy user confirmation, Transport V2 options and completion through the shared proof verifier, and platform/developer reset initiation and verification. The process-local limiters remain as cheap first-line guardrails. Coverage adds cross-process sharing across separate app states, concurrent wrong guesses and concurrent initiation over separate pooled connections, and the rolling-window boundary.
…9s and expiry charges Review fixes on PR MaplePrivacyLabs#1684: - The guess budget is now checked on the request the submitted code selects, not on the newest request sharing the secret: a spent request stays closed even to its correct code, and a same-secret sibling can neither reopen it nor be shielded by it. Wrong-code guesses still charge the shared per-(account, secret) budget, per the MaplePrivacyLabs#1486 charging spec, with a regression covering several open requests sharing one secret. - Only a genuinely spent budget maps to the rate-limited response on both the user and platform paths; any other database failure propagates as an infrastructure error instead of a 24-hour 429. - Expired user requests are never charged: expiry returns before the charge, the guarded UPDATE filters to active rows, and a secret whose requests have all expired reports the failure without charging (new NoActivePasswordResetRequest distinction). Expiry coverage added. - The concurrent-initiation test now asserts the exact cap and that every initiation call itself succeeded, so a no-op path cannot pass.
al-maisan
force-pushed
the
1486-durable-reset-limits
branch
from
November 25, 2026 08:22
f650af0 to
7e6d03f
Compare
Author
|
@AnthonyRonning Hi Anthony — took #1486 as an excuse to dig into the OpenSecret backend. Both reset limits (per-request guess budget, rolling-hour email cap) are now durable in Postgres instead of process-local. The charge is a guarded UPDATE scoped to the reset-secret hash, so a random secret can't burn someone else's budget; the email cap serializes through the user row the same way the credential-mutation flows already do. Every existing route contract keeps its exact responses, and there's cross-process + concurrent-connection coverage (commits signed). Happy to take #1483 next if this approach looks good. |
This branch has not been deployed
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.
Closes #1486.
What
Password-reset email codes had no durable guess budget, and reset initiation had no per-account email cap that survives restarts or holds across enclave processes: the process-local limiters in
web/rate_limit.rsreset on restart and each replica kept its own allowance.Both limits now live in PostgreSQL, coordinated through the reset request rows themselves (
failed_attemptscolumn + rolling-hour row count), for the legacy user confirm route, the Transport V2 options/completion routes through the shared proof verifier, and the platform (developer) routes.Guess budget semantics
Email cap semantics
Invariants kept
up.sql/down.sql, new columns default 0, two new indexes).Validation
Disposable dockerized Postgres 17, migrated with
diesel migration run(up and redo verified):cargo fmt --all -- --check: cleancargo clippy --locked --all-targets -- -D warnings: cleanAEAD_TAMPER_TEST_DATABASE_URLignored DB suites (--ignored --test-threads=1): all password-reset, recovery-route, recovery-db, tamper and oauth tests pass, including the existingpassword_reset_limitscontractsdb_compaction_*suites pass against theopensecret_agent_test_*-named database they requireOpen in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.