RocketChat / RocketChat/Rocket.Chat

Message search `from:` and `mention:` filters match unintended usernames when username contains a dot

Open
#39,927 2 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

Description:

When searching messages using the from: or mention: filters with a username that contains a dot (e.g. rocket.cat), the search returns messages from unintended users. This is because the username is inserted directly into a MongoDB $regex pattern without escaping, causing . to act as a regex wildcard ("any character") instead of a literal dot.

This affects any workspace using the default username policy, which allows dots in usernames ([0-9a-zA-Z-_.]+), including the built-in rocket.cat bot.

Steps to reproduce:
  1. Ensure you have two users whose usernames differ only at a dot position — e.g. rocket.cat and rocketXcat (or john.doe and johnXdoe).
  2. Have both users send messages in a channel you have access to.
  3. Open the message search and enter from:rocket.cat.
  4. Observe the results.
Expected behavior:

Only messages sent by the user with the exact username rocket.cat should appear in the results.

Actual behavior:

Messages from other users whose usernames match the unescaped pattern such as rocketXcat, rocket_cat, or any username where the dot position is any character are also returned.

Server Setup Information:
  • Version of Rocket.Chat Server: 8.3.0-rc.2 (reproduced on develop branch)
  • License Type:
  • Number of Users: Any (requires at least two users with usernames differing at a dot position)
  • Operating System:
  • Deployment Method:
  • Number of Running Instances:
  • DB Replicaset Oplog:
  • NodeJS Version:
  • MongoDB Version:
Client Setup Information
  • Desktop App or Browser Version:
  • Operating System:
Additional context
Relevant logs:

No server or browser logs required because the issue is observable purely in search results.

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 at the message-search handling for the from: and mention: filters and locate where usernames are inserted into the MongoDB $regex pattern. Make matching literal for usernames containing dots, then reproduce the rocket.cat versus rocketXcat case and verify that only the exact username's messages are returned.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, typescript
Domain
backend, search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
64/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.