Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Block clients from sending server ACLs that lock the local server out. #8708

Merged
merged 6 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 3 additions & 0 deletions synapse/handlers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,9 @@ def is_inviter_member_event(e):
if original_event.room_id != event.room_id:
raise SynapseError(400, "Cannot redact event from a different room")
Copy link
Member

Choose a reason for hiding this comment

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

hmm, this should probably be a 403, alas. out of scope for this PR though.

Choose a reason for hiding this comment

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

No, this is a 400; redacting a room's event using a different room ID is ill-formed, it is not "well-formed but forbidden".


if original_event.type == EventTypes.ServerACL:
raise AuthError(403, "Redacting server ACL events is not permitted")

prev_state_ids = await context.get_prev_state_ids()
auth_events_ids = self.auth.compute_auth_events(
event, prev_state_ids, for_verification=True
Expand Down
21 changes: 21 additions & 0 deletions tests/handlers/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,24 @@ def test_deny_server_acl_block_outselves(self):
tok=self.access_token,
expect_code=400,
)

def test_deny_redact_server_acl(self):
"""Test that attempting to redact an ACL is blocked
erikjohnston marked this conversation as resolved.
Show resolved Hide resolved
"""

body = self.helper.send_state(
self.room_id,
EventTypes.ServerACL,
body={"allow": [self.hs.hostname]},
tok=self.access_token,
expect_code=200,
)
event_id = body["event_id"]

# Redaction of event should fail.
path = "/_matrix/client/r0/rooms/%s/redact/%s" % (self.room_id, event_id)
request, channel = self.make_request(
"POST", path, content={}, access_token=self.access_token
)
self.render(request)
self.assertEqual(int(channel.result["code"]), 403)