The vulnerability exists because Mattermost failed to enforce Multi-Factor Authentication (MFA) on WebSocket connections. The core of the issue lies in the WebConn.IsAuthenticated function within server/channels/app/platform/web_conn.go. In vulnerable versions, this function only checked for a valid session token and did not verify if the user had completed the MFA process.
When a user establishes a WebSocket connection, the WebConn.ShouldSendEvent function is called for each event to determine if the user is authorized to receive it. This function, in turn, calls WebConn.IsAuthenticated. Since the authentication check was incomplete, an attacker who had compromised a user's credentials could log in, establish a WebSocket connection, and start receiving real-time events and sensitive information without ever providing an MFA token. The attacker would effectively bypass the MFA control for all data transmitted over WebSockets.
The patch addresses this by renaming the original, insecure IsAuthenticated function to IsBasicAuthenticated and introducing a new, more secure IsAuthenticated function. This new function checks for both a valid session and MFA completion by calling a new IsMFAAuthenticated function. By fixing the authentication check, the ShouldSendEvent function now correctly prevents event transmission to users who have not completed MFA, thus closing the security hole.