Skip to content
IDOR Write-up Intermediate

Repro steps

An Instagram GraphQL endpoint allowed an attacker to retrieve details of private or archived media (posts, stories, reels, IGTV) by supplying a media ID, without following the user. The attacker could obtain CDN URLs and engagement counts, and by brute-forcing media IDs could identify and store private media details.

Mayur Fartade Follow

Published on fartademayur.medium.com

Bounty$30,000 View original

I am Mayur Fartade from Maharashtra. This is my first bug in the Facebook Bug bounty program.

Mayur Fartade, on fartademayur.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

Instagram's media objects (posts, reels, IGTV videos and stories) are identified by a numeric media ID. The GraphQL endpoint used by Instagram's ads tooling at https://i.instagram.com/api/v1/ads/graphql/ accepts a persisted query identified by a doc_id and a set of query_params, and returns metadata about a media object. The researcher found that this endpoint would return details for media belonging to accounts the caller does not follow, including private and archived content, as long as the media ID was known.

The disclosed details include like, comment and save counts, display_url, image.uri, the Facebook page linked to the Instagram account (where one exists) and other fields. The researcher notes that the Facebook page to Instagram account link is itself public, and points to the Ads Library page that exposes it:

Text
https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=US&view_all_page_id=PAGE_ID&search_type=page

Here PAGE_ID is the Facebook page ID.

Setup

The report does not describe any special accounts, roles or tooling. The only precondition is knowledge of a target's media ID, which the researcher says can be obtained by brute-forcing or by other techniques. Requests are plain POST requests to the ads GraphQL endpoint, and the researcher redacts the doc_id values in the write-up.

Finding it

Supplying a media ID in query_params returned metadata for that media, including private and archived content. Because media IDs can be brute-forced, private and archived media could be enumerated. The object is fetched by ID, and the report does not describe the server-side check.

Exploitation

Step 1: query the first doc_id with a media ID

Send a POST request to the ads GraphQL endpoint with the following parameters:

HTTP
doc_id=[REDACTED]&query_params={"query_params":{"access_token":"","id":"[MEDIA_ID]"}}

[MEDIA_ID] is the media ID of any post, reel, IGTV video or story, and doc_id is redacted in the report. The access_token inside query_params is sent empty. The response discloses display_url, save_count and other details of the media.

From the original on fartademayur.medium.com

The screenshot accompanies the first request in the report.

Step 2: a second doc_id with the same behaviour

A few days later the researcher found another doc_id on the same endpoint that disclosed the same information. This time the request also carried an access_token at the top level:

HTTP
access_token=[REDACTED]&variables={"query_params":{"access_token":"","id":"[MEDIA_ID]"},"fetch_actor_id":false}&server_timestamps=true&doc_id=[REDACTED]

[MEDIA_ID] is the media ID of any post, reel, IGTV video or story, doc_id is redacted, and the other parameters are not included in the report. The access_token is a valid Facebook access token. When the researcher tried to access media belonging to different accounts, the response came back as data:null.

From the original on fartademayur.medium.com

The screenshot accompanies the second request in the report.

Step 3: set access_token to null

Changing the access_token to null gave access to the information again:

HTTP
access_token=null&variables={"query_params":{"access_token":"","id":"[MEDIA_ID]"},"fetch_actor_id":false}&server_timestamps=true&doc_id=[REDACTED]

The same endpoint also disclosed the Facebook page linked to an Instagram account, though as noted above that link is public.

From the original on fartademayur.medium.com

The screenshot accompanies the request with access_token=null.

Root cause

The access_token in query_params is sent empty, and the top-level access_token can be set to null. The report notes only that a valid token returned data:null for other accounts, and that setting it to null returned the data.

Impact

An attacker who knows or guesses a media ID could read details of private and archived posts, stories, reels and IGTV videos without following the user. The disclosed fields include like, comment and save counts, display_url, image.uri, the linked Facebook page and other metadata. The researcher notes that an attacker could regenerate a valid CDN URL for archived stories and posts, and could brute-force media IDs to store details about specific media and later filter which are private and archived.

Fix

