element-hq / dendrite

Dendrite is a second-generation Matrix homeserver written in Go!
https://element-hq.github.io/dendrite/
GNU Affero General Public License v3.0
33 stars 5 forks source link

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

Open matrixbot opened 3 weeks ago

matrixbot commented 3 weeks ago

This issue was originally created by @luk3yx at https://github.com/matrix-org/dendrite/issues/2522.

Background information

Description

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.

Steps to reproduce

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

image

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)"
matrixbot commented 3 weeks ago

This comment was originally posted by @ashkitten at https://github.com/matrix-org/dendrite/issues/2522#issuecomment-1236536425.

i'm seeing this issue as well, dendrite 0.9.6

matrixbot commented 3 weeks ago

This comment was originally posted by @ashkitten at https://github.com/matrix-org/dendrite/issues/2522#issuecomment-1237094682.

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.

matrixbot commented 3 weeks ago

This comment was originally posted by @arenekosreal at https://github.com/matrix-org/dendrite/issues/2522#issuecomment-1729664016.

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.

matrixbot commented 3 weeks ago

This comment was originally posted by @jackmaninov at https://github.com/matrix-org/dendrite/issues/2522#issuecomment-2332017404.

I am also seeing this issue (I believe).

In my case I am seeing failed to find the membership event for 'join_authorised_via_users_server' user referencing the second of two space administrators, who happens to not be in a subset of the rooms in that space. Adding that admin to the rooms allows other users to join.

Affected users had not been invited to the space by this second administrator, so it is not clear to me why Dendrite would expect that admin to be involved in the room join at all. Is perhaps the most recently added/promoted administrator being referenced?