The vulnerability allowed guest users to view information about public teams they are not members of. This was due to an improper authorization check in the API endpoint /api/v4/teams/{team_id}. The commit patches reveal that the function api4.getTeam in server/channels/api4/team.go is the handler for this endpoint.
The root cause was an insufficient conditional statement for permission checking within api4.getTeam. The original logic effectively bypassed necessary permission checks if a team was flagged as 'public' (open invite and type open). This allowed users, including guests, who were not members of a public team and did not have the PermissionViewTeam for that specific team, to still retrieve the team's details.
The patch addresses this by introducing a more granular permission check. It first determines if a team is public (isPublicTeam) and if the user has direct permission to view the team (hasPermissionViewTeam). The critical fix is a new condition: if isPublicTeam && !hasPermissionViewTeam && !c.App.SessionHasPermissionTo(*c.AppContext.Session(), model.PermissionListPublicTeams). This ensures that for public teams where the user is not a member (i.e., !hasPermissionViewTeam), the user must possess the broader PermissionListPublicTeams to access the team information. If they don't, access is denied. This change directly mitigates the reported vulnerability by correctly restricting access based on appropriate permissions for public teams.
Therefore, api4.getTeam is the vulnerable function as it contained the flawed logic that was exploited to gain unauthorized access to team information. During exploitation, this function would be present in the runtime profile as it processes the malicious API request.