dendrite icon indicating copy to clipboard operation
dendrite copied to clipboard

Can't join private federated space rooms from multiple users without a direct invite

Open luk3yx opened this issue 2 years ago • 3 comments

Background information

  • Dendrite version or git SHA: 3e9c734da5151aac6b7073c0797d26cde529ced7 (with the space summary, threading, and presence features enabled)
  • Monolith or Polylith?: Monolith
  • SQLite3 or Postgres?: Postgres
  • Running in Docker?: No
  • go version: 1.18.3
  • Client used (if applicable): Element

Description

  • What is the problem: I can't join rooms in spaces on matrix.org that have their access set to "space members" without a direct invite to the room.
  • Who is affected: Users trying to join rooms inside spaces
  • How is this bug manifesting: When I attempt to join some rooms in spaces, I get the following error:

InputRoomEvents auth failed: InputRoomEventsResponse: eventauth: the nominated 'join_authorised_via_users_server' user "(user)" is not joined to the room

The user that it says isn't joined to the room is not necessarily the same user that is attempting to join the room. This only seems to affect some rooms in the space.

  • When did this first appear: After trying Dendrite with two accounts

Steps to reproduce

  • Create a private space on matrix.org
  • Invite a user from Dendrite to the space
  • Join a room in the space from the first Dendrite user
  • Invite a second user from Dendrite to the space and make the second user join the space

For some reason the room shows as "unnamed room" for the second Dendrite user at this point:

image

  • Try to join the room from the second user.

Possibly relevant logs:

time="2022-06-09T01:22:06.509121001Z" level=info msg="Sending event" func="github.com/matrix-org/dendrite/federationapi/queue.(*OutgoingQueues).SendEvent" file="/home/dendrite/dendrite/federationapi/queue/queue.go:234" destinations=1 event="$L-mLWTFxMntGYAXIiQ91ZvJDQfXRc0YBSq9Mb577voA"time="2022-06-09T01:22:09.116014634Z" level=info msg="User requested to room join" func="github.com/matrix-org/dendrite/roomserver/internal/perform.(*Joiner).PerformJoin" file="/home/dendrite/dendrite/roomserver/internal/perform/perform_join.go:61" room_id="!TqhISZkeLnITbfnThZ:matrix.org" servers="[matrix.org]" user_id="(Dendrite user MXID)"
time="2022-06-09T01:22:09.182043925Z" level=error msg="internal.DeviceListCatchup failed" func="github.com/matrix-org/dendrite/syncapi/streams.(*DeviceListStreamProvider).IncrementalSync" file="/home/dendrite/dendrite/syncapi/streams/stream_devicelist.go:33" device_id=BVh_ny9G error="GetBulkStateContent: failed to load state for room !TqhISZkeLnITbfnThZ:matrix.org : storage: state NIDs missing from the database (0 != 1)" limit=20 req.id=YWphzFN5BKO3 req.method=GET req.path=/_matrix/client/r0/sync since=s2639_1311_2928_12_2644_2643_5563_806_14538 timeout=30s user_id="(Dendrite user MXID)"
time="2022-06-09T01:22:09.183673237Z" level=info msg="Sending event" func="github.com/matrix-org/dendrite/federationapi/queue.(*OutgoingQueues).SendEvent" file="/home/dendrite/dendrite/federationapi/queue/queue.go:234" destinations=1 event="$EwH5S7FWAFsMlsen-U6SlvWz2acFKjv7hqcrZ06Vk5E"time="2022-06-09T01:22:09.185279066Z" level=info msg="User joined room successfully" func="github.com/matrix-org/dendrite/roomserver/internal/perform.(*Joiner).PerformJoin" file="/home/dendrite/dendrite/roomserver/internal/perform/perform_join.go:76" room_id="!TqhISZkeLnITbfnThZ:matrix.org" servers="[matrix.org]" user_id="(Dendrite user MXID)"
time="2022-06-09T01:22:14.436241205Z" level=info msg="Signalling other goroutines waiting for this goroutine to generate the thumbnail." func=github.com/matrix-org/dendrite/mediaapi/thumbnailer.broadcastGeneration file="/home/dendrite/dendrite/mediaapi/thumbnailer/thumbnailer.go:126" Height=54 MediaID=OWuRjJJOFikFQkDIHKFPgNeb Origin=matrix.org ResizeMethod=crop Width=54 req.id=a04R3SOk02jU req.method=GET req.path=/_matrix/media/r0/thumbnail/matrix.org/OWuRjJJOFikFQkDIHKFPgNeb
time="2022-06-09T01:23:01.754088142Z" level=info msg="Cleaning old notifications" func=github.com/matrix-org/dendrite/userapi.NewInternalAPI.func1 file="/home/dendrite/dendrite/userapi/userapi.go:100"
time="2022-06-09T01:23:49.877650238Z" level=info msg="Signalling other goroutines waiting for this goroutine to generate the thumbnail." func=github.com/matrix-org/dendrite/mediaapi/thumbnailer.broadcastGeneration file="/home/dendrite/dendrite/mediaapi/thumbnailer/thumbnailer.go:126" Height=54 MediaID=OWuRjJJOFikFQkDIHKFPgNeb Origin=matrix.org ResizeMethod=crop Width=54 req.id=MYUaOph3zWiR req.method=GET req.path=/_matrix/media/r0/thumbnail/matrix.org/OWuRjJJOFikFQkDIHKFPgNeb

