The vulnerability exists in the Slack import feature of Mattermost, where email addresses of imported users were automatically verified without proper authorization checks. This could be exploited by a low-privileged user to bypass domain-based restrictions for team membership.
The analysis of the provided patches points to two key functions:
-
github.com/mattermost/mattermost/server/platform/services/slackimport.SlackImporter.oldImportUser: This is the core vulnerable function. The diff clearly shows the removal of an unconditional call to VerifyEmail and the introduction of a conditional check based on whether the import is performed by an admin (isAdminImport). Before the patch, any user could trigger this function through a Slack import and have an email from a restricted domain be marked as verified.
-
github.com/mattermost/mattermost/server/channels/app.App.SlackImport: This function serves as the entry point for the Slack import functionality. The patch modifies this function to check the session of the user initiating the import to determine if they are a system admin. This check is crucial for the fix, as it provides the isAdminImport flag needed by oldImportUser. An exploit would necessarily involve this function to start the import process.
Therefore, a runtime profile of an exploit would show app.App.SlackImport being called, which in turn would lead to the execution of slackimport.SlackImporter.oldImportUser, where the unauthorized email verification would occur in vulnerable versions.