Skip to content
SSRF Write-up Intermediate

$1.000 SSRF in Slack

Slack's slash commands and event subscriptions allowed users to supply URLs that the backend would fetch, and a blacklist tried to block internal addresses. The author bypassed the blacklist by using an IPv6 address and a redirect, reaching internal services such as SSH and SMTP.

Elber Andre Follow

Published on medium.com

Bounty$1,000 View original

#### Elber Andre

Elber Andre, 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. 5 min read.

Context

Slack is a collaboration hub that brings people, information and tools together. Two features accept a URL that Slack's backend servers will later fetch: Slash Commands (and integrations such as Phabricator) and the Event Subscriptions parameter of an app. In both cases the user supplies a URL and Slack's servers make a request to it, which is exactly the shape of a server-side request forgery (SSRF) primitive.

A blacklist is meant to stop those requests from reaching internal resources: loopback, [redacted]/8, [redacted]/24 and similar ranges. As HackerOne user agarri_fr described it for Slack:

Some Slack features like "Integrations / Phabricator" and "Integration / Slash Commands" allow users to submit URL that will be accessed by the backend servers. A blacklist tries to forbid access to internal resources (loopback, [redacted]/8, [redacted]/24, …). This blacklist can be bypassed using "[::]" as the hostname. Only services binding all the interfaces and supporting IPv6 can be reached using that vector.

Slack then disabled the option to register IPv6 addresses in Slash Commands. A Slack staff member, slacka, wrote:

I created a new issue for the ipv6 blocking and escalated the case with our engineers. I'll let you know when we have an update.

That was marked as fixed. For the researcher, the fix was a bypass.

Setup

The attacker-side host is referred to as hackerserver[.]com and later hacker.site; the PHP files are index.php and x.php.

Finding it

The starting point was the earlier IPv6 blacklist bypass: using [::] as the hostname reaches services that bind all interfaces and speak IPv6. Slack closed that by refusing to register IPv6 addresses in Slash Commands.

Exploitation

Step 1: a redirect on your own domain

On the researcher's own domain, index.php was set up to answer with a Location header pointing at the IPv6 loopback:

PHP
<?php header("location: http://[::]:22/"); ?>

The resulting header is:

HTTP
location: http://[::]:22/

Save the file. The slash command is then configured to point at the researcher's server, http://hackerserver[.]com/, and invoked from Slack by typing /youslash.

Step 2: results on ports 22 and 25

The backend followed the redirect to http://[::]:22/. The result for port 22:

And for port 25:

Image for post
Image for post From the original on medium.com

In other words, the redirect carried Slack's fetcher past the IPv6 registration block and onto loopback services. The timeline for this first issue:

Date Event
Jul 13th First response
Jul 18th Triaged
Jan 23 Slack rewarded elber with a $500 bounty

Step 3: the Event Subscriptions parameter

After the slash command bypass, the researcher looked for the same weakness elsewhere and found the Event Subscriptions parameter, described in Slack's own words as:

Your app can subscribe to be notified of events in Slack (for example, when a user adds a reaction or creates a file) at a URL you choose.

The configuration page is:

Text
https://api.slack.com/apps/YOUAPPCODE/event-subscriptions?

When a URL that does not meet the API's standards is submitted, Slack answers with:

Text
Your request URL gave us a 500 error. Update your URL to receive a new request and challenge value.
Image for post
Image for post From the original on medium.com

Step 4: bypass with an IPv6 vector

The bypass again uses [::]. On the researcher's host, x.php takes the target from the u parameter and reflects it into a Location header:

PHP
<?phpheader("location: ".$_GET['u']);?>

The proof of concept URL:

Text
http://hacker.site/x.php/?u=http://%5B::%5D:22/

Here %5B and %5D are the percent-encoded [ and ], so the value passed to the Location header is http://[::]:22/. The response observed:

Text
SSH [::]:22
Image for post
Image for post From the original on medium.com

And on port 25:

Text
SMTP [::]:25
Image for post
Image for post From the original on medium.com

Step 5: duplicate handling

