Skip to content
Open redirect Write-up Beginner

Open-redirect Vulnerability on Facebook

The exit_uri parameter in Facebook's mobile story viewer accepted an arbitrary external URL and redirected the user to it without passing through the Linkshim filter. An attacker could craft a link that sends victims to a malicious site while appearing to originate from Facebook.

Ashok Chapagai Follow

Published on medium.com

Bounty$500 View original

#### dw1

dw1, 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

Facebook wraps outbound links in a redirect mechanism called Linkshim. As the report describes it, every time a link is clicked on the site, the URL is checked against Facebook's own internal list of malicious links, along with the lists of numerous external partners including McAfee, Google, Web of Trust and Websense. If Facebook detects that a URL is malicious, it displays an interstitial page before the browser actually requests the suspicious page. The full explanation is referenced in a Facebook note at https://www.facebook.com/10150492832835766.

The feature in scope here is the mobile story viewer. Stories can be opened from the Home page or directly from a profile page, and the profile route generates a different endpoint that carries a callback parameter.

Setup

The researcher's Facebook personal account was blocked for up to a month for violating Facebook community standards, so the account could not update or share status, comment on status, like pages, or add and accept friend requests. The only available action was viewing friends' statuses on the homepage. The work was done through a mobile browser against m.facebook.com, starting from an attempt to download a friend's story.

Finding it

Opening Facebook in the mobile browser and viewing a story from the Home page did not expose the interesting parameter. Looking at the story from the Home page shows the next stories of friends in a certain time window, and no exit_uri appears in that flow.

Viewing the same story through the profile page directly, by clicking the profile picture, generated a different endpoint:

Text
https://m.facebook.com/story/view/?bucket_id=:bucket_id&viewer_session_id=:session_id&exit_uri=/profile.php?id=:profile_id

The parameter of interest is exit_uri. It behaves like a URL callback: once all the available stories have been seen, the viewer is directed to the value of exit_uri. In the normal flow that value is a relative path back to the profile.

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

Exploitation

Step 1: reach the story viewer through the profile route

Instead of opening the story from the Home page, open it from the profile page by clicking the profile picture. This produces the story/view/ request shown above, with exit_uri set to a relative profile URL.

Step 2: replace the callback value

The researcher changed the value of exit_uri to an external site:

Text
http://evilzone.org

Step 3: view all available stories

When all the available stories have been seen, the viewer redirects to the value of exit_uri. With the modified value, the page redirects to the external site, and there is no Linkshim filter in the path.

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

The redirect fires only after the story sequence is exhausted, so the condition for the callback to trigger is that the viewer has seen all the available stories.

A limit worth knowing

Facebook does not consider an open redirect a vulnerability if the payload URL is shortened. In other words, Facebook does not check two or more levels deep, because users can shorten a URL to 100 levels, which makes sense as a policy decision.

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

Root cause

The exit_uri parameter is a post-story callback that the server uses to send the viewer somewhere after the story sequence ends. The value is taken from the request and used as a redirect target, and an absolute external URL is accepted. The report observes that there is no Linkshim filter on this redirect. The report does not describe the server-side validation, so the exact check that is missing is not stated; the observable behaviour is that an absolute external URL is accepted and used as the redirect target.

Impact

Opening a crafted story/view/ URL with a modified exit_uri redirects to the external site after the stories finish, without the Linkshim filter. The report does not describe any further abuse beyond the redirect itself, and it notes that Facebook does not consider an open redirect a vulnerability if the payload URL is shortened.

Fix

Facebook resolved the issue: the vulnerability was patched, as recorded in the timeline below.

Timeline

Date Event
19-01-2020 Vulnerability reported
20-01-2020 The Facebook team reproduces and investigates the vulnerability
21-01-2020 Triaged
11-02-2020 Resolved, vulnerability patched
12-02-2020 Bounty rewarded

