Skip to content

MSC4155: Invite filtering #4155

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

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

Johennes
Copy link
Contributor

@Johennes Johennes commented Jun 13, 2024

Rendered


In line with matrix-org/matrix-spec#1700, the following disclosure applies:

I am a Systems Architect at gematik, Software Engineer at Unomed, Matrix community member and former Element employee. This proposal was written and published with my gematik hat on.


SCT stuff:

MSC checklist

FCP tickyboxes

Signed-off-by: Johannes Marbach <[email protected]>
@Johennes Johennes force-pushed the johannes/invite-filtering branch from ddd43ec to 6adc165 Compare June 13, 2024 10:08
@Johennes Johennes changed the title MSCXXXX: Invite filtering MSC4155: Invite filtering Jun 13, 2024
@Johennes Johennes marked this pull request as ready for review June 13, 2024 10:11
@clokep clokep added proposal A matrix spec change proposal client-server Client-Server API kind:feature MSC for not-core and not-maintenance stuff needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. labels Jun 13, 2024
Copy link
Member

@turt2live turt2live Jun 13, 2024

Choose a reason for hiding this comment

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

Implementation requirements:

  • Client supporting the feature, and using it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I believe all the gematik implementations will be closed source, I'll reference #3860 (comment) as an example for how cases like this were handled in the past. Thanks @clokep for digging it up.

Copy link
Contributor

@Half-Shot Half-Shot Mar 27, 2025

Choose a reason for hiding this comment

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

element-hq/synapse#18288 is a serverside implementation, albeit with #4155 (comment) "corrected"

Copy link
Contributor

Choose a reason for hiding this comment

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

element-hq/element-web#29603 exposes the serverside settings in the client, but does no filtering of itself. @Johennes does this evoke any worries from you if the invite filtering is done server-side?

Copy link
Contributor Author

@Johennes Johennes Mar 27, 2025

Choose a reason for hiding this comment

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

No, I this is fine and consistent with the proposal which allows but doesn't enforce the filtering on either the client or the server. Now that I think of it, we might need a capability so that the client knows when the server does not filter in which case the client needs to filter itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, I still need to get all this stuff approved but hopefully yes :). EWeb has lots of nice safety features landing :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Partial implementation as a synapse module: https://github.com/matrix-org/msc4155-synapse-invite-filter

Copy link
Contributor

Choose a reason for hiding this comment

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

element-hq/synapse#18288 supports the updated proposal.

Copy link
Member

Choose a reason for hiding this comment

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

With my SCT hat:

The following implementations demonstrate the desire for filtering, and experiment with different ordering, but all demonstrate that the code is more than possible:

The following implementations show that there's desire, but don't do much with the actual config:

Collectively, I feel this satisfies the implementation component, though we should monitor for user feedback if the rule processing order feels wrong. If so, we can correct it with a future MSC relatively easily (it'll suck for people on implementations which use the 'old' rules, but as those implementations update users will see the changes).


The `default` field defines the standard setting that is applied to all invites that don't match an
exception. Exceptions invert the default setting and are provided via the `user_exceptions` and
`server_exceptions` fields which follow the format of the `ignored_users` field in `m.ignored_user_list`.
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this comes with a problem of data loss. If you flip the "default" here, you end up with one of two problems. Either:

  1. The exemptions are now blocked/allowed, so if I start with my invites allowed but block @badguy:scam.org and then flip the default then the only person who can talk to me is bad guy!
  2. If the client flips the default and removes the exceptions then that data is lost forever and I need to reconstruct my list.

Could we make an easy change here where the exceptions are explicit about their behavior by including the block/allow for each key. While this looks redundant, it means flipping bits won't cause unexpected behavior here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, this is a problem indeed. Adding the block / allow behavior into each exception sounds reasonable to me.

It might be worth pointing out that this would make the proposal somewhat equivalent to the combination of #3847 and #4150. The only significant difference is storing the rules in a single account data event vs. as multiple policy events in a room.

I won't add this into the proposal yet because I'm hoping the SCT can provide some guidance on #4192 so that we don't spend our time in vein on the different options.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm looking to work on an experimental implementation of this, for the current T&S safety sprint I'm doing so I'm just doing some review on that basis.

#4192 felt a bit heavy a quick experiment, so I want to give this one a fair tryout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I see! And sorry, I wasn't aware you're actually part of T&S. If you want to go ahead with putting the type into the exceptions, that sounds reasonable to me, like I said. I'll happily add this into the proposal if it turns out worthwhile in the implementation.

Also, since we have this in the gematik specification (though with a different event type), there must already be implementations of this somewhere, just apparently not in open source clients, sadly. 😕

Copy link
Member

Choose a reason for hiding this comment

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

I think this would be relatively easy to handle with just prefixing fields for now:

{
  "allowed_users": [...],
  "allowed_servers": [...],
  "denied_users": [...],
  "denied_servers": [...]
}

Though verbose, it carries the same meaning. If we consider #4283 then we might extend this to:

allowed_users
ignored_users
blocked_users

allowed_servers
ignored_servers
blocked_servers

A later MSC (namely #3847) would handle change history of the rules more easily.

Copy link
Member

Choose a reason for hiding this comment

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

https://github.com/matrix-org/msc4155-synapse-invite-filter is a partial implementation of the variant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for expanding. I have updated proposal text accordingly.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to keep it separate for now, for ease of use by developers. Having too many 'tricks' like this makes the protocol feel more complicated than it is, sometimes.

So basically it's because "you like it this way"? I can accept that but there should be some consesus instead of your sole opinion, ain't it?

Seems like a clear duplicate functionality, and I guess the code would look like matching the sender of the invite with the list entries, so in this case two lists instead of one, using the same matching. I don't see how this would make developers' life simpler.

There were mentions elsewhere about ordering (name matches first, server later, to make it possible to disable everone but allow someone), which is not mentioned here as a pro, but feels like it would be a mess anyway people guessing the double ordering (first names, then servers).

Using common globs (servers and users) does not feel complex to me, and clinet developers can create separate UI for servers if they feel like, I'm sure it's not very complex to understand/remember that *:servername is a "server" entry.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had the same question initially but I think splitting users and servers is actually helpful. Having dedicated fields for servers prevents unintended globbing issues (server names can contain : as well) and is more explicit and easier to understand. Furhtermore, overlapping user / server globs don't strike me as problematic because we have a defined evaluation order for all settings.

I'm reopening this in case other people have thoughts on this.

Copy link
Member

Choose a reason for hiding this comment

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

(not considering this thread as a blocker against the checklist in this case)

@turt2live turt2live self-requested a review April 2, 2025 16:26
@turt2live turt2live added implementation-needs-checking The MSC has an implementation, but the SCT has not yet checked it. and removed needs-implementation This MSC does not have a qualifying implementation for the SCT to review. The MSC cannot enter FCP. labels Apr 2, 2025
@github-project-automation github-project-automation bot moved this to Needs idea feedback / initial review in Spec Core Team Backlog Apr 2, 2025
@turt2live turt2live moved this from Needs idea feedback / initial review to Ready for FCP ticks in Spec Core Team Backlog Apr 2, 2025
@turt2live turt2live moved this from Ready for FCP ticks to Proposed for FCP readiness in Spec Core Team Backlog Apr 2, 2025
Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

other than the confusion of block versus ignore, this looks good to me - thank you!

If we do switch to using split out fields, supporting globs would be ideal.

Copy link
Member

@turt2live turt2live left a comment

Choose a reason for hiding this comment

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

thanks for updating this! I'll do some implementation review then hopefully send this for FCP (with the assumption that the listed suggestions aren't too controversial 😇 )

Copy link
Contributor

@grinapo grinapo left a comment

Choose a reason for hiding this comment

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

Would be nice to get more exmplanation why it's out of scope...

@turt2live
Copy link
Member

@mscbot resolve Rule order

@turt2live
Copy link
Member

@mscbot concern Clarify ignore behaviour (preferred: send an event, but don't deliver, like normal user ignores)

@clokep
Copy link
Member

clokep commented Jun 3, 2025

@mscbot concern Confusing behavior of whether enforced by clients or servers

@Half-Shot
Copy link
Contributor

@mscbot concern Confusing behavior of whether enforced by clients or servers

Sounds resolved now clients are not involved.

@clokep
Copy link
Member

clokep commented Jun 4, 2025

@mscbot resolve Confusing behavior of whether enforced by clients or servers

reivilibre pushed a commit to element-hq/synapse that referenced this pull request Jun 5, 2025
This implements
matrix-org/matrix-spec-proposals#4155, which
adds support for a new account data type that blocks an invite based on
some conditions in the event contents.

---------

Co-authored-by: Andrew Morgan <[email protected]>
@turt2live
Copy link
Member

@mscbot resolve Clarify ignore behaviour (preferred: send an event, but don't deliver, like normal user ignores)
@mscbot resolve Checklist incomplete

@mscbot mscbot removed the unresolved-concerns This proposal has at least one outstanding concern label Jun 5, 2025
Comment on lines +42 to +50
1. Verify the invite against each `*_users` setting:
1. If it matches `allowed_users`, stop processing and allow.
2. If it matches `ignored_users`, stop processing and ignore.
3. If it matches `blocked_users`, stop processing and block.
2. Verify the invite against each `*_servers` setting:
1. If it matches `allowed_servers`, stop processing and allow.
2. If it matches `ignored_servers`, stop processing and ignore.
3. If it matches `blocked_servers`, stop processing and block.
3. Otherwise, allow.
Copy link
Contributor

@Gnuxie Gnuxie Jun 11, 2025

Choose a reason for hiding this comment

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

The allow semantic here is in the reverse order to server ACL, and the implication is that an allow rules overrule ban rules. This will cause problems later if an allow policy rule recommendation is created, because it will have different semantics based on context.

To be explicit, for it to be consistent with server ACL, the allow rule would have to be applied first and processing can only continue if there is a match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client-server Client-Server API disposition-merge kind:core MSC which is critical to the protocol's success proposal A matrix spec change proposal proposed-final-comment-period Currently awaiting signoff of a majority of team members in order to enter the final comment period.
Projects
Status: Ready for FCP ticks
Development

Successfully merging this pull request may close these issues.