Skip to content

Ignore received EDUs if origin server in room ACL #18475

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 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
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
1 change: 1 addition & 0 deletions changelog.d/18475.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make ACLs apply to EDUs.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have any tests for ACLs on /send anywhere? I can't seem to find any and don't want to waste time reinventing the wheel trying to add tests for these 2 cases.

There is tests/federation_acl_test.go in Complement

Copy link
Member

Choose a reason for hiding this comment

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

Complement PR: matrix-org/complement#783

Copy link
Contributor

Choose a reason for hiding this comment

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

The Complement PR is still in draft and has a piece of pending review

24 changes: 24 additions & 0 deletions synapse/federation/federation_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,30 @@ async def _process_edu(edu_dict: JsonDict) -> None:
edu_type=edu_dict["edu_type"],
content=edu_dict["content"],
)

if edu.edu_type == EduTypes.TYPING:
origin_host, _ = parse_server_name(origin)
room_id = edu.content["room_id"]
try:
await self.check_server_matches_acl(origin_host, room_id)
except AuthError:
logger.warning(
"Ignoring typing EDU for room %s from banned server", room_id
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"Ignoring typing EDU for room %s from banned server", room_id
"Ignoring typing EDU for room %s from banned server because of ACL's", room_id

)
return

if edu.edu_type == EduTypes.RECEIPT:
origin_host, _ = parse_server_name(origin)
for room_id, _ in edu.content.items():
try:
await self.check_server_matches_acl(origin_host, room_id)
except AuthError:
Copy link
Contributor

Choose a reason for hiding this comment

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

Feels like we should also have a general except Exception that logger.exception(...) like below.

Perhaps we should just nest everything under that single try

logger.warning(
"Ignoring receipt EDU containing room %s from banned server",
room_id,
)
return

try:
await self.registry.on_edu(edu.edu_type, origin, edu.content)
except Exception:
Expand Down
Loading