Variants to test

  1. Look for other callback parameters on redirect endpoints, such as exit_uri, return, next, redirect_uri or callback, and try an absolute external URL. A positive result is a 30x response whose Location header points to the external host without an interstitial.
  2. Test the same parameter with a protocol-relative value such as //evilzone.org and with a scheme other than HTTP. A positive result is the browser leaving the trusted domain.
  3. Compare the same feature reached through different entry points (home feed versus profile route). A positive result is a parameter present in one route and absent in the other, as happened here.
  4. Check whether the redirect target is validated only on the first hop, for example by chaining through a URL shortener or another redirector on an allowed domain. A positive result is the final landing page being attacker-controlled while every intermediate hop is on an allowlisted host.
  5. Test whether the callback fires only after a state change, such as exhausting a story sequence or completing a flow. A positive result is the redirect appearing only after that condition is met, which shows the check is tied to the flow rather than to the parameter.

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

What happened, in plain words

A security researcher found a way to make Facebook redirect to an external website, without the usual warning page. The trick was a parameter in the address of a Facebook page that shows friends' stories. By changing that parameter, the researcher could make Facebook redirect to an external site after the stories finished. Facebook fixed the problem and paid a bounty of 500 USD.

This article explains the whole story from scratch, for someone who has never done security testing. You only need to know how to use a browser.

Background: what is Linkshim?

Facebook doesn't want you to land on malicious websites. So when you click a link on Facebook, Facebook first checks the link against its own list of bad sites and against lists from partners such as McAfee, Google, Web of Trust and Websense. If the link looks dangerous, Facebook shows a warning page (called an interstitial) before your browser actually goes to the site. This protection is called Linkshim.

The researcher refers to a Facebook note that explains Linkshim: https://www.facebook.com/10150492832835766.

The feature: stories on mobile

Stories are the short photo or video updates that appear at the top of the Facebook app and on the website. You can open a story from your Home page, or you can go directly to a friend's profile and tap their profile picture to see their story.

The researcher was using a mobile browser, at m.facebook.com, the mobile version of Facebook.

How the researcher found it

At the time, the researcher's own Facebook account was blocked for up to a month for violating Facebook's community standards. The account could not update or share status, comment, like pages, or add and accept friend requests. The only thing it could do was see friends' statuses on the homepage. The researcher started by trying to download a friend's story.

When viewing a story from the Home page, the address of the page did not contain anything unusual. But when viewing the same story by going to the friend's profile and clicking the profile picture, the address was different. It looked like this:

Text
https://m.facebook.com/story/view/?bucket_id=:bucket_id&viewer_session_id=:session_id&exit_uri=/profile.php?id=:profile_id

Let's break this address down:

  • https://m.facebook.com/story/view/ is the page that shows a story.
  • ? starts the list of parameters, which are extra pieces of information sent to the server.
  • bucket_id=:bucket_id is a parameter that identifies a group of stories. The value :bucket_id is a placeholder; the real value would be some identifier.
  • viewer_session_id=:session_id is a parameter that identifies your session, that is, your logged-in visit. The value :session_id is a placeholder for a session identifier.
  • exit_uri=/profile.php?id=:profile_id is the interesting parameter. exit_uri means "the address to go to when exiting". Its value here is a relative path back to the profile page.

The parameter exit_uri works like a callback: after you have seen all the available stories, Facebook sends you to whatever address is in exit_uri. In normal use, that address is the profile page you came from.

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

The vulnerability: open redirect

An open redirect is a flaw where a website takes an address from the request and sends the user there without checking that the address belongs to the same site. Attackers abuse it because the link starts with the trusted site's name (here, m.facebook.com), so victims trust it, but end up on an attacker's site.

Step 1: get the story page from the profile

Instead of opening the story from the Home page, the researcher opened it from the profile page by clicking the profile picture. This produced the story/view/ address shown above, with exit_uri pointing to a profile.

Step 2: change the callback address

The researcher replaced the value of exit_uri with an external site:

Text
http://evilzone.org