Edit: I've tried again with Dendrite v0.8.8 and still got this error, although it only occurred the second time I tried to reproduce it with a newly created space. I got different log messages this time, maybe the previous logs were irrelevant.

time="2022-06-10T00:50:04.397247949Z" level=info msg="User requested to room join" func="github.com/matrix-org/dendrite/roomserver/internal/perform.(*Joiner).PerformJoin" file="/home/dendrite/dendrite/roomserver/internal/perform/perform_join.go:61" room_id="!VNtMIAIaTYEpWfDirJ:matrix.org" servers="[matrix.org]" user_id="(second Dendrite user)"
time="2022-06-10T00:50:04.421880682Z" level=warning msg="Event $0J2CEF-WDvmH843zzyhLAt0Uy-0Cosck2iTYMoEr8GM not allowed by auth events" func="github.com/matrix-org/dendrite/roomserver/internal/input.(*Inputer).processRoomEvent" file="/home/dendrite/dendrite/roomserver/internal/input/input_events.go:199" context=missing error="eventauth: failed to find the membership event for 'join_authorised_via_users_server' user \"(second Dendrite user)\"" event_id="$0J2CEF-WDvmH843zzyhLAt0Uy-0Cosck2iTYMoEr8GM" kind=KindNew origin="" room_id="!VNtMIAIaTYEpWfDirJ:matrix.org" type=m.room.member
time="2022-06-10T00:50:04.424630096Z" level=warning msg="Error authing soft-failed event" func="github.com/matrix-org/dendrite/roomserver/internal/input.(*Inputer).processRoomEvent" file="/home/dendrite/dendrite/roomserver/internal/input/input_events.go:236" context=missing error="eventauth: failed to find the membership event for 'join_authorised_via_users_server' user \"(second Dendrite user)\"" event_id="$0J2CEF-WDvmH843zzyhLAt0Uy-0Cosck2iTYMoEr8GM" kind=KindNew origin="" room_id="!VNtMIAIaTYEpWfDirJ:matrix.org" type=m.room.member
time="2022-06-10T00:50:04.430554994Z" level=warning msg="Stored rejected event" func="github.com/matrix-org/dendrite/roomserver/internal/input.(*Inputer).processRoomEvent" file="/home/dendrite/dendrite/roomserver/internal/input/input_events.go:346" context=missing error="eventauth: failed to find the membership event for 'join_authorised_via_users_server' user \"(second Dendrite user)\"" event_id="$0J2CEF-WDvmH843zzyhLAt0Uy-0Cosck2iTYMoEr8GM" kind=KindNew missing_prev=false origin="" room_id="!VNtMIAIaTYEpWfDirJ:matrix.org" soft_fail=true type=m.room.member
time="2022-06-10T00:50:04.430897702Z" level=warning msg="Roomserver failed to process async event" func="github.com/matrix-org/dendrite/roomserver/internal/input.(*worker)._next" file="/home/dendrite/dendrite/roomserver/internal/input/input.go:259" error="eventauth: failed to find the membership event for 'join_authorised_via_users_server' user \"(second Dendrite user)\"" event_id="$0J2CEF-WDvmH843zzyhLAt0Uy-0Cosck2iTYMoEr8GM" room_id="!VNtMIAIaTYEpWfDirJ:matrix.org" type=m.room.member
time="2022-06-10T00:50:04.431717876Z" level=error msg="Failed to join room" func="github.com/matrix-org/dendrite/roomserver/internal/perform.(*Joiner).PerformJoin" file="/home/dendrite/dendrite/roomserver/internal/perform/perform_join.go:64" error="1 : InputRoomEvents auth failed: InputRoomEventsResponse: eventauth: failed to find the membership event for 'join_authorised_via_users_server' user \"(second Dendrite user)\"" room_id="!VNtMIAIaTYEpWfDirJ:matrix.org" servers="[matrix.org]" user_id="(second Dendrite user)"

