RocketChat / RocketChat/Rocket.Chat
fix: Enforce runtime schema validation for query parameter handlers
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description
Incoming request parameters in endpoint and method handlers should enforce strict primitive type assertions (e.g., string) prior to passing them into backend database query selectors. Passing unvalidated objects or operator keys can cause unexpected query behaviors or runtime type errors.
Steps to Reproduce
- Supply a non-primitive object payload to an endpoint parameter expecting a primitive type.
- Observe backend parameter parsing and query formation without schema validation.
Expected Behavior
Request parameters must be strictly validated against runtime schemas (using Zod or check) and reject unexpected input structures with a 400 Bad Request error.
Environment
- Rocket.Chat Version: Latest / Development
- Deployment: Node.js / Docker
- Database: MongoDB
Proposed Solution
Enforce runtime type checks on all controller and service inputs before building database queries:
import { check } from 'meteor/check';
// Enforce string type
check(paramValue, String);
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 by tracing controller and service inputs that feed MongoDB query selectors, then reproduce the non-primitive parameter case described in the issue. Review the existing runtime validation approach using Zod or check and identify the handlers that lack it. Done means unexpected parameter structures are rejected with a 400 Bad Request before query formation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mongodb, typescript
- Domain
- api, backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100