Unread Messages can leak Message IDs
The Meteor method unreadMessages accepted a regular expression as the message ID, allowing an attacker to infer whether a message with a given ID exists by observing error responses. This could leak private message IDs to unauthorised clients.
- Triaged in 5 hours
- Fixed in 38 days
- Disclosed after 3.6 years
Summary: The Meteor Method unreadMessages, called with a regular expression, can leak existing Message IDs to unauthorized clients.
Description:
The MongoDB _id of a Rocket.Chat Message is private, because unauthorized clients could use it to affect or leak chat messages. With a regular expression as target firstUnreadMessage, the following Meteor.call prints true when a matching message exists:
Meteor.call("unreadMessages", {
_id: { $regex: /(.*|<KNOWN_MESSAGE_ID>)/ }
}, (error, i) => console.log(!!error));
When a regex does not match any message, the KNOWN_MESSAGE_ID is found instead, so that no error is returned. An error-action-not-allowed error only occurs when the regex matched a message that may not be accessed by the requesting client.
The affected code path can be found in app/message-mark-as-unread/server/unreadMessages.js#L28:
const originalMessage = Messages.findOneById(firstUnreadMessage._id, {
fields: {
u: 1,
rid: 1,
file: 1,
ts: 1,
},
});
if (originalMessage == null || userId === originalMessage.u._id) {
throw new Meteor.Error('error-action-not-allowed', 'Not allowed', {
method: 'unreadMessages',
action: 'Unread_messages',
});
}
Releases Affected:
- 3.9.3 / develop
Steps To Reproduce (from initial installation to vulnerability):
- Login to Rocket.Chat
- Open Web Inspector
- Call
unreadMessages - Repeat 3. with more specific regular expression until full message ID is known
Suggested mitigation
- Ensure input data
firstUnreadMessage._idis a String
Impact
Unauthorized clients can leak existing messages unique identifiers.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the server did not validate that the message ID input was a string, so a regular expression object was passed to the database query and used for pattern matching.
Impact
Unauthorised clients could leak existing message unique identifiers by observing error responses.
What the attacker needed
A Rocket.Chat account; ability to call Meteor methods
How it was found
- Log in to Rocket.Chat.
- Open the browser's Web Inspector.
- Call the unreadMessages method with a regular expression as the message ID.
- Repeat with more specific regular expressions until the full message ID is known.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A message ID is a unique code that identifies a chat message. The server normally keeps these secret because knowing one might let someone access or change that message. Here, a function that checks unread messages could be tricked into revealing whether a guessed ID exists, by sending a pattern instead of a real ID and watching for errors.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.