A Mattermost personal access token lets whoever holds it call the Mattermost REST API as the user, or bot, that owns the token. It works like a session that does not expire by itself and does not need a password or a second factor. With it, an attacker can read the channels and direct messages the user can see, post messages as them, and use whatever permissions the account has, which for an administrator means the whole server. Mattermost is often self-hosted for sensitive internal discussion, so the exposure can be significant. Revoke the token first, then investigate.
Check your GitHub account for leaked secrets — free
- Provider
- Mattermost
- Severity
- High
- Impact
- SaaS account access and billing
- Checked live by LeakWatch
- No
What a Mattermost access token looks like
A personal access token is a random string of 26 lowercase letters and digits. It has no prefix:
MATTERMOST_TOKEN=xxxxxxxx…xxxx (26 characters, masked)
Authorization: Bearer xxxxxxxx…xxxx
A value of that length is common, since Mattermost identifiers for users, channels and posts have the same shape, and those are not secret. What identifies a token is the context: the Authorization: Bearer or Token header sent to your server’s /api/v4/ endpoints, or a variable such as MATTERMOST_TOKEN, MM_TOKEN or MATTERMOST_ACCESS_TOKEN. Bot accounts have their own access tokens, with the same format, and they are often used in integrations and CI. Incoming webhook URLs and slash command tokens are separate secrets with their own endpoints.
How Mattermost access tokens get leaked
- Integration scripts. Bots that post build results, alerts or reports, with the token written in the script.
- Environment files.
MATTERMOST_*variables in a committed.env, a Docker configuration or a deployment manifest. - CI pipelines. A token echoed by a debug step, or stored in a pipeline definition of a public repository.
- Plugins and tools. Command-line clients and chat-ops tools whose configuration file holds the token and ends up in a dotfiles repository.
- Support threads and screenshots. A curl command with the bearer header pasted in an issue.
What to do in the first hour
- Identify the owner. Work out which user or bot the token belongs to. In the System Console, the user management section lists users, and the token list of a user shows the tokens by description.
- Revoke the token. Delete it, either from the profile settings of the user (the security section lists personal access tokens) or from the System Console as an administrator. Mattermost documents that deleting a token also ends the sessions created with it. Disabling a token is a temporary alternative, and deleting is the right choice after a leak.
- Create a new token for the integration if it is still needed, and deploy it. Give bots only the roles they need.
- Review what the token did. Check the audit logs if your edition has them, the server logs and the posts the account made for the period since the exposure. Look for messages you did not send, channel exports, new users, new bots and new webhooks.
- Check other credentials. If the token belonged to an administrator, review the other tokens, the incoming and outgoing webhooks, slash commands, OAuth apps and plugins that were created recently.
- Reset the user’s password and sessions if you suspect the account itself is compromised, not only the token.
- Clean up the code. See I accidentally pushed an API key to GitHub and remove the value from the history if the repository is public.
Not sure what else leaked from the same repository? Run a free scan.
Revoke it at Mattermost
Mattermost is usually self-hosted, so there is no single vendor console: tokens are revoked on your own server. The user can delete a token in their profile, in the security settings, and an administrator can do it from the System Console. The API offers a revoke endpoint for tokens, documented on the Mattermost documentation site. A person has not confirmed the exact menu wording for this guide, and it depends on your server version, so look for the section where personal access tokens are listed, and follow the documentation of your version.
How LeakWatch detects it
The rule called Mattermost Access Token looks for the word mattermost, in any letter case, possibly inside a longer name such as MATTERMOST_TOKEN, followed by up to 20 name characters, and then an assignment: =, :, =>, := and similar separators, with optional quotes and spaces. The value after it must be exactly 26 letters or digits, followed by a quote, whitespace, a semicolon, a line break or the end of the text. A value of another length, or one not assigned in this way, is refused, so a bare bearer header with no mention of Mattermost is not reported. The severity is high. This type is not checked live: LeakWatch does not send any request to your Mattermost server with the value it found, and it could not know which server to contact.
LeakWatch detects this format but does not check it live: it can tell you the key is exposed, not whether it still works. Assume it does until you have revoked it.
FAQ
Does a Mattermost token bypass two-factor authentication?
Yes. A personal access token authenticates API calls without the password or the second factor, which is why it must be treated like a long-lived session and revoked as soon as it is exposed.
Is a bot token less dangerous?
It is limited to what the bot account is allowed to do, which can be narrow. But bots are sometimes given broad roles for convenience, so check the roles before deciding.
Should I deactivate the user instead of deleting the token?
Deactivating ends the sessions, but Mattermost keeps the tokens, and they work again if the account is reactivated. Delete the token, and only deactivate the account if it is compromised.