Skip to content

fix: Drop abac attributes when room changes to public#40537

Merged
dionisio-bot[bot] merged 3 commits into
developfrom
chore/drop-attr-on-channel-typechange
May 19, 2026
Merged

fix: Drop abac attributes when room changes to public#40537
dionisio-bot[bot] merged 3 commits into
developfrom
chore/drop-attr-on-channel-typechange

Conversation

@KevLehman
Copy link
Copy Markdown
Member

@KevLehman KevLehman commented May 14, 2026

Proposed changes (including videos or screenshots)

Issue(s)

https://rocketchat.atlassian.net/browse/ABAC3-10

Steps to test or reproduce

Further comments

This is only possible while abac is disabled and the rooms was previously abac managed. Other changes to rooms while keeping the same privacy level are permitted without changing attributes.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed ABAC attributes incorrectly persisting when converting a room from private to public while ABAC is disabled. These attributes are now properly removed during room type conversion.

Review Change Stack

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 14, 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 May 14, 2026

🦋 Changeset detected

Latest commit: 35cc236

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

This PR includes changesets to release 42 packages
Name Type
@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/models 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/federation-matrix 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/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-composer 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 May 14, 2026

Walkthrough

When a room is converted to a direct channel type (roomType 'c'), any existing ABAC attributes are now cleared before the type update proceeds. The fix prevents attributes from persisting when ABAC is disabled, with corresponding tests and release documentation.

Changes

ABAC Attribute Cleanup on Room Type Conversion

Layer / File(s) Summary
Clear ABAC attributes when converting to direct channel type
apps/meteor/app/channel-settings/server/functions/saveRoomType.ts
The saveRoomType function adds a conditional check to clear ABAC attributes by calling Rooms.unsetAbacAttributesById(rid) when converting a room to type 'c' and the room has existing abacAttributes.
Test ABAC attribute clearing and preservation on room conversion
apps/meteor/tests/end-to-end/api/abac.ts
New test cases verify that converting a private room to public strips abacAttributes when ABAC is disabled, while preserving them if the room stays private. An existing team conversion test is extended to assert that channels.info does not return abacAttributes after conversion.
Patch release changelog entry
.changeset/calm-seas-run.md
Changeset metadata documents the @rocket.chat/meteor patch version fix for ABAC attribute cleanup on room type conversion.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

type: bug

Suggested reviewers

  • tassoevan
🚥 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 'fix: Drop abac attributes when room changes to public' accurately summarizes the main change—clearing ABAC attributes when a room transitions to public with ABAC disabled—which is reflected in the code changes and PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.63%. Comparing base (3f3c565) to head (35cc236).
⚠️ Report is 20 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40537      +/-   ##
===========================================
+ Coverage    69.62%   69.63%   +0.01%     
===========================================
  Files         3326     3326              
  Lines       122681   122681              
  Branches     21886    21849      -37     
===========================================
+ Hits         85414    85427      +13     
+ Misses       33914    33912       -2     
+ Partials      3353     3342      -11     
Flag Coverage Δ
e2e 59.23% <ø> (+0.10%) ⬆️
e2e-api 46.22% <ø> (-0.01%) ⬇️
unit 70.33% <ø> (-0.03%) ⬇️

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.

@KevLehman KevLehman marked this pull request as ready for review May 14, 2026 18:11
@KevLehman KevLehman requested a review from a team as a code owner May 14, 2026 18:11
@KevLehman KevLehman added this to the 8.5.0 milestone May 14, 2026
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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/meteor/app/channel-settings/server/functions/saveRoomType.ts (1)

45-53: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Race condition: ABAC attributes stripped after room type change.

The current implementation changes the room type to public at line 45, then strips ABAC attributes at line 52. This creates a timing window where the room is public but still has abacAttributes in the database, potentially allowing unauthorized access or violating security invariants.

Additionally, there's no check that ABAC is disabled. According to the PR description, attributes should only be dropped "when ABAC is disabled," but this function doesn't validate that condition and appears to rely on upstream validation.

🔒 Proposed fix: Strip attributes before type change
 const result = await Promise.all([Rooms.setTypeById(rid, roomType), Subscriptions.updateTypeByRoomId(rid, roomType)]);

 if (!result) {
 	return result;
 }