Slack marked this second report as a duplicate of another SSRF. The researcher insisted on being listed as a participant in the other report, and argued that the other report was different from his, so the team might have made a mistake. The timeline:

Date Event
Jul 24th Duplicated
Sep 2nd Triaged
Jan 23 Slack rewarded elber with a $500 bounty

Root cause

The validation was applied to the URL supplied in the configuration field, and that validation rejected IPv6 literals such as [::]. The fetcher, however, followed HTTP redirects. A redirect issued by an attacker-controlled host is a new URL that the backend requests without the same registration-time check, so the IPv6 loopback address reached the fetcher through the Location header instead of through the form.

Impact

An attacker who can configure a slash command or an app's Event Subscriptions URL can make Slack's backend servers issue requests to services reachable from those servers, including loopback addresses over IPv6. In the demonstrations this reached SSH on port 22 and SMTP on port 25. The earlier description notes the limit: only services binding all interfaces and supporting IPv6 can be reached using that vector. The report does not show data exfiltration or further pivoting; the demonstrated result is reachability of internal services.

Fix

Slack disabled registration of IPv6 addresses in Slash Commands, which the researcher bypassed with the redirect. The report does not state what change, if any, was made for the Event Subscriptions issue.

Variants to test

  1. Redirect chains: point the configured URL at your host and answer with a Location header to an internal address. A positive result is a response from the internal service, as with SSH [::]:22 and SMTP [::]:25 here.
  2. IPv6 literal forms: try [::], [::1] and other IPv6 loopback spellings in the redirect target. A positive result is a connection to a loopback-only service.
  3. Other redirect status codes and relative Location values: if the fetcher follows them, the same bypass may apply. A positive result is a request arriving at an internal address.
  4. Different features that fetch user-supplied URLs (webhooks, integrations, event subscriptions): test each with the same redirect technique. A positive result is any internal response reflected back to you.
  5. DNS-based bypass: a hostname you control that resolves to a loopback or private address, used as the redirect target. A positive result is the fetcher connecting to the internal address.

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.

What happened, in plain words

Slack is a chat program that teams use to talk to each other. Besides sending messages, Slack can be told to fetch a web address (a URL) for you. For example, a "slash command" is a shortcut you type in a chat box, like /youslash, and Slack's own computers then go and visit a web address that someone configured earlier. Slack also lets app developers say "send me a notification at this web address whenever something happens in Slack", a feature called Event Subscriptions.

Because Slack's computers make those visits, a person who can choose the address can try to make Slack's computers visit places on Slack's own internal network, places that outsiders are not supposed to reach. That kind of trick is called server-side request forgery, or SSRF: you are not breaking into a server directly, you are persuading a server to make a request on your behalf.

Slack tried to stop this with a blocklist: a list of address ranges that the fetcher is not allowed to visit, such as the machine's own loopback address (the address a computer uses to talk to itself). The researcher Elber Andre found that the blocklist could be dodged by writing the loopback address in its IPv6 form, [::]. Slack then blocked people from typing IPv6 addresses into slash commands. Slack's computers followed the redirect to the forbidden address, and the check never saw it.

He demonstrated the same trick in the Event Subscriptions feature, and Slack paid a $1,000 bounty in total: $500 for the first issue and $500 for the second, which Slack first marked as a duplicate of another report.

Background you need

