The vulnerability description clearly states that Mattermost failed to validate permissions for team invites, specifically allowing users without guest invitation permissions to add guests via the API for adding a single user. I started by examining the provided version ranges and patch information. The commit 76ab3867b785 associated with v10.6.2 was initially investigated but found to be related to UI components, not the server-side API logic described.
I then compared the tags v10.6.1 (last vulnerable) and v10.6.2 (first patched) for the mattermost/mattermost repository. Among the commits between these tags, a4a6b40e7b500ba3958966b84b9864d49c3e5c11 stood out due to its message: "MM-63350 Add tests for inviting guest users to teams".
Fetching the details of this commit revealed modifications to server/channels/api4/team.go, specifically within the addTeamMember function. This function is the handler for the API endpoint that adds a single user to a team. The patch introduced a new block of code that explicitly checks if the inviting user has model.PermissionInviteGuest. If they do not, and the user being added is identified as a guest (user.IsGuest()), a permission error is returned. This directly addresses the described vulnerability.
The commit was a cherry-pick of 3b9f9b209a28b584e52f91522f60c0d58325f1ab, which contained the same relevant code changes. The added test functions, TestAddTeamMemberGuestPermissions and TestAddTeamMembersGuestPermissions, further corroborate that the fix is centered around guest invitation permissions for team membership APIs. Although tests for addTeamMembers (batch addition) were also added, the vulnerability description specifically points to the "API to add a single user to a team," making addTeamMember the primary vulnerable function identified from the patch.