Skip to content
CSRF Write-up Advanced

Facebook graphql CSRF

The Instagram business tools page passed a user-controlled path segment into a Graph API request, so a crafted link could make the victim's browser issue GraphQL mutations with the victim's token. An attacker could perform arbitrary mutations, such as creating a story, as the victim.

Philippe Harewood Follow

Published on philippeharewood.com

Bounty$7,500 View original

There was a “CSRF” styled query in business.instagram.com that can allow GraphQL calls to be made. The discovery of the bug in View the Assigned Roles and Emails of an Instagram Account started at business.instagram.com/login with an authorization screen.

Philippe, on philippeharewood.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. 6 min read.

Context

business.instagram.com is the Instagram Business Tools web application. It is a client-side routed application that loads modules such as BusinessToolsEntrypoint.instagram, BusinessLogin.instagram, BusinessSelect.instagram, BusinessHome.instagram and BusinessStore.instagram. The /select screen picks a business, and the /business/:id routes load data for a given business ID from the Facebook Graph API using the Instagram Tools access token.

The report describes a "CSRF" styled query in business.instagram.com that allows GraphQL calls to be made. The discovery began while looking at a separate issue, View the Assigned Roles and Emails of an Instagram Account.

Setup

The entry point examined was business.instagram.com/login, which presents an authorisation screen. If the user did not have an Instagram Business account, an error page was shown instead.

The last screen of that flow sent the user to https://business.instagram.com/select. The researcher notes having no Instagram businesses, so no permission to the tools; the researcher had no Instagram businesses and so no permission to the tools.

Finding it

Searching for the string /select in Chrome Developer Tools points to the BusinessToolsEntrypoint.instagram module. Inside it, a function shows the flow:

JavaScript
c("Router.instagram").get("/login", function(l, m, n) {
        c("auth.instagram").ensure(function() {
            m.redirect("/select")
        }, function() {
            c("Bootloader").loadModules(["BusinessLogin.instagram"], function(o) {
                m.send({
                    component: o
                })
            }, "BusinessToolsEntrypoint.instagram")
        })
    });

One function lower shows what happens for the business /select screen:

JavaScript
c("Router.instagram").get("/select", i(function(l, m, n) {
        c("Bootloader").loadModules(["BusinessSelect.instagram"], function(o) {
            m.send({
                component: o
            })
        }, "BusinessToolsEntrypoint.instagram")
}));

And in the BusinessSelect.instagram module:

