Repository navigation
fix(auth): per-purpose throttles, per-address sign-in backoff, constant-work login (#688) - #874
Merged
Merged
Conversation
Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
… throttles (#688) Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
…efusal (#688) GetByEmail now matches LOWER(email) and resolves a legacy case-variant duplicate to the exact spelling, then the oldest row. Login normalises the address before the lookup. An unknown address is compared against a hash made at start-up with the live hasher, and a disabled account against its own hash, so neither answers faster than a wrong password. Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
…urce (#688) Failed sign-ins are counted per normalised address, hashed, in the store #689 added. The tenth failure locks the address for fifteen minutes; the lock is not extended by refused attempts and a password reset ends it. A locked address answers 429 LOGIN_LOCKED with Retry-After, and every failed sign-in is audited with the address hashed. Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
…gn-up (#688) Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
#688) Signed-off-by: alex-dembele <alexandredembele16@gmail.com>
Base automatically changed from
689-securityauth-mfa-challenge-codes-can-be-guessed-without-limit-no-attempt-counter-no-rate-limit
to
master
October 2, 2026 11:36
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 #688
Stacked on #689 (PR #871): it reuses #689's
authmfa.AttemptStorefor the per-address lock. Base is #689's branch; once #871 merges, GitHub retargets this PR to master. Spec:docs/688_AUTH_THROTTLE.md.What changes
Retry-Afterheader pluscode/retry_afterin the body. Sign-in and sign-up say how long to wait, in FR and EN.GetByEmailmatchesLOWER(email), and legacy duplicates resolve deterministically.Verification
Backend gate (
cd backend && go build ./... && go vet ./... && go test ./... -race): BUILD_OK · VET_OK · TEST_OK, 80 packagesok, 0FAIL.Frontend gate:
npx tsc -b --noEmitexit 0 ·npx vitest run→ 102 files, 950 tests passed ·npm run build→ built in 4.97s ·eslint src/features/auth→ 2 errors, both already on master, inMFAEnrollmentBanner.tsx:61andMFAPostAhaPrompt.tsx:64, neither touched here. The 6 new tests inauthThrottle.test.tsxfail with the oldAuthScreen.tsxand pass with the new one.Named tests:
TestLogin_UnknownAddressCostsAHashComparison,TestLogin_EmailCaseInsensitive,TestAuthRateLimit_PasswordCheckDoesNotConsumeLoginBudget,TestLogin_PerAccountBackoff, plusTestLogin_Success/_NotFound/_Unauthorized,TestConfirmPasswordReset_ClearsLoginLock,TestGetByEmail_CaseInsensitive,TestGetByEmail_LegacyMixedCaseRows,TestLoginThrottle_LockedAddressAnswers429AndEveryFailureIsAudited,TestRateLimit_RefusalCarriesRetryAfterAndCode.Live (throwaway Postgres 18 + Redis, branch server, 2026-10-02):
Reproduction 1, run again:
Reproduction 2, run again (20 attempts each, wrong password, one source IP per request):
Reproduction 4, run again (account registered as awa.diallo@e2e.test):
Per-address backoff (criterion 3):
Browser (Vite against the branch server): sign-in on the locked address shows "Trop de tentatives. Réessayez dans 15 minutes."; sign-up in EN with the IP's sign-up budget used up shows "Too many attempts. Try again in 7 minutes."
Honest remainders
lower(email)index: login does a scan ofusersuntil a migration can be numbered (see bug(auth): registration refuses people sharing an email local part, accepts case-variant duplicates, and is not atomic #687). Follow-up issue not yet opened.Retry-Aftercan be early by up to one window.AuditService.LogFiberrecords rawX-Forwarded-Foras the audit IP. Two eslint errors inMFAEnrollmentBanner.tsxandMFAPostAhaPrompt.tsx.