luk3yx avatar Jun 09 '22 01:06 luk3yx

i'm seeing this issue as well, dendrite 0.9.6

ashkitten avatar Sep 05 '22 04:09 ashkitten

this seems like it may be related to these complement tests that are currently skipped: image

at a guess, it feels like it may be checking the wrong room for membership. instead of checking the space from the join rules, if it checked the target room then it would fail.

ashkitten avatar Sep 05 '22 14:09 ashkitten

I think this problem is existing on dendrite 0.13.2 The room #archlinux-cn-offtopic:nichi.co requires people join their space #archlinux-cn-space:nichi.co first. When one of my friends @phantomfutaba:data.haus tried to join the room and do everything required, he absolutely succeeded joining the room. However, dendrite thoughts that join_authorised_via_users_server in his join event is someone who cannot invite people, so dendrite treats my friend as an invalid user and ignores everything my friend says. This is dendrite's log when my friend joins the room:

time="2023-09-21T07:49:01.163132251Z" level=warning msg="Event $1-f9XIPhMlikLhN6ejqsLsofQq-b05l-awVsfKDaRG8 not allowed by auth events" context=missing error="eventauth: the nominated 'join_authorised_via_users_server' user \"@lanmengcha:data.haus\" does not have permission to invite (0 < 50)" event_id="$1-f9XIPhMlikLhN6ejqsLsofQq-b05l-awVsfKDaRG8" kind=KindOutlier origin="" room_id="!TczZJIbozgTQfqUYBA:nichi.co" type=m.room.member

This is the log when my friend speaks:

time="2023-09-21T05:31:56.518791962Z" level=warning msg="Event $9MbjYBkfUQrdUlysaZxFV3YqrFkHrXpWvnMVE19tQjY not allowed by auth events" context=missing error="eventauth: sender \"@phantomfutaba:data.haus\" not in room" event_id="$9MbjYBkfUQrdUlysaZxFV3YqrFkHrXpWvnMVE19tQjY" kind=KindNew origin=data.haus  room_id="!umlJmbWNOMWEaVlphw:matrix.org" type=m.room.message

time="2023-09-21T05:31:56.525458066Z" level=warning msg="Stored rejected event" context=missing error="eventauth: sender sender \"@phantomfutaba:data.haus\" not in room" event_id="$9MbjYBkfUQrdUlysaZxFV3YqrFkHrXpWvnMVE19tQjY" kind=KindNew origin=data.haus room_id="!umlJmbWNOMWEaVlphw:matrix.org" type=m.room.message

time="2023-09-21T05:31:56.525504940Z" level=warning msg="Roomserver rejected event" error="eventauth: sender \"@phantomfutaba:data.haus\" not in room" event_id="$9MbjYBkfUQrdUlysaZxFV3YqrFkHrXpWvnMVE19tQjY" room_id="!umlJmbWNOMWEaVlphw:matrix.org" type=m.room.message

The reason why my friend speaks before he joins is that the join log is get after an instance restart while the speak log is obtained before the restart.

arenekosreal avatar Sep 21 '23 14:09 arenekosreal