Instagram changed the affected endpoints.

Timeline

Date Event
16 April 2021 Report sent
19 April 2021 Reply from Facebook Security Team: need more info
19 April 2021 Information sent
22 April 2021 Report triaged
23 April 2021 Found another endpoint disclosing the same info
29 April 2021 Fixed
29 April 2021 Vulnerability not completely patched; information sent to the Facebook Security Team
15 June 2021 Awarded $30,000 bounty
From the original on fartademayur.medium.com

The screenshot accompanies the timeline in the report.

Variants to test

  1. Persisted GraphQL queries on other products: take a doc_id that resolves an object by ID and substitute IDs belonging to accounts you do not control. A positive result is metadata for an object you should not be able to see.
  2. Empty or null tokens: send the query with access_token set to an empty string or null, as in the requests above. A positive result is the same data being returned without a valid token.
  3. Token scoping: compare results with a valid token against results with null. If a valid token returns data:null for other accounts but null returns data, the authorisation check is tied to the token rather than the object.
  4. ID enumeration: increment or brute-force media IDs and record which return data. A positive result is a set of IDs for private or archived media that can be filtered from the responses.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

Instagram lets people share photos, videos, reels, IGTV videos and stories. Each of those items is stored on Instagram's computers and given a unique number, called a media ID. Think of it like a library shelf number: if you know the number, you can ask the librarian for that exact item.

Normally, Instagram should only hand over the details of an item if you are allowed to see it. If an account is private, or a story has been archived (moved out of public view), you should not be able to read anything about it unless the owner lets you follow them.

Mayur Fartade found that a particular Instagram web address, used by Instagram's advertising tools, would hand back details about private and archived media items as long as you gave it the media ID. It did not check whether you were allowed to see that item. So a stranger could learn about private and archived posts, stories, reels and IGTV videos without following the account.

This kind of mistake has a name: IDOR, which stands for Insecure Direct Object Reference. It means a program looks up an object (here, a media item) using an identifier supplied by the user (here, the media ID) and forgets to check that this user is permitted to see that object. A simple comparison: a hotel clerk who hands out a room key to anyone who says a room number, without checking that the person actually booked that room.

The address involved is an API endpoint. An API is the part of a website that programs talk to, rather than the part a person clicks on in a browser. When you scroll Instagram, the app is quietly sending requests to API endpoints and drawing the answers on your screen. The endpoint here is:

Text
https://i.instagram.com/api/v1/ads/graphql/

GraphQL is a way for a program to ask a server for exactly the pieces of data it wants. Instead of many separate addresses for many separate questions, there is one address, and the request describes what to fetch. Instagram's ads tooling uses GraphQL, and it uses persisted queries: the full question is stored on Instagram's servers in advance and given a short identifier called a doc_id. The client sends the doc_id, and the server looks up the stored question and runs it. It is a bit like a restaurant menu with numbered dishes: you say "number 7" and the kitchen knows what to cook.

A token (here an access token) is a short string that acts like a temporary pass. When you log in, the server gives your app a token, and the app shows it on later requests to prove who you are. A cookie is a similar idea: a small piece of data your browser stores and sends back to a site so the site can remember you between page loads. Tokens and cookies are secrets: anyone who copies one can often act as you, which is why they are redacted in public write-ups.

Finally, a CDN (Content Delivery Network) is a network of servers that serve files such as images and videos quickly. A CDN URL is the web address of a file on that network. If you can obtain a valid CDN URL for a private image, you can load that image even though you were never meant to see it.

This was Mayur's first bug in the Facebook bug bounty programme. A bug bounty programme is a scheme where a company pays researchers who report security mistakes responsibly, instead of suing them or ignoring them.

The details that leaked

The report says the endpoint returned details of private and archived posts, stories, reels and IGTV videos without the caller following the user, as long as the media ID was known. The details included:

  • like, comment and save counts
  • display_url (the web address of the image or video file)
  • image.uri (another identifier for the image)
  • the Facebook page linked to the Instagram account, if there is one
  • other fields

The researcher also notes that the link between a Facebook page and an Instagram account is itself public, and points to the Facebook Ads Library page that shows it:

