-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Description
The DDP method messageSearch accepts a user-controlled limit parameter but does not enforce any maximum value.
File: apps/meteor/server/methods/messageSearch.ts
Currently only the type is validated:
check(limit, Match.Optional(Number));
The value is later passed to MongoDB through parseMessageSearchQuery and used in:
Messages.find(query, { ...options }).toArray()
Since no upper bound exists, a client can call:
Meteor.call('messageSearch', 'a', null, 200000, 0)
This forces the server to execute a very large query on the rocketchat_message collection (the largest collection in Rocket.Chat). The result is high CPU usage, slow response times, and event loop blocking. A normal authenticated user can repeatedly trigger this and degrade server availability.
This is effectively a resource-exhaustion / denial-of-service vector.
Expected behavior
Search queries should be paginated and limited to a safe maximum value (similar to other search endpoints).
Proposed solution
Clamp limit and sanitize offset:
limit = Math.min(limit ?? 20, 100);
offset = Math.max(offset ?? 0, 0);
This prevents extremely expensive queries while maintaining current functionality.