The vulnerability (CVE-2025-2571) description states that Mattermost fails to clear Google OAuth credentials when converting user accounts to bot accounts. The provided commit 04676582cdd26f4fdfa78fcf60a7f8745e6b27f5 directly addresses this issue.
The patch modifies the ConvertUserToBot function in server/channels/app/bot.go. Specifically, it adds a new block of code at the beginning of the function to check if the user has an AuthService (like Google OAuth) configured. If so, it explicitly calls UpdateUserAuth to set AuthService and AuthData to empty strings, effectively clearing the OAuth credentials before proceeding with the bot conversion.
This indicates that the ConvertUserToBot function was the point where the OAuth credentials should have been cleared but were not, thus making it the vulnerable function. An attacker could exploit this by having an OAuth session for a regular user account, and if that account was converted to a bot, the OAuth credentials would persist, potentially allowing the attacker to take over the bot account through the OAuth flow. The fix ensures these credentials are wiped during the conversion process.