Skip to content
Smuggling / CRLF Write-up Advanced

Slack HTTP Request Smuggling: Stealing Session Cookies

A malformed Transfer-Encoding header with a stray space before the colon was ignored by the front-end server but honoured by the back-end server, causing a request smuggling desync. The leftover bytes were prepended to the next customer's request, turning it into a redirect to an external host that carried the victim's Slack session cookie.

medium.com

Published on medium.com

Bug Bounty

Muhammad Asim Shahzad, on medium.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. 4 min read.

Context

Slack is a messaging platform where each customer works inside a workspace, and access to that workspace is carried by a session cookie. In November 2019, Evan Custodio (defparam) reported an HTTP request smuggling flaw on a Slack asset through HackerOne report #737140. The bug let him hijack other customers' requests in flight and collect their session cookies. Slack reproduced the issue, shipped a fix and paid a bounty within 24 hours.

AI-generated illustration From the original on medium.com

The illustration above is AI-generated and accompanies the write-up rather than showing any part of the attack.

This is an analytical case study of that public disclosure. The report does not publish the vulnerable hostname, the exact request bytes or the reproduction steps.

Setup

The report does not describe accounts, roles, tooling or versions. What it does establish is the precondition that matters: a front-end server and a back-end server sit in front of the same application, and the back-end connection is shared. Without that connection reuse there is nothing to poison and no victim to reach.

Finding it

The researcher was looking at how the two tiers framed HTTP requests. A request body's length can be declared in two ways: with a Content-Length header, or with chunked Transfer-Encoding. When both appear, the standard says Transfer-Encoding wins.

What he found was a malformed Transfer-Encoding header carrying a stray space before the colon. The front-end server ignored that header and measured the request by Content-Length. The back-end server honoured it and read the body as chunked. Two servers, one request, two different answers to the question of where the request ended. That is a CL.TE desync.

Exploitation

Step 1: Desynchronise the connection

The front end measures the request by Content-Length, while the back end reads it as chunked and leaves the remaining bytes sitting on the shared back-end connection. The report does not reproduce the exact request, so the precise header bytes are not available here.

Step 2: Poison the next request

The leftover bytes are glued to the front of the next customer's request on that connection. That prefix rewrites the victim's request into one that makes the back end answer with a redirect to an external host.

Step 3: Capture the cookie

The victim's browser follows the redirect, and Slack's session cookie travels with the request to a server the researcher controlled. Every request on that poisoned connection is a potential victim, selected by timing rather than by targeting.

Root cause

The framing disagreement is the first mistake: the front end ignored the malformed header and measured by Content-Length, while the back end honoured it and read chunked. The second mistake is the redirect gadget. The researcher recommended reviewing back-end redirects and never building an absolute Location from the request line. The report notes that desync on its own is noisy, and the redirect made it critical.

Impact

A stolen Slack session cookie is a logged-in session: the messages, files and channels of whatever workspace the victim belonged to. The researcher argued the technique could be automated into mass account takeover. Victims are chosen by timing on a shared connection, not by any prior knowledge of who they are. Slack paused public disclosure until its investigation concluded, and a redacted summary was disclosed in March 2020.

Fix

Slack shipped a fix within 24 hours of the report. The report does not describe what that fix changed. The researcher's own recommendation was to review back-end redirects and never build an absolute Location from the request line.

Variants to test

  1. Malformed header names at the edge. Send a header whose name contains a space before the colon, or another character outside the token set, alongside both framing headers. A positive result is the front end forwarding the request while the back end frames it differently, visible as a delayed or mismatched response on the next request over the same connection.
  2. Conflicting framing headers. Send both Content-Length and Transfer-Encoding: chunked and observe whether the edge rejects with a 400 and closes the connection or forwards it. Forwarding is the precondition for a desync.
  3. Redirect gadgets on the back end. Look for endpoints that reflect the request line or Host into an absolute Location. A positive result is a redirect to a host you control that still carries the victim's cookies.
  4. Connection reuse across users. Check whether the front end pools back-end connections between different sessions. If it does, a successful smuggle reaches the next user on that connection rather than only yourself.

