RocketChat / RocketChat/Rocket.Chat
Plan: Enhance Login Protection and Fix Email Bypass
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
This plan addresses a security gap where login protection is bypassed when using email addresses for login, and improves the IP whitelist to support CIDR ranges.
User Review Required
[!IMPORTANT]
The fix for email-based login protection will now block failed login attempts against a specific email address, which was previously missing. This enhances security but may change behavior for users who frequently mistype their passwords when logging in with email.
Proposed Changes
Authentication Logic
[MODIFY] restrictLoginAttempts.ts
- Update
isValidAttemptByUserto extract eitherusernameoremailfromlogin.methodArguments[0].user. - Update
saveFailedLoginAttemptsto capture theemailifusernameis unavailable in the method arguments. - Import
isIpInCidrRangefrom@rocket.chat/server-fetchto support CIDR matching inisValidLoginAttemptByIp.
Verification Plan
Automated Tests
- I will create or update unit tests for
restrictLoginAttempts.tsto verify:- Failed logins with email are correctly blocked after the threshold.
- CIDR ranges in the whitelist correctly allow access.
Manual Verification
- I'll simulate failed login attempts using the
LoginProtectionlogger to verify that the correct identifiers are being processed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with apps/meteor/app/authentication/server/lib/restrictLoginAttempts.ts and read isValidAttemptByUser, saveFailedLoginAttempts, and isValidLoginAttemptByIp. Review the existing unit tests for restrictLoginAttempts.ts before running them. Done means email-based failed logins are blocked at the threshold and CIDR ranges in the whitelist allow access, with logger-based manual verification of identifiers.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- authentication, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100