Repository navigation
fix(account): rate limit token session attempts per account - #14880
Conversation
|
Review complete. No blocking issues — approved ✅; 1 nitpick below. 🧹 Nitpicks (1) — 🟢 1 low
The change extends the abuse/rate-limit protection on three account token-verification routes by pairing a
One low-severity issue was found: with multiple keys the rate-limit reporting closure appends a second set of Reviewed commit: 3c2a64f |
🔵 Tier A · Mergeable after minor fixes
The token, magic-URL, and phone session routes now apply an additional per-account abuse limit alongside the existing IP-and-user limit. The account-scoped key includes the project, route, and submitted user ID so accounts with matching IDs in different projects are isolated. Latest changes: The latest commits add the project ID to the account-scoped abuse key on all three token-session routes.
Fix with agent prompt### Issue 1
app/controllers/api/account.php:1409
**Test the per-account limit across IPs**
The existing abuse test covers email sign-in from one IP, so it does not verify that these new keys enforce a shared per-account cap across different IPs. An E2E case exercising the token-session route from multiple source IPs would cover the behavior this change adds.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.📂 Walkthrough · 1
⏳ Still open from earlier reviews · 1
✅ Fixed since the last review · 1
Reviewed the commits since |
| )) | ||
| ->label('abuse-limit', 10) | ||
| ->label('abuse-key', 'ip:{ip},userId:{param-userId}') | ||
| ->label('abuse-key', ['ip:{ip},userId:{param-userId}', 'url:{url},userId:{param-userId}']) |
There was a problem hiding this comment.
Test the per-account limit across IPs
The existing abuse test covers email sign-in from one IP, so it does not verify that these new keys enforce a shared per-account cap across different IPs. An E2E case exercising the token-session route from multiple source IPs would cover the behavior this change adds.
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/controllers/api/account.php
Line: 1409
Comment:
**Test the per-account limit across IPs**
The existing abuse test covers email sign-in from one IP, so it does not verify that these new keys enforce a shared per-account cap across different IPs. An E2E case exercising the token-session route from multiple source IPs would cover the behavior this change adds.
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.🟡 Minor · testing · Reply if this doesn't apply.
Security rulesNo new WARNING or ERROR findings from security rules. 6 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…ount fix(account): rate limit token session attempts per account (cherry picked from commit d71104d)
Token session routes (
POST /v1/account/sessions/token,PUT /v1/account/sessions/magic-url,PUT /v1/account/sessions/phone) now also count attempts per account per route, alongside the existing IP + user key, using the arrayabuse-keyform the abuse hook already supports.Details are tracked internally.
Tested:
php -lon the changed file.