A few ideas come up again and again, so here they are from zero.

  • URL: the address of something on the web, like https://slack.com/about. It has a scheme (https), a host (slack.com) and a path (/about).
  • Server: a computer that answers requests from other computers. When you open a website, your browser asks a server for the page.
  • Backend server: the computer behind a website that does the actual work. You never see it; your browser talks to it through the site.
  • Loopback address: the address a computer uses to refer to itself. In the older IPv4 style it is [redacted]; in the newer IPv6 style it is ::1, and [::] is a way of writing an IPv6 address that means "this machine, all its network interfaces". Services listening there are often only meant for the machine itself, not for the outside world.
  • Port: a numbered door on a computer. One machine can run many services, each on its own port. Port 22 is conventionally SSH (a way to log in to a machine remotely) and port 25 is conventionally SMTP (email sending).
  • SSRF (server-side request forgery): making a server send a request to a destination of your choosing, usually to reach things you could not reach yourself. Everyday comparison: you cannot get into a building, but you can ask the receptionist to walk down the corridor for you and tell you what is there.
  • Blacklist (blocklist): a list of things that are forbidden. Here, a list of address ranges the fetcher may not visit. Its weakness is that it can only forbid what someone thought of in advance.
  • Redirect: when you ask a web server for something and it answers "not here, look over there" and gives a new address. In HTTP this is done with a response header called Location. Your browser then automatically requests the new address. Everyday comparison: you ask at a desk for a form, and the clerk points you to a different desk; you walk there without questioning it.
  • Header: a small piece of information sent along with a web request or response, separate from the main content. Location is one such header.
  • PHP: a programming language commonly used for web pages. A file ending in .php is run by the web server, and whatever it prints is sent back to the visitor.
  • Slash command: a shortcut typed into Slack's message box that starts with /, such as /youslash. Slack can be configured so that typing it makes Slack's servers call a URL you set up.
  • API: a way for two programs to talk to each other, as opposed to a page meant for a human. Slack's Event Subscriptions are part of its API: your app tells Slack "notify me at this URL", and Slack's servers call it.
  • Event Subscriptions: a Slack app setting where the developer gives a URL, and Slack sends a request to that URL whenever chosen events happen, for example when a user adds a reaction or creates a file.
  • Bounty: money a company pays a researcher who reports a security problem responsibly.
  • Triaged: a report has been looked at by the company and accepted as a real issue worth handling.
  • Duplicate: a report describing a problem the company has already received in another report, so it is linked to that one instead of being handled separately.

The researcher's two starting tips

Before the technical part, the author gives two pieces of advice to people starting in bug bounty work:

  1. Always read previous reports. You may find a bypass technique that works in your situation, or you may learn something new.
  2. If you like content about bug bounty and hacking, subscribe to his channel and follow the new posts.

That first tip matters here: the whole story starts from a technique described in an earlier report.

Slack and SSRF

Image for post
Image for post From the original on medium.com

Slack describes itself as a collaboration hub that brings the right people, information and tools together, used from Fortune 100 companies to corner markets. The important part for us is that Slack's servers fetch URLs on behalf of users.

Slash Commands

The author frames the first issue as: "SSRF in api.slack.com, using slash commands and bypassing the protections."

Slack's own help pages explain slash commands. The key sentence quoted in the report is from HackerOne user agarri_fr, describing the situation for Slack:

Some Slack features like "Integrations / Phabricator" and "Integration / Slash Commands" allow users to submit URL that will be accessed by the backend servers. A blacklist tries to forbid access to internal resources (loopback, [redacted]/8, [redacted]/24, …). This blacklist can be bypassed using "[::]" as the hostname. Only services binding all the interfaces and supporting IPv6 can be reached using that vector.

In plain words: you give Slack a URL, Slack's backend visits it, and a blocklist is supposed to stop it visiting internal addresses. The earlier researcher found that writing the host as [::] slipped past the blocklist. The caveat at the end is important: this only reaches services that listen on all network interfaces and understand IPv6.

After that earlier report, Slack disabled the option to register IPv6 addresses in Slash Commands. A Slack staff member, slacka, wrote:

I created a new issue for the ipv6 blocking and escalated the case with our engineers. I'll let you know when we have an update.

The issue was marked as fixed. For the author, the fix was a bypass: a new door to try.

The idea behind the bypass

Think about where the check happens. When you configure a slash command, you type a URL into a form, and Slack checks that text. If the text contains an IPv6 address, Slack refuses it.

A redirect changes where the fetcher ends up. If Slack's server requests your URL and your server answers with a Location header pointing somewhere else, Slack's server makes a second request to that new place. The forbidden IPv6 address never appears in the form Slack validated; it appears only in the redirect answer. That is the whole trick.

Step 1: a redirect on your own domain

