Skip to content
XSS Disclosed report Intermediate

OSX slack:// protocol handler javascript injection

The Slack macOS app's slack:// protocol handler failed to sanitise single quotes in the team and a parameters, allowing an attacker to inject JavaScript that runs in the client app context. An attacker could post messages on the victim's behalf by tricking them into clicking a crafted link.

computerality Follow

Originally disclosed on HackerOne

  • Triaged in under an hour
  • Fixed in 21 days
  • Paid in 21 days
  • Disclosed after 11 months

The Mac Slack app version 1.1 introduced the slack:// protocol handler. Due to improper input sanitization, arbitrary Javascript code can be run in the context of the client app if the user clicks on a slack:// link on a website or email. I have confirmed this issue still exists in the 1.1.1 release.

PoC

If a user clicks this link, a message will be posted on their behalf to their general channel. <a href="slack://test?team=1&a=');eval(atob('VFNTU0Iuc2VuZE1zZ0Zyb21Vc2VyKHdpbmRvdy5UUy5jaGFubmVscy5nZXRHZW5lcmFsQ2hhbm5lbCgpLmlkLCAiSGVsbG8sIEkgYW0gcHJvb2Ygb2YganMgaW5qZWN0aW9uIik7'));String('">Click me for a good time</a>

or go to http://computerality.com/t/slack_report.html

The example javascript that is run in the context of the client app is: TSSSB.sendMsgFromUser(window.TS.channels.getGeneralChannel().id, "Hello, I am proof of js injection");

Details

The Objective-C function responsible for handling the scheme processing is: -[SLAppDelegate handleURLEvent:withReplyEvent:]

The argument is passed into the format string: "TSSSB.handleDeepLink(‘%@‘);”. Then the resulting string is evaluated in javascript via the stringByEvaluatingJavaScriptFromString method call.

An attempt is made to sanitize input by calling stringByAddingPercentEscapesUsingEncoding. This function will perform escaping of certain characters but leave the single quote character unmodified.

In the PoC link, the team argument is set to any value. When an invalid team id is used, a popup appears but the rest of the Javascript still runs. Next, the a parameter is processed. We escape and end the TSSSB.handleDeepLink() function call. Next we want to run arbitrary Javascript without having any spaces. To do this, we use the base64 decoding function atob() and call eval() on the result. Finally, the Javascript needs to continue to be valid so we create an unused object using the String constructor.

If you have any other questions or if anything needs clarification, please let me know.

Thanks!

-Jay

The original report as published on HackerOne, by computerality. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The app inserted the URL argument into a JavaScript string using a format string and then evaluated it, while its escaping function left single quotes unmodified, allowing the string to be broken out of.

Impact

An attacker could run arbitrary JavaScript in the Slack client context and post messages on the victim's behalf; an invalid team id causes a popup but the rest of the JavaScript still runs.

What the attacker needed

Slack macOS app 1.1 or 1.1.1; victim clicks a crafted slack:// link

How it was found

  1. Craft a slack:// link with a team parameter and an a parameter containing JavaScript that breaks out of the handleDeepLink call.
  2. Use base64 and eval to run arbitrary JavaScript without spaces, and keep the syntax valid with a trailing String constructor.
  3. Send the link to the victim via a website or email.
  4. The victim clicks the link, the app processes the URL, and the injected JavaScript runs in the client context.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A protocol handler lets a website open a desktop app by using a special link, like slack://. The app took part of that link and pasted it into a JavaScript command without cleaning it properly, so an attacker could sneak in their own JavaScript. When the victim clicked the link, the app ran the attacker's code and posted a message as the victim.

What is XSS?

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.

More from Slack

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.