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

Prevent suspended users from sending encrypted messages #18157

Merged
merged 6 commits into from
Feb 21, 2025

Conversation

H-Shay
Copy link
Contributor

@H-Shay H-Shay commented Feb 12, 2025

Missed in the first round.

@H-Shay H-Shay requested a review from a team as a code owner February 12, 2025 19:49
if (
event_dict["type"] == EventTypes.Message
or event_dict["type"] == EventTypes.Encrypted
):
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense to whitelist things? e.g. just membership events?

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 think this makes more sense? There is a relatively small set of actions which are prohibited - most of which are bounced higher in the stack, but I do see the point that the whitelist approach prevents errors like this. Happy to do it the way you think best, just let me know!

Copy link
Member

Choose a reason for hiding this comment

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

It's mostly up to T&S I think, it just feels odd to ban people from sending messages but not other events into the room, e.g. polls.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah suspended users shouldn't be sending polls - I have switched to an allowlist. I don't think what I have added violates any of these specifically allowed actions but let me know if it does:
Log in/create additional sessions (which should also behave as suspended).
See and receive messages, particularly via /sync and /messages.
Verify their other devices and write associated cross-signing data
Populate their key backup
Leave rooms & reject invites.
Redacting their own events.
Log out/delete any device of theirs, including the current session.
Deactivate their account, potentially with a deliberate time delay to discourage making a new account right away.

@H-Shay H-Shay requested a review from erikjohnston February 18, 2025 21:44

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
requester.user.to_string()
)
if requester_suspended:
if event_dict["type"] in ["m.room.redaction", "m.room.member"]:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if event_dict["type"] in ["m.room.redaction", "m.room.member"]:
# We want to allow suspended users to perform "corrective" actions
# asked of them by server admins, such as redact their messages and
# leave rooms.
if event_dict["type"] in ["m.room.redaction", "m.room.member"]:

@H-Shay
Copy link
Contributor Author

H-Shay commented Feb 20, 2025

Thanks for the review! I added a test and the comment, if it looks good can you merge when you get a chance? I no longer can :)

@erikjohnston erikjohnston merged commit 8fd7148 into element-hq:develop Feb 21, 2025
37 of 39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants