Repository navigation
Conversation
Ayush7614
requested review from
MikeRyanDev,
davidmckayv,
guidovizoso,
mxmzb and
tylerslaton
as code owners
October 7, 2026 07:23
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.
What
The routes that verify something guessable had no bound on attempts at all.
POST /api/sign-in-requests/:id/submitandPOST /:id/use-savedcheck a typed password and, worse, the short numeric second-factor code — one request per guess, forever, with no counter, lockout, or delay anywhere in the service or the routes (verified by grep: the only 429s inserver/srcare vendor-side handling plus one pending-count cap in the desktop handoff).This adds the missing bound:
server/src/rate-limit.ts: a per-process sliding-window limiter as Hono middleware. Over-budget callers get 429 +Retry-Afterwith one fixed sentence; budgets key on the signed-in actor (spoof-proof on these authed routes), unauthenticated callers share oneanonymousbucket, expired buckets are pruned, and the key map itself is capped so distinct-key rotation cannot grow memory.server/src/passwords/routes.ts:submit+use-savedshare one code-attempt budget (60 per 10 minutes per person — far past mistyping, nowhere near a six-digit space),POST /creation gets its own hourly budget (30/hour). Reads and state transitions (finish/cancel/take-over, vault GET/DELETE) are untouched. The 429 path returns directly and never passes through the route error handler, so the no-secret-echo guarantee is preserved (asserted in tests).docs/architecture.md, including the honest per-process scope (N replicas ≈ N× budget).createSignInRoutestakes an optional 4th arg, so existing call sites compile unchanged.Verification (all run locally, all green)
server/tests/rate-limit.test.ts(cap, 429 + Retry-After, window reset, countdown, per-key isolation, pruning) andserver/tests/signin-submit-rate-limit.test.ts(shared submit/use-saved budget, no secret echo in 429, separate creation budget, reads unaffected, per-actor isolation, window reopen) — all pass, all use a fake clock, no waiting.server/tests/passwords-sign-in.test.ts17/17 pass with production defaults.bunx biome lint --error-on-warnings: clean.bun run --filter server typecheck: exit 0.passwords-store.integration.test.tsneeds a liveTEST_DATABASE_URLPostgres and fails identically on cleanmain— pre-existing environmental, unrelated.Original work for this repo: no open issue or PR covers server-side rate limiting (checked open issues/PRs and the codebase before starting); branch is fresh off current
upstream/mainwith nothing else on it.