Skip to content
XSS Disclosed report Intermediate

Stored XSS on team.slack.com using new Markdown editor of posts inside the Editing mode and using javascript-URIs

A stored cross-site scripting flaw existed in Slack's post editing mode, where a crafted WebSocket request could insert a javascript: URI into a link. An attacker could then trick a team member into clicking the link while editing the post, executing arbitrary script in the victim's browser.

Frans Rosén Follow

Originally disclosed on HackerOne

  • Triaged in 11 days
  • Fixed in 2 months
  • Paid in 2 months
  • Disclosed after 4 months

Hi,

I noticed while looking at an old article I made a while ago that some links were actually inserted as javascript:-links. Doing some modifications to these actually revealed that inside editing mode, no protection is added for getting arbitrary scripts to run. This means that by catching the modifications for the Web Socket, I was able to create a payload that would trigger on click (only inside Editing mode for some reason).

Here's the vulnerable socket-request I modified to get the payload in:

As you see in my post, I delete a link, then do a Ctrl+Z to undo it, putting back the link. I then capture that request and modify the request to insert the payload inside the links part:

{"type":"rocket","event":"rocket","payload":{"mm":[["fi",[],3,{"type":"unfurl","originalFragment":{"_bindings":{"attach":[[]],"mutation:post":[[]],"attached":[[]],"detach":[[]],"detached":[[]]},"_bindingLock":0,"_customData":[],"_data":{"type":"p","text":"javascript:alert(document.domain%29","tabbing":0,"links":{"javascript:alert(\"XSS\"%29":[0,22]},"formats":[]},"_dom":null,"_mutable":{"_lock":0},"_mutableGuard":{"_lock":0},"_parent":null,"_text":"javascript:alert(\"XSS\"%29","_tabbing":0,"_links":{"javascript:alert(\"XSS\"":{"_ranges":[{"_s":0,"_e":22}]}},"pendingUnfurls":[],"_formats":{"b":{"_ranges":[]},"i":{"_ranges":[]},"u":{"_ranges":[]},"strike":{"_ranges":[]},"code":{"_ranges":[]}}},"url":"javascript:alert(\"XSS\"%29"}]],"r":19,"$":15,"type":"mm","sel":[[3],0,[3],0]},"id":25}

Here's a PoC-image when clicking the link when I'm editing the post in my team:

Also, since you're able to get other people to edit it as well, by enabling "Let others edit this Post" you can get other people affected in your team. What's also interesting is that when creating a public link, that will be hosted on slack-files.com, there's a catcher for links that does not begin with ^http(s)?: which is awesome, however, this is not the case when editing a post on the team domain, which is a bit worse, since it's not sandboxed at all.

This is the link to my team's post: https://marqueexss.slack.com/files/marqueexss/F0283AA4K/__hello__a_name__n____href__javascript_alert__xss_____you___a_

Also, here's a link to the public post: https://slack-files.com/T025M9QPZ-F0283AA4K-2989c27641 to show you that the link has indeed the javascript: uri, however, this little snippet is triggered, which is great:

if (protocol && /^https?:$/.test(protocol) === false) {
     e.preventDefault();
     if (console && typeof console.warn === "function") {
         console.warn("not following bad link from a post preview")
     }
}

(This code is not present in the Edit-mode on the team URL as mentioned above)

PoC-movie is attached showing the complete flow from editing to triggering the XSS. I've also verified that it will trigger for other users in the team if they edit the post.

Regards, Frans

The original report as published on HackerOne, by fransrosen. 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

Likely the post editor's link handling did not validate or sanitise javascript: URIs when links were inserted via the WebSocket editing protocol, unlike the public preview which had a protocol check.

Impact

An attacker could execute arbitrary JavaScript in the victim's Slack team domain when the victim clicks the malicious link while editing the post.

What the attacker needed

Ability to create or edit a post; victim must edit the post; victim clicks the malicious link

How it was found

  1. Create or edit a post and insert a link, then delete it and undo with Ctrl+Z to generate a WebSocket request.
  2. Capture the WebSocket request and modify the links field to contain a javascript: URI payload.
  3. Send the modified request to store the malicious link in the post.
  4. Enable 'Let others edit this Post' so other team members can edit the post.
  5. Have a victim open the post in editing mode and click the crafted link to trigger the script.

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.

When you click a link, the browser normally goes to a website. But if the link starts with 'javascript:', the browser runs it as code instead. Slack's post editor failed to block such links, so an attacker could make a link that runs harmful code when clicked.

What is XSS?

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

More by Frans Rosén

View all

26 more disclosed reports, best first.

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.