RocketChat / RocketChat/Rocket.Chat

fix: Enforce runtime schema validation for query parameter handlers

Open
#42,005 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
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
  1. Supply a non-primitive object payload to an endpoint parameter expecting a primitive type.
  2. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.