To use the trick, the author needed a web server under his control that would answer with a redirect. On his own domain he created a file called index.php containing:

PHP
<?php header("location: http://[::]:22/"); ?>

Line by line:

  • <?php starts a block of PHP code inside the file.
  • header("location: http://[::]:22/"); tells the web server to send a response header named location whose value is http://[::]:22/. That is the "look over there" instruction: the address [::] (this machine, IPv6) on port 22 (SSH).
  • ?> closes the PHP block.

The resulting header is:

HTTP
location: http://[::]:22/

This is the actual instruction sent back to whoever asked for the page. Any client that follows redirects, including Slack's fetcher, will now request http://[::]:22/.

Save the file. Then configure the slash command to point at the author's server, http://hackerserver[.]com/, and invoke it from Slack by typing /youslash.

Step 2: results on ports 22 and 25

The backend followed the redirect to http://[::]:22/. The result for port 22:

And for port 25:

Image for post
Image for post From the original on medium.com

What these results mean: Slack's fetcher reached a service on its own machine. The :22 and :25 outputs are the evidence that the connection landed on those ports. In other words, the redirect carried Slack's fetcher past the IPv6 registration block and onto loopback services.

The timeline for this first issue:

Date Event
Jul 13th First response
Jul 18th Triaged
Jan 23 Slack rewarded elber with a $500 bounty

Step 3: the Event Subscriptions parameter

After the slash command bypass, the author looked for the same weakness elsewhere in Slack and found the Event Subscriptions parameter. He describes it as: "Bypass of the SSRF protection in Event Subscriptions parameter."

Slack's own description of the feature, quoted in the report:

Your app can subscribe to be notified of events in Slack (for example, when a user adds a reaction or creates a file) at a URL you choose.

In plain words: a developer building a Slack app gives Slack a URL, and Slack's servers call that URL when something happens. That is the same shape as the slash command problem: a user-supplied URL that Slack's backend will fetch.

The configuration page is:

Text
https://api.slack.com/apps/YOUAPPCODE/event-subscriptions?

Here YOUAPPCODE is a placeholder for the identifier of a particular app; the report does not give a real one. The page is where the developer sets the notification URL.

When a URL that does not meet the API's standards is submitted, Slack answers with:

Text
Your request URL gave us a 500 error. Update your URL to receive a new request and challenge value.
Image for post
Image for post From the original on medium.com

A 500 error is the general "something went wrong on the server" answer. The message tells the developer to update the URL and try again. This is the normal behaviour when the URL is not acceptable.

Step 4: bypass with an IPv6 vector

The bypass again uses [::]. This time the author's server does not hard-code the destination; it takes it from the request. On his host, x.php contains:

PHP
<?phpheader("location: ".$_GET['u']);?>

Line by line:

  • <?php starts the PHP block.
  • header("location: ".$_GET['u']); sends a location header. The value is built by joining the text location: with $_GET['u'], which is the value of the u parameter in the incoming request. So whatever you put after ?u= in the URL becomes the redirect destination.
  • ?> closes the block.

Why this design: instead of editing the file for every test, the author can pass any destination in the URL. The server simply repeats it back as a redirect.

The proof of concept URL:

Text
http://hacker.site/x.php/?u=http://%5B::%5D:22/

Breaking it down:

  • http://hacker.site/x.php/ is the author's own server and the PHP file.
  • ?u= starts the parameter named u.
  • http://%5B::%5D:22/ is the value of u. %5B and %5D are the percent-encoded forms of [ and ]. Percent-encoding is how special characters are written safely inside a URL; a browser or server decodes them back to the real characters.

So the value passed to the Location header is http://[::]:22/, the IPv6 loopback on port 22. The response observed:

Text
SSH [::]:22
Image for post
Image for post From the original on medium.com

And on port 25:

Text
SMTP [::]:25
Image for post
Image for post From the original on medium.com

SSH and SMTP here are the names of the services that answered on those ports. The point is the same as before: Slack's backend followed the redirect and connected to a service on its own machine, which the blocklist was supposed to prevent.

Step 5: duplicate handling

Slack marked this second report as a duplicate of another SSRF report. The author insisted that they list him as a participant in the other report. He had looked at the other report and saw that it was different from his, so he told the team they might have made a mistake.

The timeline:

Date Event
Jul 24th Duplicated
Sep 2nd Triaged
Jan 23 Slack rewarded elber with a $500 bounty

Why it worked

The check was applied to the URL typed into the configuration field, and that check rejected IPv6 addresses such as [::]. But the fetcher followed redirects. A redirect from a server the attacker controls is a new URL that the backend requests without the same registration-time check, so the IPv6 loopback address reached the fetcher through the Location header instead of through the form.

What it means

Someone who can configure a slash command, or an app's Event Subscriptions URL, can make Slack's backend servers send requests to services reachable from those servers, including loopback addresses over IPv6. In the demonstrations this reached SSH on port 22 and SMTP on port 25. The earlier description notes the limit: only services that listen on all interfaces and support IPv6 can be reached this way. The report does not show data being taken out or any further movement inside the network; what it demonstrates is that internal services can be reached.

The fix

Slack disabled registration of IPv6 addresses in Slash Commands, which the author bypassed with the redirect.

Things to try yourself

These are the kinds of variations worth testing if you are learning. Each one has a clear sign of success.

  1. Redirect chains: point the configured URL at your own host and answer with a Location header to an internal address. Success looks like a response from the internal service, as with SSH [::]:22 and SMTP [::]:25 here.
  2. IPv6 literal forms: try [::], [::1] and other IPv6 loopback spellings in the redirect target. Success is a connection to a loopback-only service.
  3. Other redirect status codes and relative Location values: if the fetcher follows them, the same bypass may apply. Success is a request arriving at an internal address.
  4. Different features that fetch user-supplied URLs (webhooks, integrations, event subscriptions): test each with the same redirect technique. Success is any internal response reflected back to you.
  5. DNS-based bypass: a hostname you control that resolves to a loopback or private address, used as the redirect target. Success is the fetcher connecting to the internal address.

References

The author lists these HackerOne reports as background:

He also notes that the reports would be publicly disclosed on HackerOne on 02/22.

Glossary

  • API: a way for two programs to talk to each other, rather than a page meant for a person.
  • Backend server: the computer behind a service that does the real work, which users do not see directly.
  • Blacklist (blocklist): a list of forbidden things, here address ranges the fetcher may not visit.
  • Bounty: money a company pays for a responsibly reported security problem.
  • Duplicate: a report describing a problem already covered by another report, linked to it instead of handled separately.
  • Event Subscriptions: a Slack app setting where the developer supplies a URL that Slack calls when chosen events happen.
  • Header: a small piece of information sent with a web request or response, separate from the main content.
  • HTTP: the language browsers and servers use to exchange requests and responses on the web.
  • IPv4 / IPv6: two versions of the addressing system for the internet. IPv4 addresses look like [redacted]; IPv6 addresses are longer and written with colons, like ::1.
  • Location header: the response header that tells a client to go to a different address, used for redirects.
  • Loopback address: the address a computer uses to refer to itself, such as [redacted] in IPv4 or ::1 in IPv6.
  • Percent-encoding: writing special characters in a URL as % plus a code, such as %5B for [.
  • PHP: a programming language commonly used to build web pages.
  • Port: a numbered door on a computer through which a particular service is reached; 22 is conventionally SSH and 25 is conventionally SMTP.
  • Redirect: a server's answer telling the client to request a different address instead.
  • Slash command: a shortcut typed into Slack starting with /, which can be configured to make Slack's servers call a URL.
  • SMTP: the protocol used to send email.
  • SSH: a protocol for logging in to a machine remotely.
  • SSRF (server-side request forgery): making a server send a request to a destination of your choosing, often to reach internal services.
  • Triaged: a report has been reviewed and accepted as a real issue to handle.
  • URL: the address of something on the web, made of a scheme, a host and a path.
  • Webhook: a URL that a service calls automatically when something happens, to notify another system.

More by Elber Andre

View all

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

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.