task(auth): add per-uid rate limiting to passkey auth failures#20553
Draft
dschom wants to merge 1 commit into
Draft
task(auth): add per-uid rate limiting to passkey auth failures#20553dschom wants to merge 1 commit into
dschom wants to merge 1 commit into
Conversation
5d30e41 to
16d2bcd
Compare
9b2c4ed to
efd76ba
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds per-UID rate limiting for passkey authentication finish failures by propagating uid context through passkey verification errors and enforcing a new customs action when failures occur. This helps throttle repeated failed assertions against a specific account, reducing signal-noise compared to IP-only limits.
Changes:
- Extend
AppErrorpasskey failure helpers to optionally carry an internal-onlyuidfield (not serialized in responses). - Attach
uidto passkey verification failures once the credential owner is known, and consume it in the auth-server route to run a per-uid customs check on failure. - Add new
passkeyAuthFinishFailedrate-limit rules plus unit tests covering the new behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/fxa-auth-server/lib/routes/passkeys.ts | Runs a per-uid customs rate-limit check when authenticationFinish fails with an AppError that includes uid. |
| packages/fxa-auth-server/lib/routes/passkeys.spec.ts | Adds route tests ensuring customs per-uid failure recording and rate-limit error propagation. |
| packages/fxa-auth-server/config/rate-limit-rules.txt | Introduces passkeyAuthFinishFailed rules (uid + ip). |
| libs/accounts/passkey/src/lib/passkey.service.ts | Attaches uid to thrown passkey auth AppErrors after credential resolution. |
| libs/accounts/passkey/src/lib/passkey.service.spec.ts | Adds tests verifying uid is/ isn’t attached depending on failure stage. |
| libs/accounts/errors/src/index.spec.ts | Adds assertions that uid is attached when provided and not leaked to payload. |
| libs/accounts/errors/src/app-error.ts | Adds uid?: string to AppError and updates passkey error factories to accept optional uid. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+411
to
+417
| const failedAccount = await this.db.account(err.uid); | ||
| await this.customs.checkAuthenticated( | ||
| request, | ||
| err.uid, | ||
| failedAccount.email, | ||
| 'passkeyAuthFinishFailed' | ||
| ); |
Comment on lines
+166
to
+168
| passkeyRegisterStart : ip_uid : 10 : 10 minutes : 10 minutes : block | ||
| passkeyRegisterFinish : ip_uid : 10 : 10 minutes : 10 minutes : block | ||
| passkeyAuthFinishFailed : uid : 50 : 24 hours : 15 minutes : block |
Comment on lines
+21
to
+22
| loadAccountFailed : ip : 50 : 24 hours : 15 minutes : ban | ||
| passkeyAuthFinishFailed : ip : 50 : 24 hours : 15 minutes : ban |
| 'passkeyAuthFinishFailed' | ||
| ); | ||
| }); | ||
|
|
efd76ba to
ebea56d
Compare
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.
Because
This pull request
Issue that this pull request solves
Closes: FXA-13675
Checklist
Put an `x` in the boxes that apply
How to Test
rate-limit-rules.txtto set a tight `passkeyAuthFinishFailed` rule (e.g. 1 attempt per 10 minutes by uid) for fast verification