The vulnerability description states that Mattermost failed to check the 'Allow Users to View Archived Channels' configuration when fetching channel metadata of a post from archived channels. The provided patches (which are identical across the listed commits) modify server/channels/app/authorization.go.
The primary change involves introducing a new helper function isChannelArchivedAndHidden(*model.Channel) bool which checks this specific configuration (!*a.Config().TeamSettings.ExperimentalViewArchivedChannels) in conjunction with whether a channel is deleted (channel.DeleteAt != 0).
This helper function is then used to add a crucial check in two main authorization functions: (*App).SessionHasPermissionToChannel and (*App).SessionHasPermissionToChannels. The diffs show that the condition if a.isChannelArchivedAndHidden(channel) { return false } was added to these functions. Before this addition, these functions would proceed with other permission checks (like team membership or specific roles) without first verifying if the channel was archived and if the user was allowed to view archived channels. This omission is the root cause of the vulnerability, as these functions would incorrectly grant (or fail to deny) permissions for archived channels under certain circumstances.
Other functions like (*App).HasPermissionToReadChannel and (*App).HasPermissionToChannelMemberCount were also modified to use this new helper function, but they already had an equivalent inline check (if !*a.Config().TeamSettings.ExperimentalViewArchivedChannels && channel.DeleteAt != 0). Their modification was primarily a refactoring to use the centralized helper and does not indicate they were the source of the missing check described in the vulnerability. The vulnerability was a failure to check, which was rectified by adding the check to SessionHasPermissionToChannel and SessionHasPermissionToChannels.
Therefore, these two functions are identified as the vulnerable ones because they lacked the necessary authorization logic prior to the patch.