Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Allow any user in e2ee room to create and propagate room keys #34152

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chilly-pants-hunt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Removes a validation that allowed only the room creator to propagate E2EE room keys. This was causing issues when the rooms were created via apps or some other integration, as the creator may not be online or able to create E2EE keys
24 changes: 7 additions & 17 deletions apps/meteor/app/e2e/client/rocketchat.e2e.room.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
import { Emitter } from '@rocket.chat/emitter';
import EJSON from 'ejson';

import { RoomManager } from '../../../client/lib/RoomManager';
import { roomCoordinator } from '../../../client/lib/rooms/roomCoordinator';
import { RoomSettingsEnum } from '../../../definition/IRoomTypeConfig';
import { ChatRoom, Subscriptions, Messages } from '../../models/client';
import { sdk } from '../../utils/client/lib/SDKClient';
import { t } from '../../utils/lib/i18n';
import { E2ERoomState } from './E2ERoomState';

Check failure on line 5 in apps/meteor/app/e2e/client/rocketchat.e2e.room.js

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

`./E2ERoomState` import should occur after import of `../../utils/lib/i18n`
import {

Check failure on line 6 in apps/meteor/app/e2e/client/rocketchat.e2e.room.js

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

`./helper` import should occur after import of `../../utils/lib/i18n`
toString,
toArrayBuffer,
joinVectorAndEcryptedData,
Expand All @@ -28,8 +22,14 @@
sha256HashFromArrayBuffer,
createSha256HashFromText,
} from './helper';
import { log, logError } from './logger';

Check failure on line 25 in apps/meteor/app/e2e/client/rocketchat.e2e.room.js

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

`./logger` import should occur after import of `../../utils/lib/i18n`
import { e2e } from './rocketchat.e2e';

Check failure on line 26 in apps/meteor/app/e2e/client/rocketchat.e2e.room.js

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

`./rocketchat.e2e` import should occur after import of `../../utils/lib/i18n`
import { RoomManager } from '../../../client/lib/RoomManager';
import { roomCoordinator } from '../../../client/lib/rooms/roomCoordinator';
import { RoomSettingsEnum } from '../../../definition/IRoomTypeConfig';
import { ChatRoom, Subscriptions, Messages } from '../../models/client';
import { sdk } from '../../utils/client/lib/SDKClient';
import { t } from '../../utils/lib/i18n';

const KEY_ID = Symbol('keyID');
const PAUSED = Symbol('PAUSED');
Expand Down Expand Up @@ -308,8 +308,7 @@

try {
const room = ChatRoom.findOne({ _id: this.roomId });
// Only room creator can set keys for room
if (!room.e2eKeyId && this.userShouldCreateKeys(room)) {
if (!room.e2eKeyId) {
this.setState(E2ERoomState.CREATING_KEYS);
await this.createGroupKey();
this.setState(E2ERoomState.READY);
Expand All @@ -325,15 +324,6 @@
}
}

userShouldCreateKeys(room) {
// On DMs, we'll allow any user to set the keys
if (room.t === 'd') {
return true;
}

return room.u._id === this.userId;
}

isSupportedRoomType(type) {
return roomCoordinator.getRoomDirectives(type).allowRoomSettingChange({}, RoomSettingsEnum.E2E);
}
Expand Down
Loading