feat(security): add route-specific rate limits for /auth and /r/:reference (#153) - #178
Open
Muhd010 wants to merge 1 commit into
Open
feat(security): add route-specific rate limits for /auth and /r/:reference (#153)#178Muhd010 wants to merge 1 commit into
Muhd010 wants to merge 1 commit into
Conversation
…rence (determined-001#153) Apply strictRateLimit (20/min per IP) to the /auth route, which is a sensitive authentication surface that triggers Horizon account lookups and amplifies outbound traffic. At the previous global cap of 120/min, IP rotation made brute-force or credential-stuffing attacks trivially scalable. Give /r/* its own receipt limiter (60/min per IP) — tighter than the global 120 cap but looser than the strict bucket, since buyers legitimately refresh public receipts. Add tests confirming that the 21st request within the window returns 429 for both /auth and /r/:reference routes. Closes determined-001#153 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
|
@Muhd010 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
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.
Overview
This PR adds route-specific rate limits for the sensitive
/authroute and the public receipt route/r/:referenceto prevent abuse and improve security posture.Related Issue
Closes #153
Changes
[MODIFY]
apps/api/src/index.tsApply
strictRateLimit(20/min per IP) to the/authroute. This route triggers Horizon account lookups on every attempt, making it both an authentication surface and an outbound-traffic amplifier. At the previous global cap of 120/min, IP rotation made brute-force or credential-stuffing attacks trivially scalable.Create a receipt-specific rate limiter for
/r/*routes (60/min per IP) — tighter than the global 120 cap but looser than the strict 20/min bucket, since buyers legitimately refresh public receipts.[ADD]
apps/api/test/routes/rate-limit.test.ts/authwithin the rate limit window returns 429./authwithin the rate limit window returns 429./r/:referencehas its own rate limiter distinct from the global cap (4th request returns 429 when limit is 3).Verification Results
Acceptance Criteria
/authreturns 429 past the strict limit/r/:referencehas a limiter distinct from the global cap