RocketChat / RocketChat/Rocket.Chat
Message search `from:` and `mention:` filters match unintended usernames when username contains a dot
Nobody has claimed this yet.
- 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:
- Ensure you have two users whose usernames differ only at a dot position — e.g.
rocket.catandrocketXcat(orjohn.doeandjohnXdoe). - Have both users send messages in a channel you have access to.
- Open the message search and enter
from:rocket.cat. - 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
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 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