Skip to content

fix: add rate limiting to /auth/login and /auth/register - #268

Open
RudraDudhat2509 wants to merge 1 commit into
OpenLake:mainfrom
RudraDudhat2509:feat/rate-limit-login
Open

fix: add rate limiting to /auth/login and /auth/register#268
RudraDudhat2509 wants to merge 1 commit into
OpenLake:mainfrom
RudraDudhat2509:feat/rate-limit-login

Conversation

@RudraDudhat2509

Copy link
Copy Markdown
Collaborator

Fixes #260

What changed

/auth/login had zero rate limiting — only /auth/forgot-password had a limiter. Combined with predictable @iitbhilai.ac.in usernames, this left the login endpoint open to unlimited automated password guessing.

Added the same express-rate-limit pattern already used for forgot-password — 10 requests per 15 minutes — to both /auth/login and /auth/register.

Testing

This PR was cut before #266 merged, so it re-adds the same backend test setup (jest + supertest + mongodb-memory-server) — no conflict, just means both PRs happen to touch package.json the same way; whichever merges first, the other will just no-op that part.

Test fires 11 login attempts with bad credentials against a live (in-memory) Mongo instance and asserts the limiter kicks in before all 11 go through.

Verified the test is meaningful — ran it against the old unprotected route first:

BEFORE (old code): 0 requests blocked — test fails, none of the 11 attempts get throttled
AFTER  (this fix):  request blocked with 429 once the limit is hit — test passes

Run with npm test in backend/.

Login had zero throttling — only /auth/forgot-password had a rate
limiter. Combined with predictable @iitbhilai.ac.in usernames, this
left login open to unlimited brute-force/credential-stuffing.

Added the same express-rate-limit pattern already used for
forgot-password (10 requests/15min for login and register).

Bootstraps backend testing (jest + supertest + mongodb-memory-server)
since this branch was cut before OpenLake#266 (same infra) was merged.

Fixes OpenLake#260
@vercel

vercel Bot commented Aug 13, 2026

Copy link
Copy Markdown

@RudraDudhat2509 is attempting to deploy a commit to the openlake's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@RudraDudhat2509, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8580b43d-4a28-4e30-b655-6d14b9f094bd

📥 Commits

Reviewing files that changed from the base of the PR and between 3a38811 and cd284fb.

⛔ Files ignored due to path filters (1)
  • backend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (3)
  • backend/package.json
  • backend/routes/auth.js
  • backend/tests/authRoutes.loginRateLimit.test.js

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

Security: no rate limiting on /auth/login (brute-force / credential-stuffing exposure)

1 participant