Skip to content
IDOR Write-up Intermediate

Accessing to Data Sources of any Facebook Business account via IDOR in GraphQL

An IDOR in Facebook's GraphQL API allowed an attacker to change the assetOwnerId parameter to access data sources of any business account. By then using the obtained data source ID in another query, the attacker could read the data.

Mukund Bhuva Follow

Published on medium.com

An attacker can use an IDOR (Insecure Direct Object Reference) vulnerability to enumerate the data sources of any user with the "assetOwnerId" and "userid", allowing unauthorized access to sensitive information.

Mukund Bhuva, 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 Business accounts expose a GraphQL endpoint at business.facebook.com/api/graphql/. The researcher had been learning GraphQL and reading write-ups when he came across an older write-up about a GraphQL bug on Facebook, and decided to explore that endpoint himself.

Two parameters turned out to matter when navigating this endpoint:

  • X-Fb-Friendly-Name (or fb_api_req_friendly_name in the body), which selects the operation, i.e. which node in the graph is executed.
  • variables, which carries the arguments injected into that operation.

The operations under test belong to the account quality area of Facebook Business. The report classifies the issue as an IDOR in the Pages product area.

Setup

The report does not describe any special tooling, roles or versions. The only precondition stated is that the requests are made against business.facebook.com with a valid session, since the captured requests carry session material and anti-CSRF values such as fb_dtsg, lsd and jazoest. The researcher's closing tip is to use your own testing account for testing purposes.

Finding it

While exploring the endpoint, the researcher found an operation called [redacted]. As the name suggests, it fetches data belonging to the account owner, but it also parses a variable, which is what made it interesting:

JSON
{"assetOwnerId": "ID"}

Because the identifier is supplied by the client, changing the ID in that parameter returned the data sources of the victim.

Photo by Roman Martyniuk on Unsplash From the original on medium.com

The image is the article's opening illustration, credited to Roman Martyniuk on Unsplash.

Exploitation

Step 1: enumerate another owner's data sources

The researcher sent the following request, changing the assetOwnerId value to point at the victim:

HTTP
POST /api/graphql/ HTTP/2Host: business.facebook.comContent-Type: application/x-www-form-urlencodedX-Fb-Friendly-Name: [redacted]-Fb-Lsd: G5Wbr7fIMeYiFNPeGC7N7AContent-Length: 1010Origin: https://business.facebook.comav=100009240779294&session_id=7427440000033a96&__user=100009240779294&__a=1&__dyn=[redacted]-[redacted]-[redacted]-q4VEhG7o2swQzUS2W2K4E6-bxu3ydCgqw-z8c8-[redacted]&__csr=&__req=1&__hs=19360.BP%3ADEFAULT.2.0.0.0.0&dpr=1&__ccg=EXCELLENT&__rev=1006774989&__s=pxy8ln%3Aw8c1cm%3Ac2n3s5&__hsi=7184000067673134486&__comet_req=0&fb_dtsg=NAcP-[redacted]-5ZSGb4NHdofBSCttg%3A7%3A1672671328&jazoest=25337&lsd=G5WbrxxxMeYiFNPeGC7N7A&__aaid=1433661493618529&__spin_r=1006774989&__spin_b=trunk&__spin_t=1672725067&__jssesw=1&fb_api_caller_class=RelayModern&fb_api_req_friendly_name=BusinessUnifiedScopingGlobalScopeSelectorSearchSourceQuery&variables={"assetOwnerId":"4"}&server_timestamps=true&doc_id=8009820932425164

The important parts are the X-Fb-Friendly-Name header, which names the operation, and the variables field, which carries {"assetOwnerId":"4"}. The rest of the body is the usual Relay Modern envelope: fb_api_caller_class=RelayModern, a doc_id identifying the persisted query, fb_dtsg, lsd, jazoest and the other session and anti-CSRF values. By changing the ID in the parameter, the researcher was able to access the data sources of the victim.

POC
POC From the original on medium.com

Step 2: read the data inside a data source

