From 95eaf401af990ef6e366c568a4fe929aa94723a5 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Tue, 29 Jul 2025 10:33:59 +0300 Subject: [PATCH] MM-64926: Membership sync sends sensitive data to remote (#33560) (#33577) Automatic Merge --- server/platform/services/sharedchannel/membership.go | 2 +- server/platform/services/sharedchannel/util.go | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/server/platform/services/sharedchannel/membership.go b/server/platform/services/sharedchannel/membership.go index 8903b217f6..b27fd897bd 100644 --- a/server/platform/services/sharedchannel/membership.go +++ b/server/platform/services/sharedchannel/membership.go @@ -322,7 +322,7 @@ func (scs *Service) syncMembershipBatchToRemotes(syncMsg *model.SyncMsg, remotes // Check if user profile needs to be synced doSync, _, sErr := scs.shouldUserSync(user, syncMsg.ChannelId, rc) if sErr == nil && doSync { - enrichedSyncMsg.Users[user.Id] = user + enrichedSyncMsg.Users[user.Id] = sanitizeUserForSyncSafe(user) } } } diff --git a/server/platform/services/sharedchannel/util.go b/server/platform/services/sharedchannel/util.go index 603f56ff3f..40ea67255f 100644 --- a/server/platform/services/sharedchannel/util.go +++ b/server/platform/services/sharedchannel/util.go @@ -48,6 +48,12 @@ func sanitizeUserForSync(user *model.User) *model.User { return user } +func sanitizeUserForSyncSafe(user *model.User) *model.User { + // Create a copy to avoid modifying the original user object + userCopy := *user + return sanitizeUserForSync(&userCopy) +} + const MungUsernameSeparator = "-" // mungUsername creates a new username by combining username and remote cluster name, plus