A defensive check for the framing half, as published in the write-up:

Python
import reHEADER_NAME = re.compile(r"^[!#$%&'*+.^_`|~0-9A-Za-z-]+$")   def check_framing(raw_headers):    names = [n for n, _ in raw_headers]    if any(not HEADER_NAME.match(n) for n in names):                   return reject(400, close=True)    lower = [n.lower() for n in names]    has_te, has_cl = "transfer-encoding" in lower, "content-length" in lower    if has_te and has_cl:        return reject(400, close=True)                             if has_te and header(raw_headers, "transfer-encoding").strip().lower() != "chunked":        return reject(400, close=True)    return forward_canonical(raw_headers)

The code rejects invalid header names, rejects requests carrying both framing headers, rejects any Transfer-Encoding value other than plain chunked, and forwards a canonicalised request rather than the raw bytes.

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. 11 min read.

What happened, in plain words

Slack is a messaging platform. Each customer, such as a company, works inside its own space called a workspace, and once you log in, your browser holds a small piece of data called a session cookie. That cookie is what tells Slack who you are on every page you open, so anyone who copies it can act as you without knowing your password.

In November 2019, a security researcher named Evan Custodio, who also goes by defparam, reported a bug in a Slack system through the bug bounty platform HackerOne, as report #737140. A bug bounty is a programme where companies pay people for finding and reporting security problems responsibly instead of exploiting them. The bug was a type called HTTP request smuggling. In simple terms, two servers that sit in front of the same application read the same incoming request and disagreed about where that request ended. The researcher used that disagreement to hijack other customers' requests while they were travelling through Slack's systems, and to collect their session cookies.

Slack reproduced the issue, shipped a fix and paid a bounty within 24 hours. That speed matters: the report was submitted, confirmed, fixed and rewarded in under a day.

AI-generated illustration From the original on medium.com

The illustration above is AI-generated and accompanies the write-up rather than showing any part of the attack.

This is an analytical case study of that public disclosure. The report does not publish the vulnerable hostname, the exact request bytes or the reproduction steps.

Setup

Before the bug makes sense, you need a picture of how a big website is usually built. When you visit a site like Slack, your browser rarely talks to one computer. It usually talks to a front-end server, sometimes called an edge or a proxy, which sits at the front door. That front-end server passes your request on to a back-end server, which does the real work of the application. Think of a restaurant: the front-end server is the waiter taking your order, and the back-end server is the kitchen cooking it. The waiter repeats your order to the kitchen, and normally both agree on what was ordered.

A second idea is connection reuse. Opening a new network connection between two computers takes time, so front-end servers often keep a pool of connections to the back end and reuse them for many different customers. That is efficient, like a waiter carrying several tables' orders on one tray. It also means that if one customer's request leaves extra data behind on that shared connection, the next customer's request can pick it up.

The report does not describe accounts, roles, tooling or versions. What it does establish is the precondition that matters: a front-end server and a back-end server sit in front of the same application, and the back-end connection is shared. Without that connection reuse there is nothing to poison and no victim to reach.

Finding it

An HTTP request is the message your browser sends to a server. It has a first line saying what you want, then a set of headers, which are lines of metadata such as Content-Length, and sometimes a body, which is the actual data being sent, for example a form you filled in.

A request body's length can be declared in two ways. One is the Content-Length header, which simply says how many bytes the body contains. The other is chunked Transfer-Encoding, which says the body is sent in pieces, each piece labelled with its own size, ending with a zero-size piece. When both appear, the standard says Transfer-Encoding wins.

What the researcher found was a malformed Transfer-Encoding header carrying a stray space before the colon. Header names are supposed to be a strict set of characters with no spaces, so a header written with a space before the colon is not valid. The front-end server ignored that header and measured the request by Content-Length. The back-end server honoured it and read the body as chunked. Two servers, one request, two different answers to the question of where the request ended. That is a CL.TE desync: CL for Content-Length, TE for Transfer-Encoding, and desync for the two sides falling out of step.