JavaScript
function k() {
        var l, m;
        "use strict";
        for (var n = arguments.length, o = Array(n), p = 0; p < n; p++) o[p] = arguments[p];
        return m = (l = j.constructor).call.apply(l, [this].concat(o)), this.state = {
            businesses: null
        }, this.dataChangeHandler = function() {
            var q = c("FBViewerStore.instagram").getAllBusinesses(),
                r = c("FBViewerStore.instagram").getViewerBusiness();
            if (q && q.length === 1 && !r) {
                var s = q[0],
                    t = c("Router.instagram").getQueryParams();
                c("Router.instagram").navigate("/business/" + s.id, t)
            } else this.setState({
                businesses: q
            })
        }.bind(this), this.renderError = function() {
            return c("React").createElement(c("BusinessMessage.instagram"), {
                heading: h._("You do not have permission to access Business Tools."),
                subHeading: h._("Contact your work admin if you think this is a mistake."),
                withBox: true
            })

Returning to the BusinessToolsEntrypoint.instagram module, the researcher lists the routes that can happen in the tool:

  • /login
  • /business/:id
  • /business/:id/manage/people
  • /business/:id/manage/accounts
  • /business/:id/manage/adaccounts/
  • /business/:id/insights/:username/:tab?
  • /business/:id/insights/:username/:tab?/p/:shortcode

Following the flow for /business/:id:

  1. BusinessToolsEntrypoint.instagram

    • Route the slug "/business/:id"
    • c("Router.instagram").get("/business/:id"...
    • c("Bootloader").loadModules(["BusinessHome.instagram"]...
    • m.send({ component: o, props: l.params })...
  2. BusinessHome.instagram

    • Handle data changes for the component and load the business data
    • m.prototype.componentDidMount
    • c("BusinessStore.instagram").addListener(c("BusinessStore.instagram").CHANGE_EVENT
    • this.dataChangeHandler()
    • this.dataChangeHandler = function()
    • c("BusinessStore.instagram").getBusiness(this.props.id)
  3. BusinessStore.instagram

    • Request the business data from Facebook Graph API
    • this._fetchBusiness(x)
    • u(t(x), "get").then(function(A)
    • s = "?fields=" + ["id", "name", r].join()
    • function t(w) { return w + s }
    • function u(w, x, y)
    • c("graph.instagram")(w, x, y, function(B, C)

Exploitation

Step 1: the :id segment is passed straight into a Graph API request

If a user went to https://business.instagram.com/business/113702895386410, the :id portion would be sent to the component from BusinessHome.instagram. A data change listener handles a data load request for the ID 113702895386410 and calls the GraphAPI:

HTTP
https://graph.facebook.com/v2.4/113702895386410?access_token=IG_TOKEN&callback=FB.__globalCallbacks.f1a20b453d927fc&fields=id%2Cname%2Cinstagram_users.limit(1000).filtering(%5B%7Bfield%3A%22role%22%2Coperator%3A%22IN%22%2Cvalue%3A%5B%22manager%22%2C%22analyst%22%5D%7D%5D).fields(id%2Cusername%2Clogging_start_date%2Crole%2Cprofile_pic%2Cmedia_count%2Cfollow_count%2Cfollowed_by_count%2Cinsights.metric(page_impressions%2Cpage_impressions_unique).since(1506126329).until(1509323129)%2Cinstagram_media.limit(8).fields(id%2Ccontent_type%2Cdisplay_url%2Cvideo_url))&method=get&pretty=0&sdk=joey

However 113702895386410 isn't an Instagram business account. So it seems the :id parameter has some flexibility with using the Graph API. Since the access_token used in Instagram Tools has access to GraphQL, there should be a way to perform calls.

Step 2: a GraphQL mutation that does not need POST

The researcher constructs a GraphQL mutation and notes that it does not need to be sent via HTTP POST:

Text
graphql?q=Mutation SyncAddMutations : SyncAddMutationsResponse {story_create(<input>){client_mutation_id}}&query_params={'input':'{\'actor_id\':\'TARGET_ID\',\'client_mutation_id\':\'1\',\'audience\':{\'privacy\':{\'@_@\':\'@_@\',\'@_@\':\'@_@\'}},\'@_@\':\'@_@\',\'message\':{\'text\':\'MaliciousMessage\'}}'}

@_@ marks other fields dropped for brevity. The mutation is a story_create call whose input carries an actor_id (the victim), a client_mutation_id, an audience/privacy object and a message text.

Step 3: the final link sent to the victim

The final query to send to the victim places the GraphQL query into the :id segment of the business route, URL-encoded:

HTTP
https://business.instagram.com/business/graphql%3Fq%3DMutation%20SyncAddMutations%20%3A%20SyncAddMutationsResponse%20%7Bstory_create%28%3Cinput%3E%29%7Bclient_mutation_id%7D%7D%26query_params%3D%7B%27input%27%3A%27%7B%5C%27actor_id%5C%27%3A%5C%27TARGET_ID%5C%27%2C%5C%27client_mutation_id%5C%27%3A%5C%271%5C%27%2C%5C%27audience%5C%27%3A%7B%5C%27privacy%5C%27%3A%7B%5C%27@_@%5C%27%3A%5C%27@_@%5C%27%2C%5C%27@_@%5C%27%3A%5C%27@_@%5C%27%7D%7D%2C%5C%27@_@%5C%27%3A%5C%27@_@%5C%27%2C%5C%27message%5C%27%3A%7B%5C%27text%5C%27%3A%5C%27MaliciousMessage%5C%27%7D%7D%27%7D%26fixend

The fixend is appended to handle the original query formed in BusinessStore.instagram:

JavaScript
s = "?fields=" + ["id", "name", r].join()
function t(w) { return w + s }

Root cause

The :id route parameter is concatenated into a Graph API URL without being constrained to a numeric business ID, and the resulting request is issued with the Instagram Tools access token, which has access to GraphQL. Because the GraphQL query can be carried in the URL rather than an HTTP POST body, a crafted link to business.instagram.com is enough to make the victim's browser issue the mutation with their own credentials. The report does not describe any CSRF token or origin check that would have stopped it.

Impact

This issue allowed an attacker to carry out arbitrary mutations (CSRF) as the victim. The link provided by the attacker is specific to a victim (actor_id) and the victim should authenticate the Instagram business app.

Fix

Facebook fixed the issue on 10 October 2017, two days after the report was sent. The report does not describe the change that was made.

Variants to test

  • Other client-side routes that take an identifier and interpolate it into a Graph API URL (for example the /business/:id/manage/... and /business/:id/insights/... routes listed above). A positive result is a request to graph.facebook.com whose path or query contains attacker-controlled text rather than a plain ID.
  • GraphQL operations that can be expressed as a GET query string, as story_create was here. A positive result is a mutation that executes when delivered as a link, without a POST body.
  • Appending a terminator such as fixend to absorb a suffix the client adds to the injected value. A positive result is a well-formed upstream request despite the application's own appended parameters.
  • Replaying the crafted link against an account that is authenticated to the business app. A positive result is a state change attributed to the victim's actor_id.

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

What happened, in plain words

Instagram has a website for businesses, at business.instagram.com. It is called Instagram Business Tools. If you own an Instagram business account, you can log in there to manage that business.

This website is not built the old way, where every click asks the server for a brand new page. It is a single program that your browser downloads once, and that program then draws the different screens itself as you move around. In web development this is called a client-side application, and the act of moving between screens inside it is called routing. Each screen has its own address, and the program decides which screen to show by looking at that address.

The researcher found that one part of the address, the part that is supposed to be a business's number, was being pasted into a request to Facebook's servers without any check that it really was a number. By putting a specially crafted piece of text in that spot, an attacker could make the victim's own browser send a command to Facebook, using the victim's own login. That is a cross-site request forgery, or CSRF: the attacker does not steal the victim's password or session, they simply get the victim's browser to send a request the victim never intended.

The report describes a "CSRF" styled query in business.instagram.com that allows GraphQL calls to be made. The discovery began while the researcher was looking at a separate issue, View the Assigned Roles and Emails of an Instagram Account.

The starting point

The researcher started at business.instagram.com/login. That page shows an authorisation screen: a page that asks you to confirm that you want to let this application act on your behalf. If the person logging in did not have an Instagram Business account, the site showed an error page instead.

The last screen of that flow sent the user to https://business.instagram.com/select. The researcher notes having no Instagram businesses, so no permission to use the tools. That matters for the rest of the work: the researcher had no permission to use the tools.

Finding it

Reading the program in the browser

Every browser has a set of developer tools, usually opened with a key such as F12. Among other things they let you read the code that the website has downloaded, and search through it. The researcher searched that code for the text /select, the address of the screen mentioned above, to find out which part of the program was responsible for it.

The search pointed to a module called BusinessToolsEntrypoint.instagram. A module is simply one file of the program, a bundle of related code with a name. Inside that module, one function shows what happens when someone visits /login:

JavaScript
c("Router.instagram").get("/login", function(l, m, n) {
        c("auth.instagram").ensure(function() {
            m.redirect("/select")
        }, function() {
            c("Bootloader").loadModules(["BusinessLogin.instagram"], function(o) {
                m.send({
                    component: o
                })
            }, "BusinessToolsEntrypoint.instagram")
        })
    });

Line by line:

  • c("Router.instagram").get("/login", ...) registers a rule: when the address is /login, run the function that follows. The c(...) part is the program asking for another module by name, here the router, the piece of code that maps addresses to screens.
  • c("auth.instagram").ensure(...) asks the login-checking module whether the visitor is already signed in. It is given two functions: one to run if they are, one to run if they are not.
  • m.redirect("/select") is the first of those: if the visitor is signed in, send them straight to the /select screen.
  • The second function runs when they are not signed in. c("Bootloader").loadModules(["BusinessLogin.instagram"], ...) loads the module that draws the login screen. A bootloader is a small piece of code whose job is to fetch and start other pieces on demand.
  • m.send({ component: o }) tells the router to display that loaded component, o, on the page.

One function lower in the same module shows what happens for the /select screen:

JavaScript
c("Router.instagram").get("/select", i(function(l, m, n) {
        c("Bootloader").loadModules(["BusinessSelect.instagram"], function(o) {
            m.send({
                component: o
            })
        }, "BusinessToolsEntrypoint.instagram")
}));

This is the same pattern: when the address is /select, load the BusinessSelect.instagram module and display it. The i(...) wrapper around the function is not explained in the report.

What the select screen does

Inside the BusinessSelect.instagram module there is this code:

JavaScript
function k() {
        var l, m;
        "use strict";
        for (var n = arguments.length, o = Array(n), p = 0; p < n; p++) o[p] = arguments[p];
        return m = (l = j.constructor).call.apply(l, [this].concat(o)), this.state = {
            businesses: null
        }, this.dataChangeHandler = function() {
            var q = c("FBViewerStore.instagram").getAllBusinesses(),
                r = c("FBViewerStore.instagram").getViewerBusiness();
            if (q && q.length === 1 && !r) {
                var s = q[0],
                    t = c("Router.instagram").getQueryParams();
                c("Router.instagram").navigate("/business/" + s.id, t)
            } else this.setState({
                businesses: q
            })
        }.bind(this), this.renderError = function() {
            return c("React").createElement(c("BusinessMessage.instagram"), {
                heading: h._("You do not have permission to access Business Tools."),
                subHeading: h._("Contact your work admin if you think this is a mistake."),
                withBox: true
            })

In plain words:

  • function k() is the constructor, the code that sets up this screen when it is created. The loop over arguments and the j.constructor line are standard plumbing for building one object on top of another; the report does not explain them further.
  • this.state = { businesses: null } gives the screen a place to keep its data. At the start it holds nothing, null.
  • this.dataChangeHandler = function() { ... } defines what to do when the data changes. It asks FBViewerStore.instagram, a store (a shared place where the program keeps data it has fetched), for two things: getAllBusinesses(), every business the viewer can see, and getViewerBusiness(), the one business currently selected.
  • if (q && q.length === 1 && !r) means: if there is a list of businesses, it contains exactly one, and none is selected yet. In that case the program picks that single business, q[0], reads any extra parameters from the address with getQueryParams(), and navigates to /business/ followed by the business's id.
  • Otherwise, this.setState({ businesses: q }) stores the list so the screen can show it and let the user choose.
  • this.renderError builds the error message shown when the user has no permission: "You do not have permission to access Business Tools." and "Contact your work admin if you think this is a mistake." This is the error shown when the user has no permission.

The list of routes

Going back to the BusinessToolsEntrypoint.instagram module, the researcher lists the addresses the tool can handle. A route is a pattern for an address; the parts starting with a colon are placeholders that stand for a value, like a blank in a form.

  • /login
  • /business/:id
  • /business/:id/manage/people
  • /business/:id/manage/accounts
  • /business/:id/manage/adaccounts/
  • /business/:id/insights/:username/:tab?
  • /business/:id/insights/:username/:tab?/p/:shortcode

So /business/:id means: an address that starts with /business/ and then has some value where :id is. The question mark in :tab? marks that part as optional.

Following the /business/:id route

The researcher then traced what happens when someone visits an address of that shape, step by step through three modules.

  1. BusinessToolsEntrypoint.instagram

    • Route the slug "/business/:id"
    • c("Router.instagram").get("/business/:id"...
    • c("Bootloader").loadModules(["BusinessHome.instagram"]...
    • m.send({ component: o, props: l.params })...
  2. BusinessHome.instagram

    • Handle data changes for the component and load the business data
    • m.prototype.componentDidMount
    • c("BusinessStore.instagram").addListener(c("BusinessStore.instagram").CHANGE_EVENT
    • this.dataChangeHandler()
    • this.dataChangeHandler = function()
    • c("BusinessStore.instagram").getBusiness(this.props.id)
  3. BusinessStore.instagram

    • Request the business data from Facebook Graph API
    • this._fetchBusiness(x)
    • u(t(x), "get").then(function(A)
    • s = "?fields=" + ["id", "name", r].join()
    • function t(w) { return w + s }
    • function u(w, x, y)
    • c("graph.instagram")(w, x, y, function(B, C)

In plain words, stage by stage:

  • The router sees an address matching /business/:id, loads the BusinessHome.instagram module, and hands it the values from the address as props, which is the word this program uses for the settings passed into a screen. The :id value travels inside l.params.
  • The home screen, once it appears on the page (componentDidMount is the moment a screen has been drawn for the first time), subscribes to the business store so it is told whenever the data changes, then asks the store for the business whose id it was given: getBusiness(this.props.id).
  • The store builds a request to the Facebook Graph API and sends it. Along the way it builds a suffix, s = "?fields=" + ["id", "name", r].join(), which lists the pieces of information it wants back, and a function t(w) { return w + s } that glues that suffix onto the address it was given. The function u(w, x, y) is the part that actually performs the request, and c("graph.instagram")(...) is the program asking for the module that talks to Facebook.

Exploitation

Step 1: the :id segment is passed straight into a Graph API request

An API, short for application programming interface, is a way for one piece of software to ask another for data or to tell it to do something, in a fixed format. Facebook's Graph API is the one that Instagram's tools use to read and change data on Facebook's servers. A request to it looks like an ordinary web address, and the answer comes back as structured data rather than a web page.

If a user went to https://business.instagram.com/business/113702895386410, the :id portion would be sent to the component from BusinessHome.instagram. A data change listener handles a data load request for the ID 113702895386410 and calls the GraphAPI:

HTTP
https://graph.facebook.com/v2.4/113702895386410?access_token=IG_TOKEN&callback=FB.__globalCallbacks.f1a20b453d927fc&fields=id%2Cname%2Cinstagram_users.limit(1000).filtering(%5B%7Bfield%3A%22role%22%2Coperator%3A%22IN%22%2Cvalue%3A%5B%22manager%22%2C%22analyst%22%5D%7D%5D).fields(id%2Cusername%2Clogging_start_date%2Crole%2Cprofile_pic%2Cmedia_count%2Cfollow_count%2Cfollowed_by_count%2Cinsights.metric(page_impressions%2Cpage_impressions_unique).since(1506126329).until(1509323129)%2Cinstagram_media.limit(8).fields(id%2Ccontent_type%2Cdisplay_url%2Cvideo_url))&method=get&pretty=0&sdk=joey

What this request contains:

  • graph.facebook.com/v2.4/113702895386410 is the address of the Graph API, version 2.4, followed by the object being asked about, here the number 113702895386410.
  • access_token=IG_TOKEN is the key that proves who is asking. A token is like a temporary pass: the browser holds it after you log in, and it is sent with each request so the server knows which account the request belongs to. It is not your password, but it works like one for as long as it lasts. The real value is replaced here with IG_TOKEN.
  • callback=FB.__globalCallbacks.f1a20b453d927fc asks the server to wrap its answer in a named function so the browser can handle it. This is an old technique for getting data across without the browser blocking it.
  • fields=... lists the pieces of information wanted: the id and name, then the business's users filtered to those with the manager or analyst role, then details about each of those users, then some statistics for a date range, then the last eight media items. The %2C, %5B, %7B and similar sequences are encoded characters: %2C is a comma, %5B is [, %7B is {. Addresses cannot contain certain characters directly, so they are written in this encoded form.
  • method=get&pretty=0&sdk=joey say this is a read request (get), that the answer should not be prettified, and which software library is making the call.

However 113702895386410 isn't an Instagram business account. So it seems the :id parameter has some flexibility with using the Graph API. Since the access_token used in Instagram Tools has access to GraphQL, there should be a way to perform calls.

GraphQL is a different way of asking an API for things. Instead of a fixed address for each kind of data, you send a query written in a small query language, and the server answers exactly that. A query that only reads is called a query; one that changes something is called a mutation. The researcher's reasoning was: if the token can be used for GraphQL, and the :id slot is pasted into the address without checks, then a GraphQL request could be smuggled through that slot.

Step 2: a GraphQL mutation that does not need POST

When a browser sends data to a server it can use different methods. GET is used for fetching and puts everything in the address; POST carries data in the body of the request, which is not part of the address. A link can only carry a GET request, so a mutation that requires POST cannot be triggered by simply clicking a link. The researcher constructed a GraphQL mutation and notes that it does not need to be sent via HTTP POST:

Text
graphql?q=Mutation SyncAddMutations : SyncAddMutationsResponse {story_create(<input>){client_mutation_id}}&query_params={'input':'{\'actor_id\':\'TARGET_ID\',\'client_mutation_id\':\'1\',\'audience\':{\'privacy\':{\'@_@\':\'@_@\',\'@_@\':\'@_@\'}},\'@_@\':\'@_@\',\'message\':{\'text\':\'MaliciousMessage\'}}}'

Reading it piece by piece:

  • graphql?q= is the address of the GraphQL endpoint, with the query carried in a parameter called q.
  • Mutation SyncAddMutations : SyncAddMutationsResponse {story_create(<input>){client_mutation_id}} is the query itself. It declares a mutation named SyncAddMutations that returns a SyncAddMutationsResponse, and inside it calls story_create, which creates a story, that is, a post. It asks for client_mutation_id back.
  • &query_params={'input':'...'} supplies the input for that call. The input is written as a JSON-like object: JSON is a common text format for structured data, built from names and values in curly braces. Here the input has an actor_id, which is the account the action is performed as, set to TARGET_ID; a client_mutation_id of 1; an audience object with a privacy setting; and a message with the text MaliciousMessage.
  • @_@ marks other fields dropped for brevity. In other words, the real query had more fields in those places, and the researcher replaced them with this placeholder so the example stays readable.

So the mutation is a story_create call whose input carries an actor_id (the victim), a client_mutation_id, an audience/privacy object and a message text.

Step 3: the final link sent to the victim

The final query to send to the victim places the GraphQL query into the :id segment of the business route, URL-encoded:

HTTP
https://business.instagram.com/business/graphql%3Fq%3DMutation%20SyncAddMutations%20%3A%20SyncAddMutationsResponse%20%7Bstory_create%28%3Cinput%3E%29%7Bclient_mutation_id%7D%7D%26query_params%3D%7B%27input%27%3A%27%7B%5C%27actor_id%5C%27%3A%5C%27TARGET_ID%5C%27%2C%5C%27client_mutation_id%5C%27%3A%5C%271%5C%27%2C%5C%27audience%5C%27%3A%7B%5C%27privacy%5C%27%3A%7B%5C%27@_@%5C%27%3A%5C%27@_@%5C%27%2C%5C%27@_@%5C%27%3A%5C%27@_@%5C%27%7D%7D%2C%5C%27@_@%5C%27%3A%5C%27@_@%5C%27%2C%5C%27message%5C%27%3A%7B%5C%27text%5C%27%3A%5C%27MaliciousMessage%5C%27%7D%7D%27%7D%26fixend

What is going on in this address:

  • It starts with https://business.instagram.com/business/, the normal business screen address, and then puts the whole GraphQL request where the business number should be.
  • Everything after that is the same GraphQL text from step 2, but encoded so it can sit inside an address. %3F is ?, %20 is a space, %3A is :, %7B is {, %7D is }, %28 is (, %29 is ), %3C is <, %3E is >, %26 is &, %27 is a single quote, %5C is a backslash, %2C is a comma. Encoding is needed because characters such as ? and & have special meanings in an address; writing them encoded lets them travel as ordinary text.
  • TARGET_ID is where the victim's account number goes, so the link is made for one specific person.
  • The address ends with %26fixend, which decodes to &fixend.

The fixend is appended to handle the original query formed in BusinessStore.instagram:

JavaScript
s = "?fields=" + ["id", "name", r].join()
function t(w) { return w + s }

In other words, the client appends its own ?fields=... suffix to whatever sits in the :id position, and the trailing fixend absorbs that suffix so the injected GraphQL query remains well formed.

To see why that works, picture the address the program builds. It takes whatever is in the :id slot and adds ?fields=id,name,... to the end. If the slot contains a GraphQL request that already has its own ? and & characters, the added suffix would land in the middle of it and break it.

Root cause

The :id route parameter is concatenated into a Graph API URL without being constrained to a numeric business ID, and the resulting request is issued with the Instagram Tools access token, which has access to GraphQL. Because the GraphQL query can be carried in the URL rather than an HTTP POST body, a crafted link to business.instagram.com is enough to make the victim's browser issue the mutation with their own credentials. The report does not describe any CSRF token or origin check that would have stopped it.

A CSRF token is a secret value that a page includes in each form or request, so the server can tell that the request really came from that page and not from somewhere else. An origin check is a rule on the server that refuses requests coming from other websites. Neither is described here. And because the victim is simply opening a link to business.instagram.com itself, the browser treats it as a normal visit to that site and sends the victim's login along with it, exactly as it would if the victim had typed the address.

Impact

This issue allowed an attacker to carry out arbitrary mutations (CSRF) as the victim. The link provided by the attacker is specific to a victim (actor_id) and the victim should authenticate the Instagram business app.

In everyday terms: the attacker does not need the victim's password. They need the victim to click a link while signed in to the Instagram business app, and the action happens under the victim's name.

Fix

Facebook fixed the issue on 10 October 2017, two days after the report was sent.

Variants to test

  • Other client-side routes that take an identifier and interpolate it into a Graph API URL (for example the /business/:id/manage/... and /business/:id/insights/... routes listed above). A positive result is a request to graph.facebook.com whose path or query contains attacker-controlled text rather than a plain ID.
  • GraphQL operations that can be expressed as a GET query string, as story_create was here. A positive result is a mutation that executes when delivered as a link, without a POST body.
  • Appending a terminator such as fixend to absorb a suffix the client adds to the injected value. A positive result is a well-formed upstream request despite the application's own appended parameters.
  • Replaying the crafted link against an account that is authenticated to the business app. A positive result is a state change attributed to the victim's actor_id.

Timeline

  • Oct 8, 2017: report sent
  • Oct 9, 2017: further investigation by Facebook
  • Oct 10, 2017: fixed by Facebook
  • Oct 19, 2017: $7500 bounty awarded by Facebook

Glossary

  • API: a fixed way for one piece of software to ask another for data or to tell it to do something.
  • Graph API: Facebook's API, reached at graph.facebook.com, through which Instagram's tools read and change data.
  • GraphQL: a query language for APIs, where the client writes the exact request it wants; a read is a query, a change is a mutation.
  • Mutation: a GraphQL request that changes something, such as creating a post.
  • Query string: the part of an address after the ?, made of name and value pairs joined by &.
  • URL encoding: writing characters that are special in an address, such as ? or &, as % codes so they travel as ordinary text.
  • GET and POST: two ways a browser sends a request; GET puts everything in the address, POST carries data in the body. A link can only produce a GET.
  • Access token: a temporary pass the browser holds after login and sends with requests, so the server knows which account is asking.
  • Session: the server's memory of who you are while you stay signed in; the browser sends it with each request to that site.
  • CSRF (cross-site request forgery): tricking a signed-in victim's browser into sending a request they did not intend, so the action happens under their name.
  • CSRF token: a secret value included in requests so the server can tell they came from its own page.
  • Origin check: a server rule that refuses requests coming from other websites.
  • Client-side application: a website where the browser downloads a program once and that program draws the screens itself.
  • Routing / route: the program's mapping from an address to a screen; a route is a pattern for an address.
  • Route parameter: a placeholder in a route, such as :id, that stands for a value supplied in the address.
  • Module: one named file of a program, a bundle of related code.
  • Bootloader: code whose job is to fetch and start other modules on demand.
  • Component: a self-contained piece of a screen that the program draws and updates.
  • Props: the settings passed into a component.
  • State: the data a component keeps for itself while it is on screen.
  • Store: a shared place where the program keeps data it has fetched, so several screens can use it.
  • Listener: code that waits for a change and then runs when it happens.
  • JSON: a common text format for structured data, built from names and values in curly braces.
  • Chrome Developer Tools: the built-in panel in the Chrome browser for reading a site's code and watching its requests.
  • Bounty: a payment a company makes to someone who reports a security problem to it.

More by Philippe Harewood

View all

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

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.