Skip to content

fix: Domain allowance check to require exact matches #39752

Merged
ggazzo merged 4 commits intodevelopfrom
fix/allow-domain
Mar 20, 2026
Merged

fix: Domain allowance check to require exact matches #39752
ggazzo merged 4 commits intodevelopfrom
fix/allow-domain

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented Mar 19, 2026

…rationDomainAllowedMiddleware

Proposed changes (including videos or screenshots)

Issue(s)

Steps to test or reproduce

Further comments

task: FGA-41

Summary by CodeRabbit

  • Bug Fixes
    • Federation domain authorization now requires exact domain matches against the allow-list instead of partial/suffix matches. This prevents unintended domains from being authorized, tightening access controls and reducing the risk of accidental or unauthorized federation connections.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Mar 19, 2026

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 19, 2026

🦋 Changeset detected

Latest commit: 7545e01

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/federation-matrix Patch
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4021352d-ea77-4573-a46e-693a7f1497af

📥 Commits

Reviewing files that changed from the base of the PR and between 280aeb3 and 7545e01.

📒 Files selected for processing (1)
  • .changeset/eight-colts-kiss.md
✅ Files skipped from review due to trivial changes (1)
  • .changeset/eight-colts-kiss.md
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 📦 Meteor Build (coverage)
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build

Walkthrough

A bug fix that changes federation domain allow-list validation from suffix matching to exact matching. The check now uses domain === allowed instead of domain.endsWith(allowed), preventing domains like qa.rocket.chat from matching when only rocket.chat is listed.

Changes

Cohort / File(s) Summary
Federation Domain Validation
ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts
Changed domain matching logic from suffix-based (endsWith) to exact match (===), enforcing strict allowlist matching.
Changeset
.changeset/eight-colts-kiss.md
Added a changeset entry for @rocket.chat/federation-matrix and @rocket.chat/meteor with a patch bump noting the fix to domain allowlist behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: updating the domain allowance check to require exact matches instead of suffix matching.
Linked Issues check ✅ Passed The code changes directly address FGA-41 by implementing exact domain matching instead of suffix matching, which prevents unintended cross-environment communication.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the federation domain allowance issue: middleware logic fix and corresponding changelog entry.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ggazzo ggazzo changed the title fix: Update domain allowance check to require exact matches in isFede… fix: Domain allowance check to require exact matches Mar 19, 2026
@ggazzo ggazzo added this to the 8.3.0 milestone Mar 19, 2026
@ggazzo ggazzo marked this pull request as ready for review March 19, 2026 23:26
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 1 file

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.44%. Comparing base (1741a20) to head (7545e01).
⚠️ Report is 14 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #39752      +/-   ##
===========================================
- Coverage    70.44%   70.44%   -0.01%     
===========================================
  Files         3243     3243              
  Lines       115247   115243       -4     
  Branches     20945    20927      -18     
===========================================
- Hits         81189    81181       -8     
- Misses       31999    32006       +7     
+ Partials      2059     2056       -3     
Flag Coverage Δ
e2e 60.44% <ø> (+<0.01%) ⬆️
e2e-api 48.11% <ø> (-0.04%) ⬇️
unit 70.91% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts (1)

55-55: Remove the inline implementation comment at Line 55.

This comment should be dropped to match repository style rules.