Exploitation

Step 1: Desynchronise the connection

The front end measures the request by Content-Length, while the back end reads it as chunked and leaves the remaining bytes sitting on the shared back-end connection. The report does not reproduce the exact request, so the precise header bytes are not available here.

Why do this? The goal is to leave a piece of text, the leftover bytes, parked on the connection between the two servers. The front end thinks it has finished with the request. The back end thinks the same request is still going, or has ended sooner than the front end believes. That mismatch is the opening.

Step 2: Poison the next request

The leftover bytes are glued to the front of the next customer's request on that connection. That prefix rewrites the victim's request into one that makes the back end answer with a redirect to an external host.

A redirect is a server's way of saying "not here, go there instead", and it is delivered as a Location header pointing at another address. If the back end builds that address from the request itself, then whoever controls the start of the request can influence where the redirect points. The victim never chose to go anywhere; their own request was quietly rewritten before it reached the back end.

Step 3: Capture the cookie

The victim's browser follows the redirect, and Slack's session cookie travels with the request to a server the researcher controlled. Every request on that poisoned connection is a potential victim, selected by timing rather than by targeting.

This is the part that turns a technical curiosity into account takeover. Browsers send cookies automatically to the site they belong to, and a redirect can carry the browser to a different host. If the cookie goes along with it, the researcher now holds the victim's logged-in session. Nobody had to guess a password or phish anyone; the victim simply used Slack at the wrong moment on the wrong shared connection.

Root cause

The framing disagreement is the first mistake: the front end ignored the malformed header and measured by Content-Length, while the back end honoured it and read chunked. A strict front end would have looked at the malformed header, refused the request and closed the connection. Instead it quietly ignored the header and carried on, while the back end took it seriously.

The second mistake is the redirect gadget. A gadget here means a small, otherwise harmless feature that an attacker can repurpose. The researcher recommended reviewing back-end redirects and never building an absolute Location from the request line. An absolute address is a full one, including the host, rather than a path on the same site.

The report notes that desync on its own is noisy, and the redirect made it critical. The redirect made it critical, because it gave the smuggled text a reliable way to carry the cookie out.

Impact

A stolen Slack session cookie is a logged-in session: the messages, files and channels of whatever workspace the victim belonged to. The researcher argued the technique could be automated into mass account takeover. Victims are chosen by timing on a shared connection, not by any prior knowledge of who they are. Slack paused public disclosure until its investigation concluded, and a redacted summary was disclosed in March 2020.

Fix

Slack shipped a fix within 24 hours of the report. The report does not describe what that fix changed. The researcher's own recommendation was to review back-end redirects and never build an absolute Location from the request line.

Variants to test

These are the checks a defender or a tester would run to see whether a system has the same weaknesses. They are described at the level of what to look for, not as ready-made attacks.

  1. Malformed header names at the edge. Send a header whose name contains a space before the colon, or another character outside the token set, alongside both framing headers. A positive result is the front end forwarding the request while the back end frames it differently, visible as a delayed or mismatched response on the next request over the same connection.
  2. Conflicting framing headers. Send both Content-Length and Transfer-Encoding: chunked and observe whether the edge rejects with a 400 and closes the connection or forwards it. Forwarding is the precondition for a desync. A 400 is the HTTP status code for a bad request.
  3. Redirect gadgets on the back end. Look for endpoints that reflect the request line or Host into an absolute Location. A positive result is a redirect to a host you control that still carries the victim's cookies.
  4. Connection reuse across users. Check whether the front end pools back-end connections between different sessions. If it does, a successful smuggle reaches the next user on that connection rather than only yourself.

A defensive check for the framing half, as published in the write-up:

Python
import reHEADER_NAME = re.compile(r"^[!#$%&'*+.^_`|~0-9A-Za-z-]+$")   def check_framing(raw_headers):    names = [n for n, _ in raw_headers]    if any(not HEADER_NAME.match(n) for n in names):                   return reject(400, close=True)    lower = [n.lower() for n in names]    has_te, has_cl = "transfer-encoding" in lower, "content-length" in lower    if has_te and has_cl:        return reject(400, close=True)                             if has_te and header(raw_headers, "transfer-encoding").strip().lower() != "chunked":        return reject(400, close=True)    return forward_canonical(raw_headers)

Line by line, in plain words:

  • import re brings in Python's regular expression module, a tool for matching text against a pattern.
  • HEADER_NAME = re.compile(...) builds a pattern that describes a valid header name: one or more characters drawn from a fixed set of letters, digits and punctuation, and nothing else. A space is not in that set, so a name with a space before the colon fails the test.
  • def check_framing(raw_headers): defines a function that receives the headers of an incoming request.
  • names = [n for n, _ in raw_headers] pulls out just the header names, ignoring their values.
  • if any(not HEADER_NAME.match(n) for n in names): asks whether any name fails the pattern. If so, the next line runs.
  • return reject(400, close=True) refuses the request with a 400 and closes the connection, so nothing ambiguous is left on the wire.
  • lower = [n.lower() for n in names] makes a lowercase copy of the names, so the checks are not fooled by capitalisation.
  • has_te, has_cl = ... records whether a transfer-encoding header and a content-length header are both present.
  • if has_te and has_cl: followed by return reject(400, close=True) rejects any request that declares its length in both ways, which is exactly the ambiguity smuggling relies on.
  • if has_te and header(raw_headers, "transfer-encoding").strip().lower() != "chunked": rejects any Transfer-Encoding value other than plain chunked, after trimming spaces and ignoring case.
  • return forward_canonical(raw_headers) passes on a rebuilt, standardised request rather than the raw bytes, so the back end sees exactly what the front end saw.

Glossary

  • API: a defined way for one piece of software to talk to another, like a menu of requests a service accepts.
  • Back-end server: the computer behind the front door that does the real work of the application.
  • Bug bounty: a programme that pays people for responsibly reporting security bugs.
  • Chunked Transfer-Encoding: a way of sending a request body in labelled pieces, each with its own size, ending with a zero-size piece.
  • CL.TE desync: a request smuggling mismatch where the front end uses Content-Length and the back end uses Transfer-Encoding, so the two disagree about where the request ends.
  • Content-Length: a header stating how many bytes long the request body is.
  • Cookie: a small piece of data a site stores in your browser and receives back on each request, often used to keep you logged in.
  • CWE: a catalogue of common weakness types used to classify security bugs.
  • CVE: a public identifier for a specific known vulnerability.
  • CVSS: a scoring system for how severe a vulnerability is.
  • Desync: a state where two systems handling the same traffic fall out of step about what has been sent.
  • Endpoint: a specific address or function in an application that accepts requests.
  • Front-end server: the server at the edge that receives requests first and passes them to the back end, also called a proxy or edge.
  • Gadget: an otherwise harmless feature that an attacker can repurpose as part of an exploit.
  • Header: a line of metadata in an HTTP request or response, such as Content-Length.
  • Host: the part of a web address naming the server, for example the domain name.
  • HTTP: the protocol browsers and servers use to exchange requests and responses.
  • HTTP request smuggling: a class of bug where two servers disagree about where one request ends and the next begins, letting an attacker slip extra data into someone else's request.
  • Location: the response header that tells a browser where to go when a server redirects it.
  • Proxy: a server that sits between a client and a back end and forwards traffic.
  • Redirect: a server response telling the browser to fetch a different address instead.
  • Request line: the first line of an HTTP request, naming the method and the path being requested.
  • Session cookie: a cookie that identifies a logged-in session, so holding it is equivalent to being logged in.
  • Session hijacking: taking over someone else's logged-in session, usually by stealing their session cookie.
  • Token set: the strict list of characters allowed in a valid HTTP header name.
  • Transfer-Encoding: a header describing how a request body is encoded for transport, such as chunked.
  • Workspace: a Slack customer's own space inside the platform, holding its channels, messages and files.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.