Skip to content

πŸ›‘οΈ Sentinel: Dual Target/IP Rate Limiting for Authentication Server Actions - #99

Open
projectamazonph wants to merge 1 commit into
mainfrom
fix/dual-rate-limiting-8652958142022058832
Open

πŸ›‘οΈ Sentinel: Dual Target/IP Rate Limiting for Authentication Server Actions#99
projectamazonph wants to merge 1 commit into
mainfrom
fix/dual-rate-limiting-8652958142022058832

Conversation

@projectamazonph

Copy link
Copy Markdown
Owner

πŸ›‘οΈ Sentinel: Dual Target/IP Rate Limiting for Authentication Server Actions

🚨 Severity: HIGH
πŸ’‘ Vulnerability: Previously, the authentication actions (signUpAction and signInAction) were rate-limited solely by lowercase email address (target-based targeting). This made the application vulnerable to distributed credential stuffing or brute-force attacks where an attacker rotates the target email addresses to completely bypass the target-based limits, potentially flooding the server actions, abusing database queries, and causing performance degradation.
🎯 Impact: Credential stuffing, brute-forcing, server resource exhaustion.
πŸ”§ Fix: Implemented a Dual-Target/IP Rate-Limiter helper (rateLimitDual) that rate-limits by both target email and client IP address (using X-Forwarded-For first entry or X-Real-IP fallback). Integrated it into both authentication actions.
βœ… Verification: Comprehensive new unit tests added in src/lib/__tests__/rate-limit.test.ts covering multiple IP header combinations and sliding window mechanics. Verified that the test coverage of rate-limit.ts has increased to 92.59%, and all linting/building checks pass cleanly.


PR created automatically by Jules for task 8652958142022058832 started by @projectamazonph

- Implement `rateLimitDual` helper function in `src/lib/rate-limit.ts` to combine both email-based and IP-based rate limiting.
- Retrieve the client IP address securely via `X-Forwarded-For` first IP or fallback to `X-Real-IP`.
- Gracefully bypass IP rate limiting in environments/test setups where headers are not available.
- Refactor `signUpAction` and `signInAction` inside `src/app/actions/auth.ts` to call the new dual rate-limiter.
- Update `setup.ts`, `auth-actions.test.ts`, `progress-actions.test.ts`, and `tool-actions.test.ts` to properly mock asynchronous Next.js 15 `headers()`.
- Add a comprehensive test suite `src/lib/__tests__/rate-limit.test.ts` covering sliding window limits and IP headers, elevating `rate-limit.ts` coverage to 92.59%.

Co-authored-by: projectamazonph <286085559+projectamazonph@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 31, 2026 13:00
@google-labs-jules

Copy link
Copy Markdown
Contributor

πŸ‘‹ Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a πŸ‘€ emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants