The vulnerability exists because Mattermost failed to validate the Host header when constructing response URLs for custom slash commands. An analysis of the provided patch commit e738016c592045e14bf926eafaeda6f8521def6d reveals changes in two key functions that address this issue.
-
In server/channels/app/command.go, the function App.tryExecuteCustomCommand was modified. Previously, it constructed a response_url using args.SiteURL, a value derived from the incoming HTTP request's Host header. This allowed an attacker to craft a request with a spoofed Host header, causing the slash command's response to be sent to an arbitrary URL. The fix replaces the use of args.SiteURL with the server's pre-configured *a.Config().ServiceSettings.SiteURL, ensuring that the response URL is always based on a trusted, administrator-defined value.
-
In server/channels/app/command_autocomplete.go, the function App.getDynamicListArgument was also changed. This function makes a request to a plugin's FetchURL for autocomplete suggestions. The original code passed commandArgs.SiteURL (from the Host header) as a site_url parameter in this request. This could be exploited to manipulate the request sent to the plugin. The patch ensures that the configured SiteURL is used instead, preventing this vector of attack.
The root cause is improper trust in the Host header for generating critical URLs. The identified functions, App.tryExecuteCustomCommand and App.getDynamicListArgument, are the points where this untrusted data was used, making them the vulnerable functions that would appear in a runtime profile during exploitation.