Skip to content
Info disclosure Disclosed report Intermediate

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.

gronke Follow

Originally disclosed on HackerOne

Medium 6.5 View original
  • 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:

JavaScript
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:

JavaScript
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):

  1. Login to Rocket.Chat
  2. Open Web Inspector
  3. Call unreadMessages
  4. Repeat 3. with more specific regular expression until full message ID is known

Suggested mitigation

  • Ensure input data firstUnreadMessage._id is a String

Impact

Unauthorized clients can leak existing messages unique identifiers.

The original report as published on HackerOne, by gronke. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Log in to Rocket.Chat.
  2. Open the browser's Web Inspector.
  3. Call the unreadMessages method with a regular expression as the message ID.
  4. 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.

More by gronke

View all

27 more disclosed reports, best first.

More from Rocket.Chat

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.