Text
https://www.facebook.com/ads/library/?active_status=all&ad_type=all&country=US&view_all_page_id=PAGE_ID&search_type=page

Here PAGE_ID is the Facebook page ID. In plain words: this address is a public page where anyone can look up advertising information for a page, and it reveals which Instagram account is connected to that Facebook page. So that particular piece of information was not secret to begin with.

Why this matters (impact)

Data about users could be read when it should not be. The researcher says an attacker could regenerate a valid CDN URL for archived stories and posts, meaning they could get a working link to the actual image or video file. Also, because media IDs are numbers, an attacker could brute-force them: try many numbers in sequence, automatically, and record which ones return data. Brute-forcing simply means guessing many possibilities quickly with a computer instead of by hand. The attacker could then store the details about specific media and later filter out which items are private and archived.

The report does not say how many accounts or media items were affected.

Before you start

The report does not describe any special accounts, roles or tools. The only thing you need is the media ID of the target item, which the researcher says can be obtained by brute-forcing or by other techniques. The requests are ordinary POST requests. A POST request is one of the ways a browser or app can send data to a server: instead of just asking for a page (a GET request), it sends a bundle of data along with the request. You can think of GET as asking to read a noticeboard and POST as handing a filled-in form to a clerk.

Finding it

When a media ID was supplied in a parameter called query_params, the server returned metadata for that media, including private and archived content. Because media IDs can be brute-forced, private and archived media could be enumerated. Enumerating means walking through a list of identifiers one by one to see what comes back.

Exploitation

Step 1: query the first doc_id with a media ID

The goal of this step is simply to ask the ads GraphQL endpoint for the details of one media item, using its media ID, and see whether the server hands them over without any permission check. Send a POST request to the ads GraphQL endpoint with the following parameters:

HTTP
doc_id=[REDACTED]&query_params={"query_params":{"access_token":"","id":"[MEDIA_ID]"}}

Line by line:

  • doc_id=[REDACTED] tells the server which stored question to run. The actual value is redacted in the report, so we cannot see it.
  • query_params= is the bundle of values that the stored question needs in order to run.
  • Inside it, {"query_params":{"access_token":"","id":"[MEDIA_ID]"}} is a nested structure in JSON. JSON is a common text format for data, using curly braces for groups and quotes around names and values. Here the inner group has two fields: access_token, which is sent as an empty string (two quote marks with nothing between them), and id, which is set to the media ID.
  • [MEDIA_ID] is the media ID of any post, reel, IGTV video or story. The square brackets are a placeholder, not part of the value.

The access_token inside query_params is sent empty, meaning no pass is presented at all. The response discloses display_url, save_count and other details of the media.

From the original on fartademayur.medium.com

The screenshot accompanies the first request in the report.

Step 2: a second doc_id with the same behaviour

A few days later the researcher found another doc_id on the same endpoint that disclosed the same information. This time the request also carried an access_token at the top level, outside the nested query_params:

HTTP
access_token=[REDACTED]&variables={"query_params":{"access_token":"","id":"[MEDIA_ID]"},"fetch_actor_id":false}&server_timestamps=true&doc_id=[REDACTED]

Line by line:

  • access_token=[REDACTED] is a valid Facebook access token, sent as a top-level parameter. The value is redacted in the report.
  • variables= holds the values for the stored question, again in JSON. Inside it, query_params contains an empty access_token and the id set to the media ID, exactly as in step 1.
  • fetch_actor_id=false is another field in the same JSON group, set to false.
  • server_timestamps=true is a separate parameter set to true.
  • doc_id=[REDACTED] selects the stored question; the value is redacted.

[MEDIA_ID] is the media ID of any post, reel, IGTV video or story, doc_id is redacted, and the other parameters are not included in the report. The access_token is a valid Facebook access token. When the researcher tried to access media belonging to different accounts, the response came back as data:null. In plain words: with a real pass attached, the server refused to return the data for other people's media and answered with an empty result.

From the original on fartademayur.medium.com

The screenshot accompanies the second request in the report.

Step 3: set access_token to null