Not satisfied with enumerating data sources, the researcher dug deeper and enumerated nodes related to data sources. He found one called AccountQualityDataSourceViewWrapperQuery, which fetches data from a data source. He took the data source ID obtained in the previous step and pasted it into the asset_id variable:

JSON
{"asset_id": "DSID"}

The request he sent was:

Here the variables value is URL-encoded: %7B%22asset_id%22%3A%22435291730178743%22%7D decodes to {"asset_id":"435291730178743"}. With the victim's data source ID in that field, the researcher was able to read the data.

POC
POC From the original on medium.com

Root cause

The operations accept an object identifier from the client (assetOwnerId in the first query, asset_id in the second), and changing it returned another owner's data. The report describes the vulnerability as straightforward and easy to exploit and does not go into the server-side details.

Impact

An attacker can use the IDOR to enumerate the data sources of any user with the assetOwnerId and userid, allowing unauthorised access to sensitive information. In the second step, the same weakness lets the attacker read the data held inside a data source once its ID is known. The report does not quantify how many accounts or records were affected.

Fix

The report states that the vulnerability is fixed by now. It does not describe the change that was made.

Variants to test

  • Swap the X-Fb-Friendly-Name header for other operation names found in the application and change the object identifiers in variables. A positive result is a response containing another account's objects.
  • Take an ID obtained from one operation (for example a data source ID from an owner view query) and feed it into a different operation that accepts the same kind of ID. A positive result is data returned for an object you do not own.
  • Try identifiers belonging to accounts you control from a second account, so that any cross-account data in the response is unambiguous.
  • Test both the header form X-Fb-Friendly-Name and the body form fb_api_req_friendly_name, since the report notes both are used to select the operation.

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

What happened, in plain words

Facebook Business is a version of Facebook for companies rather than for individuals. A company can have a page, an advertising account, and a set of "data sources". The operations involved belong to the account quality area of Facebook Business.

When you use a website like this, your browser does not only download pages. It also sends small messages to the server behind the scenes, asking for data, and the server answers with data rather than with a page. Those messages are called API calls, and the system that answers them here is called GraphQL. GraphQL is a way of asking a server for exactly the pieces of information you want, by naming an operation and passing it some values.

The researcher found that two of those operations accepted an identifier straight from the browser, and changing it returned another company's data sources. By changing the number, he could look at another company's data sources, and then read the contents of one of them. This kind of mistake is called an IDOR, short for Insecure Direct Object Reference: the server uses a reference (the ID) supplied by the client directly, without an authorisation check.

A useful comparison: imagine a hotel where the receptionist hands you a key when you say a room number, and never checks that the room is yours. Saying "room 12" gets you into room 12. The lock works, the key is real, but nobody asked whether you are the guest of that room. That missing question is the whole bug.

Background you need

What an API and an endpoint are

An API (Application Programming Interface) is the set of doors a website offers to programs. Each door has an address, called an endpoint. Here the endpoint is business.facebook.com/api/graphql/: a single address that accepts many different requests, each one saying which operation it wants.

What GraphQL is

In a classic API you have many addresses, one per thing (/users, /orders, and so on). In GraphQL there is usually one address, and the request says which operation to run and what values to give it. The server has a catalogue of operations, each with a name, and the client picks one by name. Think of a restaurant with one phone number: you call the same number every time, but you say which dish you want and with which options.

What a cookie, a session and a token are

When you log in to a website, the server gives your browser a small piece of text, stored in a cookie, that proves who you are on later requests. The server keeps a record called a session, and the cookie carries the session identifier. Some sites also put a token in the page, a random string that the page must send back with each request, to prove the request really came from the site and not from a malicious page. On Facebook these values have names like fb_dtsg, lsd and jazoest. They answer the question "who are you and did this request come from our page?" They do not answer the question "are you allowed to see this particular object?" That second question is called authorisation, and it is exactly the one that was missing.

What an IDOR is

