-
Notifications
You must be signed in to change notification settings - Fork 20
fix: handling non-public room join #290
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
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,11 +160,12 @@ export class InviteService { | |
| | 'm.room.encryption' | ||
| >[], | ||
| ): Promise<void> { | ||
| const isRoomNonPrivate = strippedStateEvents.some( | ||
| (stateEvent) => | ||
| stateEvent.type === 'm.room.join_rules' && | ||
| stateEvent.content.join_rule === 'public', | ||
| const joinRuleEvent = strippedStateEvents.find( | ||
| (stateEvent) => stateEvent.type === 'm.room.join_rules', | ||
| ); | ||
| const isRoomNonPrivate = joinRuleEvent | ||
| ? joinRuleEvent.content.join_rule === 'public' | ||
| : true /* default, if no event */; | ||
|
|
||
| const isRoomEncrypted = strippedStateEvents.some( | ||
| (stateEvent) => stateEvent.type === 'm.room.encryption', | ||
|
|
@@ -199,6 +200,13 @@ export class InviteService { | |
| | 'm.room.encryption' | ||
| >[], | ||
| ) { | ||
| // SPEC: An optional list of stripped state events to help the receiver of the invite identify the room. | ||
| // https://spec.matrix.org/v1.12/server-server-api/#put_matrixfederationv1inviteroomideventid | ||
| if (strippedStateEvents.length === 0) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we validate this only if we have configured restrictions? like if we don't restrict anything we won't use the stripped state anyways |
||
| throw new NotAllowedError( | ||
| 'Invite has no room state, disallowing processing', | ||
| ); | ||
| } | ||
| // SPEC: when a user invites another user on a different homeserver, a request to that homeserver to have the event signed and verified must be made | ||
| await this.shouldProcessInvite(strippedStateEvents); | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reconsider the default value for
isRoomNonPrivate.When no
m.room.join_rulesevent is found, the code defaultsisRoomNonPrivatetotrue, treating the room as public/non-private. This appears inconsistent with the Matrix specification, which typically defaultsjoin_rulesto"invite"(private) when not explicitly set. Defaulting totruehere could bypass privacy restrictions configured viaallowedNonPrivateRooms, potentially allowing invites to private rooms that should be rejected.Consider this safer default:
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@debdutdeb what do you think about this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/element-hq/synapse/blob/f56670515bc402e13ee0bb2dd99ceb6e2ea8ba7d/synapse/event_auth.py#L565