fix(api): prevent cross-room data exposure via query parameter injection#39471
fix(api): prevent cross-room data exposure via query parameter injection#39471Ram-sah19 wants to merge 2 commits intoRocketChat:developfrom
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📜 Recent review details🧰 Additional context used📓 Path-based instructions (1)**/*.{ts,tsx,js}📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Files:
🧠 Learnings (11)📓 Common learnings📚 Learning: 2026-02-24T19:09:01.522ZApplied to files:
📚 Learning: 2026-02-23T17:53:06.802ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-26T19:25:44.063ZApplied to files:
📚 Learning: 2026-02-25T20:10:16.987ZApplied to files:
📚 Learning: 2026-01-17T01:51:47.764ZApplied to files:
📚 Learning: 2025-11-19T18:20:37.116ZApplied to files:
📚 Learning: 2025-09-16T13:33:49.237ZApplied to files:
📚 Learning: 2025-09-25T09:59:26.461ZApplied to files:
📚 Learning: 2025-09-25T09:59:26.461ZApplied to files:
🔇 Additional comments (5)
WalkthroughThree API endpoints (channels.messages, groups.messages, and im.messages) were modified to prevent user-supplied rid query parameters from overriding server-enforced room ID filters. User queries are now sanitized by removing rid before constructing the final query with server-determined room IDs. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
No issues found across 3 files
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Fixes #39471
Security Fix: Cross-Room Data Exposure via Query Parameter Injection
When the legacy unsafe query mode (
ALLOW_UNSAFE_QUERY_AND_FIELDS_API_PARAMS=TRUE) is enabled, user-supplied query parameters can override the server-enforced room constraint (rid). Due to the spread order in query merging, an attacker could supply a customridand access messages from rooms they are not a member of.Root Cause
User-provided query parameters were merged with server constraints using object spread syntax, allowing the attacker-controlled
ridto override the enforced room ID.Changes
ridfrom user query input.ridalways takes precedence.Affected Endpoints
/api/v1/im.messages/api/v1/channels.messages/api/v1/groups.messagesSecurity Impact
Prevents authenticated users from accessing messages and files from rooms they do not have permission to access.
Testing
Verified that requests attempting to override
ridthrough query parameters are ignored and only authorized room messages are returned.Summary by CodeRabbit
Bug Fixes