The vulnerability allows a malicious remote Mattermost cluster to remove any user from any shared channel, including private ones. This is due to a lack of authorization checks when processing membership synchronization messages from remote clusters.
The root cause is in the sharedchannel service, specifically in how it handles membership changes received from other clusters. The function onReceiveMembershipChanges is the entry point for these messages. It iterates over the received changes and calls either processMemberAdd or processMemberRemove.
Prior to the patch, the processMemberRemove function would proceed to remove a user from a channel without verifying that the remote cluster sending the request was authorized to do so. It did not check if the user being removed actually belonged to the remote cluster making the request. A malicious actor could craft a SyncMsg to remove arbitrary users from channels, leading to a denial of service for those users.
The fix, as seen in commit 8738f8c4b3d4, introduces checks in both processMemberRemove and processMemberAdd. The patched code now fetches the user object and compares its RemoteId with the RemoteId of the cluster that sent the sync message. If they do not match, the operation is aborted. This ensures that a remote cluster can only manage the membership of its own users in shared channels, effectively mitigating the vulnerability.