-if (roomType === 'c' && room.abacAttributes?.length) {
-	await Rooms.unsetAbacAttributesById(rid);
-}
-
 if (result[1]?.modifiedCount) {
 	void notifyOnSubscriptionChangedByRoomId(rid);
 }

Move the attribute cleanup before the type change:

+if (roomType === 'c' && room.abacAttributes?.length) {
+	await Rooms.unsetAbacAttributesById(rid);
+}
+
 const result = await Promise.all([Rooms.setTypeById(rid, roomType), Subscriptions.updateTypeByRoomId(rid, roomType)]);

 if (!result) {
 	return result;
 }

 if (result[1]?.modifiedCount) {
 	void notifyOnSubscriptionChangedByRoomId(rid);
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/app/channel-settings/server/functions/saveRoomType.ts` around
lines 45 - 53, The code currently calls Rooms.setTypeById and
Subscriptions.updateTypeByRoomId (result) before potentially removing ABAC
attributes with Rooms.unsetAbacAttributesById, creating a race where the room is
public while attributes still exist and also lacks a check that ABAC is
disabled; fix by moving the ABAC cleanup ahead of the type change and only when
ABAC is disabled: if roomType === 'c' and room.abacAttributes?.length and ABAC
is disabled (check your feature flag or helper such as isAbacEnabled/feature
flag), call Rooms.unsetAbacAttributesById(rid) first, then perform
Promise.all([Rooms.setTypeById(rid, roomType),
Subscriptions.updateTypeByRoomId(rid, roomType)]); ensure you reference the
existing room.abacAttributes check and the same rid/roomType variables.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@apps/meteor/app/channel-settings/server/functions/saveRoomType.ts`:
- Around line 45-53: The code currently calls Rooms.setTypeById and
Subscriptions.updateTypeByRoomId (result) before potentially removing ABAC
attributes with Rooms.unsetAbacAttributesById, creating a race where the room is
public while attributes still exist and also lacks a check that ABAC is
disabled; fix by moving the ABAC cleanup ahead of the type change and only when
ABAC is disabled: if roomType === 'c' and room.abacAttributes?.length and ABAC
is disabled (check your feature flag or helper such as isAbacEnabled/feature
flag), call Rooms.unsetAbacAttributesById(rid) first, then perform
Promise.all([Rooms.setTypeById(rid, roomType),
Subscriptions.updateTypeByRoomId(rid, roomType)]); ensure you reference the
existing room.abacAttributes check and the same rid/roomType variables.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fcb41ea9-1aeb-464b-b703-590560cf18d3

📥 Commits

Reviewing files that changed from the base of the PR and between 5c8efa7 and 35cc236.

📒 Files selected for processing (3)
  • .changeset/calm-seas-run.md
  • apps/meteor/app/channel-settings/server/functions/saveRoomType.ts
  • apps/meteor/tests/end-to-end/api/abac.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: 🔨 Test UI (EE) / MongoDB 8.0 coverage (4/5)
🧰 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:

  • apps/meteor/app/channel-settings/server/functions/saveRoomType.ts
  • apps/meteor/tests/end-to-end/api/abac.ts
🧠 Learnings (4)
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/calm-seas-run.md
📚 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:

  • apps/meteor/app/channel-settings/server/functions/saveRoomType.ts
  • apps/meteor/tests/end-to-end/api/abac.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:

  • apps/meteor/app/channel-settings/server/functions/saveRoomType.ts
  • apps/meteor/tests/end-to-end/api/abac.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/app/channel-settings/server/functions/saveRoomType.ts
  • apps/meteor/tests/end-to-end/api/abac.ts
🔇 Additional comments (4)
apps/meteor/tests/end-to-end/api/abac.ts (3)

1564-1580: LGTM!


1582-1599: LGTM!


1695-1698: LGTM!

.changeset/calm-seas-run.md (1)

1-5: LGTM!

@KevLehman KevLehman added the stat: QA assured Means it has been tested and approved by a company insider label May 19, 2026
@dionisio-bot dionisio-bot Bot added the stat: ready to merge PR tested and approved waiting for merge label May 19, 2026
@dionisio-bot dionisio-bot Bot added this pull request to the merge queue May 19, 2026
Merged via the queue into develop with commit 78814a8 May 19, 2026
117 of 121 checks passed
@dionisio-bot dionisio-bot Bot deleted the chore/drop-attr-on-channel-typechange branch May 19, 2026 15:15
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.

2 participants