Suggested diff
-	// Check if domain is in allowed list (exact match only)
 	if (allowList.some((allowed) => domain === allowed)) {

As per coding guidelines "Avoid code comments in the implementation".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts`
at line 55, Remove the inline implementation comment "// Check if domain is in
allowed list (exact match only)" from the isFederationDomainAllowed middleware
implementation in
ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts;
simply delete that comment so the function code contains no inline
implementation comments, leaving behavior and logic untouched.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts`:
- Line 55: Remove the inline implementation comment "// Check if domain is in
allowed list (exact match only)" from the isFederationDomainAllowed middleware
implementation in
ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts;
simply delete that comment so the function code contains no inline
implementation comments, leaving behavior and logic untouched.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b47c833c-64d3-4e10-bc02-a4b7013601f1

📥 Commits

Reviewing files that changed from the base of the PR and between 1741a20 and 2dbfcb0.

📒 Files selected for processing (1)
  • ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: 📦 Meteor Build (coverage)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:18.785Z
Learning: In Rocket.Chat PR reviews, maintain strict scope boundaries—when a PR is focused on a specific endpoint (e.g., rooms.favorite), avoid reviewing or suggesting changes to other endpoints that were incidentally refactored (e.g., rooms.invite) unless explicitly requested by maintainers.
Learnt from: ricardogarim
Repo: RocketChat/Rocket.Chat PR: 37377
File: apps/meteor/ee/server/hooks/federation/index.ts:86-88
Timestamp: 2025-11-04T16:49:19.107Z
Learning: In Rocket.Chat's federation system (apps/meteor/ee/server/hooks/federation/), permission checks follow two distinct patterns: (1) User-initiated federation actions (creating rooms, adding users to federated rooms, joining from invites) should throw MeteorError to inform users they lack 'access-federation' permission. (2) Remote server-initiated federation events should silently skip/ignore when users lack permission. The beforeAddUserToRoom hook only executes for local user-initiated actions, so throwing an error there is correct. Remote federation events are handled separately by the federation Matrix package with silent skipping logic.
Learnt from: rodrigok
Repo: RocketChat/Rocket.Chat PR: 36991
File: apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts:219-221
Timestamp: 2025-09-19T15:15:04.642Z
Learning: The Federation_Matrix_homeserver_domain setting in apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts is part of the old federation system and is being deprecated/removed, so configuration issues with this setting should not be flagged for improvement.
📚 Learning: 2025-09-19T15:15:04.642Z
Learnt from: rodrigok
Repo: RocketChat/Rocket.Chat PR: 36991
File: apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts:219-221
Timestamp: 2025-09-19T15:15:04.642Z
Learning: The Federation_Matrix_homeserver_domain setting in apps/meteor/server/services/federation/infrastructure/rocket-chat/adapters/Settings.ts is part of the old federation system and is being deprecated/removed, so configuration issues with this setting should not be flagged for improvement.

Applied to files:

  • ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts
📚 Learning: 2025-12-09T20:01:00.324Z
Learnt from: sampaiodiego
Repo: RocketChat/Rocket.Chat PR: 37532
File: ee/packages/federation-matrix/src/FederationMatrix.ts:920-927
Timestamp: 2025-12-09T20:01:00.324Z
Learning: When reviewing federation invite handling in Rocket.Chat (specifically under ee/packages/federation-matrix), understand that rejecting an invite via federationSDK.rejectInvite() triggers an event-driven cleanup: a leave event is emitted and handled by handleLeave() in ee/packages/federation-matrix/src/events/member.ts, which calls Room.performUserRemoval() to remove the subscription. Do not add explicit cleanup in the reject branch of handleInvite(); rely on the existing leave-event flow for cleanup. If making changes, ensure this invariant remains and that any related paths still funnel cleanup through the leave event to avoid duplicate or missing removals.

Applied to files:

  • ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • ee/packages/federation-matrix/src/api/middlewares/isFederationDomainAllowed.ts

Copy link
Copy Markdown
Member

@KevLehman KevLehman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing changeset

Fixes an issue where all domains ending with the pattern were being allowed to communicate, the
@ggazzo
Copy link
Copy Markdown
Member Author

ggazzo commented Mar 20, 2026

Missing changeset

I was planning to talk to diego about before consider it done, but since I marked as ready to review... one point for you ;)

KevLehman
KevLehman previously approved these changes Mar 20, 2026
Copy link
Copy Markdown
Member

@KevLehman KevLehman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually saw it ready for review and on 8.3 so I checked lol

@sampaiodiego sampaiodiego added the stat: QA assured Means it has been tested and approved by a company insider label Mar 20, 2026
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Mar 20, 2026
@dionisio-bot dionisio-bot bot added this pull request to the merge queue Mar 20, 2026
@ggazzo ggazzo removed this pull request from the merge queue due to a manual request Mar 20, 2026
@ggazzo ggazzo merged commit e65b176 into develop Mar 20, 2026
45 checks passed
@ggazzo ggazzo deleted the fix/allow-domain branch March 20, 2026 21:14
cloudblimp pushed a commit to cloudblimp/Rocket.Chat that referenced this pull request Mar 24, 2026
ggazzo added a commit that referenced this pull request Mar 25, 2026
ggazzo added a commit that referenced this pull request Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge type: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants