-
Notifications
You must be signed in to change notification settings - Fork 415
MSC3083: Restricting room membership based on membership in other rooms #3083
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
Merged
+289
−0
Merged
Changes from 20 commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
d5633d1
Add pointer to draft.
clokep dfcc467
Include the proposed MSC.
clokep c81947a
Document the error response.
clokep 4fc5acf
Update a placeholder.
clokep 13e3f18
Rework bits about peeking.
clokep 36b19fb
Clarify link.
clokep 2919e57
Update dependencies to include MSC3173.
clokep fab5eaa
Add notes from @madlittlemods.
clokep 5afe23a
More wrapping.
clokep 590b7a4
Fill in the TODO about what how to mark access via spaces for the sum…
clokep cbc4515
Spacing.
clokep 4eeb27f
Add more notes about edge-cases.
clokep 0f49611
Remove spaces summary changes.
clokep c7ab867
Fix broken backlink.
clokep c1eb461
Remove bit about user IDs being listed directly.
clokep 41dd06d
Clarify an edge case.
clokep e81686c
Many clarifications.
clokep 8a3ad47
A bit less passive.
clokep 1d1d356
Space -> room.
clokep 7061e19
Add a type field.
clokep 5a58af6
Namespace the allow type.
clokep f3e7fba
Re-iterate that ban and server-acls matter.
clokep ed679c7
Clarify membership checking over federation.
clokep bfa0dfe
Clarify auth rules for restrictedjoin rules.
clokep 39b9a9d
Clarify security concerns.
clokep 91c7612
Handle feedback from Travis.
clokep 39fdfa3
Add a list of trusted servers.
clokep 3bab6bd
Remove via field.
clokep 8e0b001
Add a note about ensuring each allowed room has at least one server i…
clokep 0b49932
Clarifications.
clokep b4296ef
Remove the authorised servers list.
clokep e5305a7
Clarifications / simplifications.
clokep 6d041d4
Fix typos.
clokep 69aec55
Clarify soft-failure is extension of current algorithm.
clokep 42a34de
Clarify that signature checks only apply to joining users.
clokep 808bb1b
Pull note about ban & ACLs out of each join rule description.
clokep 87f9938
Use a different room version to specify changes in join rules.
clokep 182c806
Clarify what happens if a homeserver cannot verify membership.
clokep 1be4019
Clarify implications of signing events.
clokep 76333ee
Add notes about the via key and authorised servers being out of sync.
clokep 5f2240a
Fix typo.
clokep 3037232
Fix typo.
clokep 2c65a03
Fix typo.
clokep b9204cc
Remove extraneous paragraph.
clokep d95200f
Add domains to the example room aliases.
clokep dc945a4
Reword intro.
clokep 2012466
Clarify users must be joined to an allowed room.
clokep db40a1c
Reflow.
clokep 81a588e
Add note about including the authorising server in the content.
clokep b41a1a3
Update the information on signature checking.
clokep 290f903
Updates from review.
clokep ffb9095
Add a note about resident servers.
clokep 7caff82
Add information about errors over federation.
clokep 55b99d2
Clarify if a resident server cannot issue a join vs. if they're unsur…
clokep 48c1d9d
Apply suggestions from code review
clokep 88a9404
Review feedback.
clokep c0b7f07
Move back section about errors for make/send_join & some review comme…
clokep 77422e2
Move changes to make/send_join out of auth rules section.
clokep 3885a94
Include an additional error situation.
clokep d9cae9b
More review comments.
clokep d128869
Fix typos.
clokep 2e7db4a
Clarify error conditions.
clokep 72ffbfe
Rename MSC.
clokep 31a9b2a
Clarifications.
clokep db089aa
De-indent section.
clokep 9699aa8
Note unstable prefix.
clokep 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 |
|---|---|---|
| @@ -0,0 +1,205 @@ | ||
| # Restricting room membership based on space membership | ||
|
|
||
| A desirable feature is to give room admins the power to restrict membership of | ||
| their room based on the membership of one or more spaces from | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [MSC1772](https://github.com/matrix-org/matrix-doc/pull/1772), for example: | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| > members of the #doglovers space can join this room without an invitation<sup id="a1">[1](#f1)</sup> | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Proposal | ||
|
|
||
| A new `join_rule` (`restricted`) will be used to reflect a cross between `invite` | ||
uhoreg marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| and `public` join rules. The content of the join rules would include the rooms | ||
| to trust for membership. For example: | ||
|
|
||
| ```json | ||
| { | ||
| "type": "m.room.join_rules", | ||
| "state_key": "", | ||
| "content": { | ||
| "join_rule": "restricted", | ||
| "allow": [ | ||
| { | ||
| "type": "room-membership", | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "room": "!mods:example.org", | ||
| "via": ["example.org"] | ||
| }, | ||
| { | ||
| "type": "room-membership", | ||
| "room": "!users:example.org", | ||
| "via": ["example.org"] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| This means that a user must be a member of the `!mods:example.org` room or | ||
| `!users:example.org` room in order to join without an invite<sup id="a2">[2](#f2)</sup>. | ||
clokep marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Membership in a single room is enough. | ||
|
|
||
| If the `allow` key is an empty list (or not a list at all), then no users are | ||
anoadragon453 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| allowed to join without an invite. Each entry is expected to be an object with the | ||
| following keys: | ||
|
|
||
| * `type`: `"room-membership"` to describe that we are allowing access via room | ||
| membership. Future MSCs may define other types. | ||
| * `room`: The room ID to check the membership of. | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * `via`: A list of servers which may be used to peek for membership of the room. | ||
|
|
||
| Any entries in the list which do not match the expected format are ignored. Thus, | ||
| if all entries are invalid, the list behaves as if empty and all users without | ||
| an invite are rejected. | ||
|
|
||
| When a homeserver receives a `/join` request from a client or a `/make_join` / `/send_join` | ||
| request from a server, the request should only be permitted if the user has a valid | ||
| invite or is in one of the listed rooms. | ||
|
|
||
| If the user is not a member of at least one of the rooms, the homeserver should | ||
| return an error response with HTTP status code of 403 and an `errcode` of `M_FORBIDDEN`. | ||
|
|
||
| It is possible for a homeserver receiving a `/make_join` / `/send_join` request | ||
| to not know if the user is in a particular room (due to not participating in any | ||
| of the necessary rooms). In this case the homeserver should reject the join, | ||
| the requesting server may wish to attempt to join via other homeservers. | ||
|
|
||
| Unlike the `invite` join rule, confirmation that the `allow` rules were properly | ||
| checked cannot be enforced over federation by event authorisation, so servers in | ||
| the room are trusted not to allow invalid users to join.<sup id="a3">[3](#f3)</sup> | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Summary of the behaviour of join rules | ||
|
|
||
| See the [join rules](https://matrix.org/docs/spec/client_server/r0.6.1#m-room-join-rules) | ||
| specification for full details, but the summary below should highlight the differences | ||
| between `public`, `invite`, and `restricted`. | ||
|
|
||
| * `public`: anyone can join, subject to `ban` and `server_acls`, as today. | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * `invite`: only people with membership `invite` can join, as today. | ||
| * `knock`: the same as `invite`, except anyone can knock, subject to `ban` and | ||
| `server_acls`. See [MSC2403](https://github.com/matrix-org/matrix-doc/pull/2403). | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * `private`: This is reserved, but unspecified. | ||
| * `restricted`: the same as `public` from the perspective of the [auth rules](https://spec.matrix.org/unstable/rooms/v1/#authorization-rules), | ||
neilalexander marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| but with the additional caveat that servers must check the `allow` rules before | ||
| generating a `join` event (whether for a local or a remote user). | ||
|
|
||
| ## Security considerations | ||
|
|
||
| The `allow` feature for `join_rules` places increased trust in the servers in the | ||
| room. We consider this acceptable: if you don't want evil servers randomly | ||
| joining spurious users into your rooms, then: | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. Don't let evil servers in your room in the first place | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 2. Don't use `allow` lists, given the expansion increases the attack surface anyway | ||
| by letting members in other rooms dictate who's allowed into your room. | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Unstable prefix | ||
|
|
||
| The `restricted` join rule will be included in a future room version to allow | ||
| servers and clients to opt-into the new functionality. | ||
|
|
||
| During development, an unstable room version of `org.matrix.msc3083` will be used. | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Since the room version namespaces the behaviour, the `allow` key and the | ||
| `restricted` value do not need unstable prefixes. | ||
|
|
||
| ## Alternatives | ||
|
|
||
| It may seem that just having the `allow` key with `public` join rules is enough | ||
| (as originally suggested in [MSC2962](https://github.com/matrix-org/matrix-doc/pull/2962)), | ||
| but there are concerns that having a `public` join rule that is restricted may | ||
| cause issues if an implementation has not been updated to understand the semantics | ||
| of the `allow` keyword. This could be solved by introducing a new room version, | ||
| but in that case it seems clearer to introduce the `restricted` join rule, as | ||
| described above. | ||
|
|
||
| Using an `allow` key with `invite` join rules to broaden who can join was rejected | ||
| as an option since it requires weakening the [auth rules](https://spec.matrix.org/unstable/rooms/v1/#authorization-rules). | ||
| From the perspective of the auth rules, the `restricted` join rule is identical | ||
| to `public` (since the checking of whether a member is in the room is done during | ||
| the call to `/join` or `/make_join` / `/send_join` regardless). | ||
|
|
||
| ## Future extensions | ||
|
|
||
| ### Checking room membership over federation | ||
|
|
||
| If a server is not in a room (and thus doesn't know the membership of a room) it | ||
| cannot enforce membership of a room during a join. Peeking over federation, | ||
| as described in [MSC2444](https://github.com/matrix-org/matrix-doc/pull/2444), | ||
| could be used to establish if the user is in any of the proper rooms. | ||
|
|
||
| Note that there are additional security considerations with this, namely that | ||
| the peek server has significant power. For example, a poorly chosen peek | ||
| server could lie about the room membership and add an `@evil_user:example.org` | ||
| to a room to gain membership to a room. | ||
|
|
||
| This MSC recommends rejecting the join in this case and allowing the requesting | ||
neilalexander marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| homeserver to ask another homeserver. | ||
|
|
||
| ### Kicking users out when they leave the allowed space | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| In the above example, suppose `@bob:server.example` leaves `!users:example.org`: | ||
| should they be removed from the room? Likely not, by analogy with what happens | ||
| when you switch the join rules from public to invite. Join rules currently govern | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| joins, not existing room membership. | ||
|
|
||
| It is left to a future MSC to consider this, but some potential thoughts are | ||
| given below. | ||
|
|
||
| If you assume that a user *should* be removed in this case, one option is to | ||
| leave the departure up to Bob's server `server.example`, but this places a | ||
| relatively high level of trust in that server. Additionally, if `server.example` | ||
| were offline, other users in the room would still see Bob in the room (and their | ||
| servers would attempt to send message traffic to it). | ||
|
|
||
| Another consideration is that users may have joined via a direct invite, not via | ||
| access through a room. | ||
|
|
||
| Fixing this is thorny. Some sort of annotation on the membership events might | ||
| help. but it's unclear what the desired semantics are: | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| * Assuming that users in a given space are *not* kicked when that space is | ||
| removed from `allow`, are those users then given a pass to remain | ||
| in the room indefinitely? What happens if the space is added back to | ||
| `allow` and *then* the user leaves it? | ||
| * Suppose a user joins a room via a space (SpaceA). Later, SpaceB is added to | ||
| the `allow` list and SpaceA is removed. What should happen when the | ||
| user leaves SpaceB? Are they exempt from the kick? | ||
|
|
||
| It is possible that completely different state should be kept, or a different | ||
| `m.room.member` state could be used in a more reasonable way to track this. | ||
|
|
||
| ### Inheriting join rules | ||
|
|
||
| If you make a parent space invite-only, should that (optionally?) cascade into | ||
| child rooms? This would have some of the same problems as inheriting power levels, | ||
| as discussed in [MSC2962](https://github.com/matrix-org/matrix-doc/pull/2962). | ||
|
|
||
| ### Additional allow types | ||
|
|
||
| Future MSCs may wish to define additional values for the `type` argument, potentially | ||
| restricting access via: | ||
|
|
||
| * MXIDs or servers. | ||
| * A shared secret (room password). | ||
|
|
||
| These are just examples are not fully thought through for this MSC, but it should | ||
clokep marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| be possible to add these behaviors in the future. | ||
|
|
||
| ## Footnotes | ||
|
|
||
| <a id="f1"/>[1]: The converse restriction, "anybody can join, provided they are not members | ||
| of the '#catlovers' space" is less useful since: | ||
|
|
||
| 1. Users in the banned room could simply leave it at any time | ||
| 2. This functionality is already partially provided by | ||
| [Moderation policy lists](https://matrix.org/docs/spec/client_server/r0.6.1#moderation-policy-lists). [↩](#a1) | ||
|
|
||
| <a id="f2"/>[2]: Note that there is nothing stopping users sending and | ||
| receiving invites in `public` rooms today, and they work as you might expect. | ||
| The only difference is that you are not *required* to hold an invite when | ||
| joining the room. [↩](#a2) | ||
|
|
||
| <a id="f3"/>[3]: This is a marginal decrease in security from the current | ||
| situation. Currently, a misbehaving server can allow unauthorised users to join | ||
| any room by first issuing an invite to that user. In theory that can be | ||
| prevented by raising the PL required to send an invite, but in practice that is | ||
| rarely done. [↩](#a3) | ||
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.