Username-Enumeration-Vulnerability - #175
Conversation
|
@kingjosmel 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! 🚀 |
|
Warning Review limit reached
Next review available in: 47 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughThe login controller now performs dummy bcrypt verification when no user is found and returns HTTP 401 with a generic invalid-credentials message. The corresponding test expectations were updated. ChangesLogin credential handling
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/login.controller.test.ts (1)
26-34: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick winTest the timing-equalization behavior as well.
This test would pass even if the dummy
bcrypt.comparecall were removed. Mockbcrypt.compareand assert it receives the supplied password plus a valid fixed hash, so the security requirement is protected against regression.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/login.controller.test.ts` around lines 26 - 34, Strengthen the user-not-found test around loginController by mocking bcrypt.compare and asserting it is called with the supplied password and a valid fixed hash, while retaining the existing 401 response assertions. Ensure the test verifies the dummy comparison used for timing equalization and would fail if that call were removed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/login.controller.test.ts`:
- Around line 26-34: Strengthen the user-not-found test around loginController
by mocking bcrypt.compare and asserting it is called with the supplied password
and a valid fixed hash, while retaining the existing 401 response assertions.
Ensure the test verifies the dummy comparison used for timing equalization and
would fail if that call were removed.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f19275c2-424e-4039-bcf2-d4e9bfb164b9
📒 Files selected for processing (2)
src/controllers/login.controller.tstests/login.controller.test.ts
Security Fix: Prevent Email Address Enumeration on Login
close #163
Overview
Standardizes the error response for non-existent users on the login endpoint to prevent email enumeration and mitigates potential timing attacks.
Changes
loginControllerto return401 Unauthorizedwith{ message: "Invalid credentials" }when a user is not found, matching invalid password responses.bcrypt.compareexecution when user lookup fails to equalize response timing and mitigate timing attacks.tests/login.controller.test.tsto assert the updated401status code and message.Summary by CodeRabbit
Bug Fixes
Tests