An IDOR happens when the server takes an identifier from the request and uses it to fetch an object, but only checks that you are logged in, not that the object belongs to you. If IDs are guessable, an attacker can try other values and reach other people's data.

The two parameters that matter

While exploring the endpoint, the researcher learned that two fields control what happens:

  • X-Fb-Friendly-Name (or fb_api_req_friendly_name when it appears in the body), which selects the operation, that is, which node in the graph is executed.
  • variables, which carries the arguments injected into that operation.

In plain terms: the first tells the server which dish to cook, the second tells it with which ingredients. If either is under the client's control, and the server trusts it, there is room for a bug.

Finding it

While exploring the endpoint, the researcher found an operation called [redacted]. As the name suggests, it fetches data belonging to the account owner, but it also parses a variable, which is what made it interesting:

JSON
{"assetOwnerId": "ID"}

Line by line: this is a small JSON object, a way of writing named values as text. It has one field, assetOwnerId, whose value is the placeholder ID. In a real request, ID is replaced by a number identifying a business asset owner. The researcher's point is that this number comes from the browser. If the server simply looks up whatever number arrives, then anyone can put any number there.

Photo by Roman Martyniuk on Unsplash From the original on medium.com

The image is the article's opening illustration, credited to Roman Martyniuk on Unsplash.

Exploitation

Step 1: enumerate another owner's data sources

The researcher sent the following request, changing the assetOwnerId value to point at the victim:

HTTP
POST /api/graphql/ HTTP/2Host: business.facebook.comContent-Type: application/x-www-form-urlencodedX-Fb-Friendly-Name: [redacted]-Fb-Lsd: G5Wbr7fIMeYiFNPeGC7N7AContent-Length: 1010Origin: https://business.facebook.comav=100009240779294&session_id=7427440000033a96&__user=100009240779294&__a=1&__dyn=[redacted]-[redacted]-[redacted]-q4VEhG7o2swQzUS2W2K4E6-bxu3ydCgqw-z8c8-[redacted]&__csr=&__req=1&__hs=19360.BP%3ADEFAULT.2.0.0.0.0&dpr=1&__ccg=EXCELLENT&__rev=1006774989&__s=pxy8ln%3Aw8c1cm%3Ac2n3s5&__hsi=7184000067673134486&__comet_req=0&fb_dtsg=NAcP-[redacted]-5ZSGb4NHdofBSCttg%3A7%3A1672671328&jazoest=25337&lsd=G5WbrxxxMeYiFNPeGC7N7A&__aaid=1433661493618529&__spin_r=1006774989&__spin_b=trunk&__spin_t=1672725067&__jssesw=1&fb_api_caller_class=RelayModern&fb_api_req_friendly_name=BusinessUnifiedScopingGlobalScopeSelectorSearchSourceQuery&variables={"assetOwnerId":"4"}&server_timestamps=true&doc_id=8009820932425164

This block is one HTTP request, the message a browser sends to a server. It is written here with its lines run together, so let us walk through it in order.

  • POST /api/graphql/ HTTP/2 is the request line: the method (POST, meaning "I am sending data"), the path (/api/graphql/, the GraphQL endpoint), and the protocol version (HTTP/2).
  • Host: business.facebook.com names the server the request is addressed to.
  • Content-Type: application/x-www-form-urlencoded says the body is formatted like a web form, as name=value pairs joined by &.
  • X-Fb-Friendly-Name: [redacted] is the header that selects the operation. This is the operation that fetches an owner's data sources.
  • X-Fb-Lsd: G5Wbr7fIMeYiFNPeGC7N7A is one of Facebook's anti-CSRF values, a token the page must echo back.
  • Content-Length: 1010 says how many bytes the body has.
  • Origin: https://business.facebook.com says which site the request came from.
  • Everything after that, starting av=100009240779294&..., is the body. It is a long list of name=value pairs. Most of them (__dyn, __csr, __hs, __rev, __s, __hsi, __comet_req, __aaid, __spin_r, __spin_b, __spin_t, __jssesw) are bookkeeping values the Facebook web app attaches to its own requests; they are not interesting for the bug.
  • fb_dtsg=..., jazoest=25337 and lsd=... are the session and anti-CSRF values mentioned earlier. They prove the request comes from a logged-in browser that loaded the page.
  • fb_api_caller_class=RelayModern says which client library sent the request. Relay is Facebook's JavaScript library for talking to GraphQL.
  • fb_api_req_friendly_name=BusinessUnifiedScopingGlobalScopeSelectorSearchSourceQuery is the same operation selector as the header, in body form.
  • variables={"assetOwnerId":"4"} is the important part: the arguments for the operation, with the owner ID set to 4.
  • server_timestamps=true asks the server to include timestamps in the answer.
  • doc_id=8009820932425164 identifies a stored, pre-registered copy of the query on the server (a persisted query), so the client does not have to send the whole query text.