This is just a normal web address for a site called evilzone.org. The researcher put it where the profile path used to be.

Step 3: view all the stories

When all the available stories have been seen, the story viewer redirects to the value of exit_uri. With the changed value, the page redirected to http://evilzone.org, and there was no Linkshim warning page. The redirect only happens after the story sequence is finished, so the condition is that the viewer has seen all the stories.

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

A limit worth knowing

Facebook does not consider an open redirect a vulnerability if the payload URL is shortened. In other words, Facebook does not check two or more levels deep, because users can shorten a URL to 100 levels, which makes sense as a policy decision.

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

Why it worked

The exit_uri parameter is a post-story callback: the server uses it to send the viewer somewhere after the story sequence ends. The value is taken from the request and used as a redirect target, and an absolute external URL is accepted. The report observes that there is no Linkshim filter on this redirect. The report does not describe the server-side validation, so the exact check that is missing is not stated; the observable behaviour is that an absolute external URL is accepted and used as the redirect target.

Impact

Opening a crafted story/view/ URL with a modified exit_uri redirects to the external site after the stories finish, without the Linkshim filter. The report does not describe any further abuse beyond the redirect itself, and it notes that Facebook does not consider an open redirect a vulnerability if the payload URL is shortened.

Fix

Facebook resolved the issue: the vulnerability was patched, as recorded in the timeline below.

Timeline

Date Event
19-01-2020 Vulnerability reported
20-01-2020 The Facebook team reproduces and investigates the vulnerability
21-01-2020 Triaged
11-02-2020 Resolved, vulnerability patched
12-02-2020 Bounty rewarded

Variants to test

  1. Look for other callback parameters on redirect endpoints, such as exit_uri, return, next, redirect_uri or callback, and try an absolute external URL. A positive result is a 30x response whose Location header points to the external host without an interstitial.
  2. Test the same parameter with a protocol-relative value such as //evilzone.org and with a scheme other than HTTP. A positive result is the browser leaving the trusted domain.
  3. Compare the same feature reached through different entry points (home feed versus profile route). A positive result is a parameter present in one route and absent in the other, as happened here.
  4. Check whether the redirect target is validated only on the first hop, for example by chaining through a URL shortener or another redirector on an allowed domain. A positive result is the final landing page being attacker-controlled while every intermediate hop is on an allowlisted host.
  5. Test whether the callback fires only after a state change, such as exhausting a story sequence or completing a flow. A positive result is the redirect appearing only after that condition is met, which shows the check is tied to the flow rather than to the parameter.

Glossary

  • Open redirect: a vulnerability where a website sends you to an address taken from the request without checking that it belongs to the same site.
  • Linkshim: Facebook's system that checks links against lists of malicious sites and shows a warning page before going to a suspicious site.
  • Interstitial: a warning page shown before you reach the actual page.
  • Parameter: an extra piece of information in a web address, after the ?, in the form name=value.
  • Callback: a mechanism where a website sends you to a specified address after an action is complete.
  • Endpoint: a specific address on a website that performs a function, such as showing a story.
  • Session: a logged-in visit to a website, identified by a session ID.
  • Payload: the part of an attack that carries the malicious data, here the external URL.
  • Bounty: a reward paid by a company for reporting a security vulnerability.
  • Triaged: the stage where a security team confirms and categorises a reported vulnerability.
  • 30x response: an HTTP response that tells the browser to go to a different address.
  • Location header: the part of a 30x response that contains the address to go to.
  • Protocol-relative URL: an address starting with // that uses the same protocol (HTTP or HTTPS) as the current page.
  • Allowlist: a list of addresses that are permitted.
  • URL shortener: a service that turns a long web address into a short one that redirects to the original.

More by Ashok Chapagai

View all

3 more disclosed reports, best first.

More from Meta

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Open redirect

The lesson behind this report.

A trusted site forwards users to any address an attacker picks; rarely paid alone, often the missing link in a chain.