The vulnerability lies in the deduplicateCreatePost function in server/channels/app/post.go. This function is responsible for handling post creation requests that include a PendingPostId to prevent duplicate posts. The vulnerability arises because the original implementation used the GetSinglePost function to retrieve the post associated with the PendingPostId from the cache. GetSinglePost does not perform any authorization checks, meaning any authenticated user could retrieve any post if they knew its PendingPostId, including posts in private channels they are not members of.
The patch addresses this by replacing the call to GetSinglePost with a call to GetPostIfAuthorized. This new function ensures that the user making the request has the necessary permissions to view the post before returning it. If the user is not authorized, the function now returns a 'forbidden' error, which is handled gracefully by logging a warning and treating the post as if it doesn't exist, thus preventing the information leak. The core of the vulnerability is the missing authorization check, which is fixed by introducing GetPostIfAuthorized within the deduplicateCreatePost logic.