Changing the access_token to null gave access to the information again:

HTTP
access_token=null&variables={"query_params":{"access_token":"","id":"[MEDIA_ID]"},"fetch_actor_id":false}&server_timestamps=true&doc_id=[REDACTED]

Line by line:

  • access_token=null is the same top-level parameter as before, but now its value is the word null, meaning "nothing" or "no value".
  • variables= and everything inside it are unchanged from step 2: an empty access_token inside query_params, the media ID as id, and fetch_actor_id set to false.
  • server_timestamps=true and doc_id=[REDACTED] are unchanged as well.

The same endpoint also disclosed the Facebook page linked to an Instagram account, though as noted above that link is public.

From the original on fartademayur.medium.com

The screenshot accompanies the request with access_token=null.

Why it worked

The access_token inside query_params is sent empty, and the top-level access_token can be set to null. The report notes only that a valid token returned data:null for other accounts, and that setting it to null returned the data.

Fix

Instagram changed the affected endpoints.

Timeline

Date Event
16 April 2021 Report sent
19 April 2021 Reply from Facebook Security Team: need more info
19 April 2021 Information sent
22 April 2021 Report triaged
23 April 2021 Found another endpoint disclosing the same info
29 April 2021 Fixed
29 April 2021 Vulnerability not completely patched; information sent to the Facebook Security Team
15 June 2021 Awarded $30,000 bounty
From the original on fartademayur.medium.com

The screenshot accompanies the timeline in the report.

Variants to test

If you want to look for similar mistakes yourself, here are the same ideas in beginner terms:

  1. Persisted GraphQL queries on other products. Take a doc_id that looks up an object by ID and substitute IDs belonging to accounts you do not control. A positive result is metadata for an object you should not be able to see.
  2. Empty or null tokens. Send the query with access_token set to an empty string or null, as in the requests above. A positive result is the same data being returned without a valid token.
  3. Token scoping. Compare results with a valid token against results with null. If a valid token returns data:null for other accounts but null returns data, the authorisation check is tied to the token rather than to the object.
  4. ID enumeration. Increment or brute-force media IDs and record which return data. A positive result is a set of IDs for private or archived media that you can filter out of the responses.

Glossary

  • API: the part of a website or app that programs talk to, rather than the part a person clicks on in a browser.
  • API endpoint: a specific web address on an API that accepts requests.
  • Access token: a short string that acts like a temporary pass, proving to a server who you are.
  • Authorisation: the check that a particular user is allowed to do or see a particular thing.
  • Brute-force: trying many possibilities quickly with a computer, such as guessing sequential numbers, instead of by hand.
  • Bug bounty programme: a scheme where a company pays researchers who report security mistakes responsibly.
  • CDN: Content Delivery Network, a network of servers that serve files such as images and videos quickly.
  • CDN URL: the web address of a file on a CDN.
  • Cookie: a small piece of data your browser stores and sends back to a site so the site can remember you between page loads.
  • doc_id: the identifier of a persisted GraphQL query stored on the server.
  • Enumeration: walking through a list of identifiers one by one to see what comes back.
  • GraphQL: a way for a program to ask a server for exactly the pieces of data it wants, using one address and a description of the data.
  • IDOR: Insecure Direct Object Reference, a mistake where a program looks up an object using an identifier supplied by the user and does not check that this user is allowed to see that object.
  • JSON: a common text format for data, using curly braces for groups and quotes around names and values.
  • Media ID: the unique number Instagram gives to each post, reel, IGTV video or story.
  • Metadata: data about an item, such as counts and file addresses, rather than the item itself.
  • null: a value meaning "nothing" or "no value".
  • Persisted query: a GraphQL query stored on the server in advance and requested by a short identifier such as a doc_id.
  • POST request: a way for a browser or app to send data to a server along with a request.
  • query_params: the bundle of values a stored query needs in order to run.
  • Redacted: removed or replaced in a public write-up so that secrets are not revealed.
  • Token: see access token.
  • Triaged: reviewed by the security team and confirmed as a real issue worth investigating.
  • Vulnerability: a weakness in software that can be used to do something the owner did not intend.

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.