RocketChat / RocketChat/Rocket.Chat

IP whitelist for failed-login protection does not trim spaces, so valid whitelisted IPs can still get blocked

Open Beginner friendly
#39,915 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
46.1k
Forks
13.9k
Avg merge
3d 3h
Merged PRs (30d)
130

Description

When Block_Multiple_Failed_Logins_Ip_Whitelist contains comma-separated IPs with spaces after commas, Rocket.Chat does not trim the values before checking membership. As a result, whitelisted IPs can still be blocked by failed-login protection.

Affected file
apps/meteor/app/authentication/server/lib/restrictLoginAttempts.ts

Relevant code

const whitelist = String(settings.get('Block_Multiple_Failed_Logins_Ip_Whitelist')).split(',');

if (
	!settings.get('Block_Multiple_Failed_Logins_Enabled') ||
	!settings.get('Block_Multiple_Failed_Logins_By_Ip') ||
	whitelist.includes(ip)
) {
	return true;
}

Steps to reproduce

  1. Enable Block_Multiple_Failed_Logins_Enabled.
  2. Enable Block_Multiple_Failed_Logins_By_Ip.
  3. Set Block_Multiple_Failed_Logins_Ip_Whitelist to something like:
    127.0.0.1, 192.168.0.10
    
  4. Attempt repeated failed logins from 192.168.0.10.

Expected behavior
192.168.0.10 should be treated as whitelisted and should bypass IP-based failed-login blocking.

Actual behavior
The IP may still be blocked because the whitelist entry is stored as ' 192.168.0.10' and compared using exact string equality.

Root cause
The whitelist is split on commas but never normalized with .trim().

Suggested fix
Normalize the whitelist values before comparison, for example:

const whitelist = String(settings.get('Block_Multiple_Failed_Logins_Ip_Whitelist'))
	.split(',')
	.map((entry) => entry.trim())
	.filter(Boolean);

Impact

  • Admins can think an IP is whitelisted when it is not.
  • Lockout behavior becomes inconsistent and hard to diagnose.
  • Common comma-and-space formatting in settings silently breaks the feature.

This one is cleaner and less likely to already be raised than the earlier candidate.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/meteor/app/authentication/server/lib/restrictLoginAttempts.ts and review how the comma-separated IP whitelist is parsed before membership is checked. Reproduce the settings scenario with a space after a comma, then verify that the listed IP bypasses IP-based failed-login blocking.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
authentication, security
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.