The important parts are the X-Fb-Friendly-Name header, which names the operation, and the variables field, which carries {"assetOwnerId":"4"}. The rest of the body is the usual Relay Modern envelope: fb_api_caller_class=RelayModern, a doc_id identifying the persisted query, fb_dtsg, lsd, jazoest and the other session and anti-CSRF values. By changing the ID in the parameter, the researcher was able to access the data sources of the victim.

Why this step was taken: the researcher had seen that the operation reads an owner ID from the request. The cheapest test of whether the server checks ownership is to put in a different owner's ID and see whether the answer changes. If the answer contains the other owner's data sources, the check is missing.

POC
POC From the original on medium.com

Step 2: read the data inside a data source

Not satisfied with enumerating data sources, the researcher dug deeper and enumerated nodes related to data sources. He found one called AccountQualityDataSourceViewWrapperQuery, which fetches data from a data source. He took the data source ID obtained in the previous step and pasted it into the asset_id variable:

JSON
{"asset_id": "DSID"}

Line by line: again a small JSON object, this time with a field called asset_id and the placeholder DSID, meaning "data source ID". The first step gave the researcher real data source IDs belonging to the victim; this step asks the server to open one of them.

The request he sent was:

Line by line, the structure is the same as the first request, with different values:

  • POST /api/graphql/ HTTP/2 and Host: business.facebook.com: same endpoint, same server.
  • Content-Type: application/x-www-form-urlencoded: same form-style body.
  • X-Fb-Friendly-Name: AccountQualityDataSourceViewWrapperQuery: this time the operation is the one that reads a data source.
  • X-Fb-Lsd: kwwJJHnYaUEsxYK97K99ZC: the anti-CSRF token for this session.
  • Content-Length: 1023: the size of the body.
  • Origin: https://business.facebook.com: where the request came from.
  • The body again carries the bookkeeping values, the session values (fb_dtsg, jazoest, lsd), fb_api_caller_class=RelayModern, and fb_api_req_friendly_name=AccountQualityDataSourceViewWrapperQuery, matching the header.
  • variables=%7B%22asset_id%22%3A%22435291730178743%22%7D is the key part. It looks unreadable because it is URL-encoded: certain characters are written as % followed by two hex digits so they can travel safely inside a form body. %7B is {, %22 is ", %3A is :, %7D is }. Decoded, it reads {"asset_id":"435291730178743"}.
  • server_timestamps=true and doc_id=6218000018150890: same roles as before, for this operation.

Here the variables value is URL-encoded: %7B%22asset_id%22%3A%22435291730178743%22%7D decodes to {"asset_id":"435291730178743"}. With the victim's data source ID in that field, the researcher was able to read the data.

Why this step was taken: listing data sources only shows that they exist. The stronger proof is reading their contents. The researcher had a real ID from step 1, so he fed it into the operation that opens a data source. If the server returns the contents, the same missing check applies one level deeper.

POC
POC From the original on medium.com

Root cause

The operations accept an object identifier from the client (assetOwnerId in the first query, asset_id in the second), and changing it returned another owner's data. The report describes the vulnerability as straightforward and easy to exploit and does not go into the server-side details.

In hotel terms again: the key is genuine and the door opens, but nobody at reception ever compares the room number on the key with the name on the booking.

Impact

An attacker can use the IDOR to enumerate the data sources of any user with the assetOwnerId and userid, allowing unauthorised access to sensitive information. In the second step, the same weakness lets the attacker read the data held inside a data source once its ID is known. The report does not quantify how many accounts or records were affected.

Fix

The report states that the vulnerability is fixed by now. It does not describe the change that was made.

Variants to test

  • Swap the X-Fb-Friendly-Name header for other operation names found in the application and change the object identifiers in variables. A positive result is a response containing another account's objects.
  • Take an ID obtained from one operation (for example a data source ID from an owner view query) and feed it into a different operation that accepts the same kind of ID. A positive result is data returned for an object you do not own.
  • Try identifiers belonging to accounts you control from a second account, so that any cross-account data in the response is unambiguous.
  • Test both the header form X-Fb-Friendly-Name and the body form fb_api_req_friendly_name, since the report notes both are used to select the operation.

Glossary

  • API: the set of addresses and rules a website offers so that programs, not just people, can ask it for data or actions.
  • Endpoint: one specific address on a server that accepts a particular kind of request, such as /api/graphql/.
  • GraphQL: a way of querying a server where the client names an operation and passes values, and the server returns exactly the requested data.
  • Operation: a named query or action in GraphQL, selected by name in the request.
  • Node: an item in the GraphQL graph, such as an account owner or a data source.
  • Variables: the named values passed to a GraphQL operation, written as JSON.
  • JSON: a text format for named values, written with curly braces, quotes and colons.
  • HTTP request: the message a browser sends to a server, made of a method, a path, headers and an optional body.
  • Header: a name: value line in an HTTP request or response carrying metadata, such as the content type or a token.
  • Body: the part of an HTTP request that carries the actual data, after the headers.
  • application/x-www-form-urlencoded: a body format where values are written as name=value pairs joined by &.
  • URL encoding: writing special characters as % plus two hex digits so they can travel safely inside a URL or form body.
  • Cookie: a small piece of text a site stores in your browser and that your browser sends back on later requests.
  • Session: the server-side record of who you are, identified by a value in a cookie.
  • Token: a random string used to prove identity or that a request came from the site itself.
  • CSRF: Cross-Site Request Forgery, an attack where a malicious page makes your browser send a request to another site; anti-CSRF tokens such as fb_dtsg, lsd and jazoest are meant to stop it.
  • Authentication: proving who you are, for example by logging in.
  • Authorisation: deciding whether the person who is asking is allowed to see or do a particular thing.
  • IDOR: Insecure Direct Object Reference, a bug where the server uses an identifier supplied by the client to fetch an object without checking that the client is allowed to access it.
  • ID: a number or string that names a particular object, such as an account owner or a data source.
  • Enumeration: going through a list of possible identifiers or names to discover which ones exist and what they return.
  • Data source: in Facebook Business, a place where a company keeps information it wants to use inside Facebook, such as a customer list.
  • Relay Modern: Facebook's JavaScript library for sending GraphQL requests from the browser; fb_api_caller_class=RelayModern says it was used.
  • Persisted query / doc_id: a query stored on the server under an identifier, so the client sends only the identifier instead of the full query text.
  • X-Fb-Friendly-Name / fb_api_req_friendly_name: the field that selects which GraphQL operation the server runs.
  • Proof of concept (POC): a demonstration that a bug can actually be triggered, usually a screenshot or recording of the request and its result.
  • Victim: the account whose data is accessed without permission in a test.
  • Root cause: the underlying mistake in the code that makes the bug possible.
  • Fix: the change made to the software so the bug no longer works.

More by Mukund Bhuva

View all

1 more disclosed report, 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.

Insecure direct object reference (IDOR)

The lesson behind this report.

One user can read or change another user's data, usually by changing an identifier the server trusts without checking who is asking. One of the most paid bug classes on web programs.