The vulnerability analysis identified a missing authorization flaw in the Mattermost Confluence plugin, specifically affecting the endpoint that retrieves subscription details. The vulnerability, as described, allows an unauthenticated attacker to access this information.
To pinpoint the vulnerable functions, I first identified the code changes between the last vulnerable version (v1.4.0) and the first patched version (v1.5.0). The commit de0a3d4c9eefa013e7d9f7a18d82eeced63322e6, with the message "Add API authentication and panic handling in server webhook process", was identified as the primary security patch.
Analysis of this commit revealed the following key changes:
- A new boolean field,
IsAuthenticated, was added to the Endpoint struct in server/controller.go.
- The
InitAPI function in server/controller.go was updated to use a new checkAuth middleware for any endpoint where IsAuthenticated is set to true.
- The
checkAuth middleware enforces authentication by checking for the presence of the Mattermost-User-Id header.
- Crucially, the
getChannelSubscription endpoint definition in server/get_subscription.go, which handles requests to GET /api/v1/{channelID}/subscription, had its IsAuthenticated flag set to true. This directly addresses the vulnerability.
The primary vulnerable function is handleGetChannelSubscription because, prior to the patch, it was executed without any authentication check, exposing sensitive subscription data. The InitAPI function is also included as it's the component responsible for routing requests to the handlers, and its modification was essential for applying the fix across multiple endpoints.