Skip to content
IDOR Write-up Beginner

How Four Lines of Code Could Delete Any Facebook Photo Album

A Facebook Graph API endpoint for deleting photo albums checked that the access token belonged to a valid user with delete permission, but did not verify that the album ID in the request belonged to that user. An attacker with a Facebook-for-Android access token could delete any album they could already view, simply by swapping the album ID.

L4ZZ3RJ0D Follow

Published on medium.com

Bug Bounty

L4ZZ3RJ0D, 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. 6 min read.

Context

Facebook's Graph API is the standard interface any application, official or third-party, uses to read and write platform data: photos, posts, pages and the rest. The feature at the centre of this report is photo album deletion. Facebook's own documentation stated explicitly that the Graph API did not support deleting photo albums at all, officially, through any standard access token. At the same time, the Facebook mobile client visibly ships a "delete album" button in its own UI, so the capability clearly existed somewhere behind the API.

Laxman Muthiyah found the issue in 2015 and was paid $12,500. Facebook patched it within two hours of the report landing. His original write-up, How I Hacked Your Facebook Photos, is still online and is worth reading in his own words; what follows is a walk through the reasoning.

Setup

The starting point was not a scanner or a tool but a question: what actually happens if I try to delete something that isn't mine? He began with a normal Graph Explorer access token. The second ingredient was an access token of the kind issued to Facebook's own official Android app, a Facebook-for-Android token.

The victim album ID was found simply by looking at the numeric ID sitting in that album's own URL.

Finding it

Muthiyah tested the documentation's claim directly rather than taking it at face value. He fired a DELETE request at his own album's ID using a normal Graph Explorer access token. It failed, exactly as documented.

The interesting part is what he did with that failure. He read the wording of the error message closely instead of logging "confirmed, blocked" and moving on, and the phrasing implied the restriction was tied to which app was asking, not a hard rule the server enforced for every possible caller. Some application, somewhere, had to be allowed to do this, because the Facebook mobile app itself has a "delete album" button sitting right there in its UI. If the feature exists in an official client, the permission exists somewhere in the API too; the only open question is which token carries it.

That instinct generalises beyond this bug. An API returning "not permitted" tells you about the token you tried, not necessarily about the endpoint itself. If a feature visibly exists in any client application, official or not, there is a token type somewhere that unlocks it, and finding which one is often more productive than continuing to poke at the same access level that already failed.

From the original on medium.com

Exploitation

Step 1: confirm the mobile token carries a broader delete permission

He obtained a Facebook-for-Android access token, the kind issued to Facebook's own official mobile app, and sent the same request against his own album, down to the same four lines:

HTTP
DELETE /518171421550249 HTTP/1.1Host: graph.facebook.comContent-Length: 245access_token=<Facebook_for_Android_Access_Token>
Text
Response: true

The path is his own album ID, the host is the Graph API, and the access_token parameter carries the Android token. The response true confirmed that the mobile token carried a broader delete permission than the standard one, exactly as the earlier error message had hinted.

On its own this is already a real finding: a permission boundary that should not exist between officially sanctioned clients and the standard API surface. But it is not yet a vulnerability. An app having elevated access to its own data is expected behaviour; Facebook's own mobile client is supposed to be able to manage a user's own albums.

From the original on medium.com

Step 2: swap the album ID for someone else's

The escalation, the moment this stopped being "my app can manage my own stuff" and became a real vulnerability, was the next test. He took a different album's ID entirely, one belonging to someone else, found simply by looking at the numeric ID in that album's URL, and sent the identical request again with the same Android token, only the ID in the path swapped out. Nothing else about the request changed at all.

HTTP
DELETE /<victim_album_id> HTTP/1.1Host: graph.facebook.comContent-Length: 245access_token=<Facebook_for_Android_Access_Token>
Text
Response: true

Deleted. An album with zero connection to his own account was gone, using a token that was only ever supposed to manage his own.

From the original on medium.com

Root cause

The server correctly verified that the access token belonged to a real, authenticated user who held delete permission on albums in general, but never took the second, equally necessary step of checking whether the specific album ID in the request actually belonged to that token's owner. Authentication was working fine. Authorization, checking not just who you are but whether you are allowed to touch this particular object, was the piece missing entirely.

That gap between "is this a valid request from a real user" and "does this real user actually own the specific thing they are asking to modify" is the definition of an IDOR, and this is about as pure an example of it as exists in bug bounty history.

Impact

The real impact was serious but not unlimited, despite what some headlines implied afterwards. Deleting a specific album still required knowing its numeric ID, and critically, still required that Muthiyah himself had permission to view that album under its own privacy settings: public albums, or ones shared with him specifically. He could not delete a stranger's fully private album he had never been granted view access to. The bug skipped the delete-ownership check but did not touch the separate, still-functioning view-permission check underneath it.

That distinction matters for scoping severity: the blast radius is everything an attacker can already see, not literally everything that exists on the platform. Getting that boundary right is the kind of precision that makes a finding credible instead of overstated.

Fix

Facebook patched the issue within two hours of the report landing. The report does not describe the change itself. The fix the behaviour calls for is an ownership check on the object being deleted: before acting on an album ID, verify that the album belongs to the owner of the token, not merely that the token is valid and carries delete permission in general.

Variants to test

The lesson sits in the gap between authentication and object-level authorization, and it applies to every object-based endpoint, not just delete actions. Any time an API lets you act on something by ID, whether deleting, editing, viewing or transferring it, the test that matters is swapping that ID for an object you do not own while keeping your own valid token attached, and watching whether the server stops you or quietly complies.

  1. Delete by ID on other object types. Send a DELETE against a post, photo, comment or page ID you do not own, using your own valid token. A positive result is a success response where an ownership error was expected.
  2. Edit and update by ID. Repeat with POST or PUT requests that modify an object you do not own. A positive result is the object changing under the victim's account.
  3. View by ID. Request an object you should not be able to read. A positive result is the object's content returned rather than a permission error.
  4. Transfer or ownership-change by ID. Attempt to move an object to another owner. A positive result is the ownership changing without the owner's consent.
  5. Client-specific tokens. Where a feature exists in an official or first-party client, obtain that client's token type and replay the same request. A positive result is a permission the standard token does not have, which then needs the ID swap to become a vulnerability.
  6. Read the error wording. When a request is refused, check whether the message ties the restriction to the calling app rather than to the object. A message that implies another client could do it is a pointer to the token type to hunt for.

Muthiyah needed no scanner, no chained exploit and no obscure technique. He needed to ask the one question most people stop short of once their own version of the request already works: does this check who I am, or does it check what I am touching? Here, it only ever checked the first one.

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

What happened, in plain words

In 2015 a security researcher named Laxman Muthiyah found a way to delete Facebook photo albums belonging to other people that he had permission to view. He reported it to Facebook, was paid $12,500, and Facebook fixed it within two hours of his report arriving. His own write-up is called How I Hacked Your Facebook Photos and is still online.

The bug was not complicated. It was a single missing check on the server. Facebook's software confirmed that the person making the request was a real, logged-in user who was allowed to delete albums in general. It never confirmed that the particular album being deleted belonged to that person. So if you knew the number that identifies someone else's album you could view, you could send a delete request for it and the server would simply do it.

This kind of mistake has a name: an IDOR, short for Insecure Direct Object Reference. You will see it explained properly below. The rest of this article walks through how Muthiyah found it, step by step, and explains every piece of jargon as it appears.

From the original on medium.com

The product and the feature

Facebook is a social network. People put photos on it, and photos can be grouped into albums, which are just collections of photos with a name, like "Holiday 2014". Each album has a delete option, so its owner can remove it.

Behind the website and the phone app sits something called an API. API stands for Application Programming Interface. A plain way to think about it: a restaurant has a dining room (the app or website you see) and a kitchen (the servers holding the data). You never walk into the kitchen yourself. You give your order to a waiter, and the waiter carries it back. An API is the waiter. It is a fixed set of requests that programs are allowed to send to the kitchen, and a fixed set of answers that come back.

Facebook's API is called the Graph API. Every app that touches Facebook data uses it: the official Facebook apps, games that log you in with Facebook, photo tools, and so on. When an app wants to read your photos or post something for you, it sends a request to the Graph API.

A request to an API is made of a few parts:

  • The method, a verb saying what you want to do. GET means "give me something". DELETE means "remove something". POST and PUT are used to create or change things.
  • The URL, the address of the thing you are acting on. In the Graph API, the address ends with a long number that identifies one specific object, such as one album.
  • Headers, small labelled lines of extra information sent along with the request, such as how big the request body is.
  • The body or parameters, the actual data or credentials you are sending.

Tokens: the key card that says who you are

To use the Graph API you need an access token. A token is a long string of characters that a server gives you after you log in, and that you show on every later request so the server knows who you are. The everyday comparison is a hotel key card: you show it at the door, the door checks it is valid, and it opens. You do not type your password at every door; the card stands in for it.

Tokens are not all the same. Different apps get tokens with different powers, in the same way a hotel might give a guest a card that opens their room, and give a cleaner a card that opens many rooms. Two token types matter here:

  • A Graph Explorer access token. Graph Explorer is a free tool Facebook provides for developers to try out API requests. Its token is the generic, everyday one that any developer can get.
  • A Facebook-for-Android access token. This is the kind of token issued to Facebook's own official Android phone app. It is meant for that app, and it carries the powers that app needs.

The starting question

Muthiyah did not begin with a scanner or an automated tool. He began with a question that anyone testing an API should ask: what actually happens if I try to delete something that is not mine?

That question is worth pausing on, because it is the whole method. Most people, once their own request works, stop. They see the feature work on their own account and move on. He asked what happens when the same request points at somebody else's data.

He also had a claim to test. Facebook's own documentation said plainly that the Graph API did not support deleting photo albums at all, officially, through any standard access token. Documentation here means the written instructions Facebook publishes telling developers what the API can and cannot do.

Finding it: the failed attempt and the error message

He tested the documentation's claim rather than trusting it. He sent a DELETE request at his own album's ID using a normal Graph Explorer access token. It failed, exactly as the documentation said it would.

The important part is what he did next. He read the wording of the error message closely instead of writing "confirmed, blocked" in his notes and moving on. The phrasing suggested the restriction was tied to which app was asking, not to a hard rule the server enforced for every possible caller.

That distinction is the seed of the whole bug. Imagine a building where the front desk tells you "visitors cannot open the storage room". That sentence does not mean the storage room cannot be opened. It means you, as a visitor, cannot open it. Somebody with a staff badge presumably can. The error message was saying something similar: this token cannot delete albums, which is not the same as nobody can delete albums.

And there was visible proof that somebody could. The Facebook mobile app has a "delete album" button sitting right there in its own interface. If a feature exists in an official client, the permission to do it must exist somewhere in the API too. The only open question is which token carries that permission.

From the original on medium.com

This instinct is reusable well beyond this one bug. An API answering "not permitted" tells you about the token you tried, not necessarily about the endpoint itself. If a feature visibly exists in any client application, official or not, there is a token type somewhere that unlocks it, and finding that token is often more productive than hammering the same access level that already failed.

Step 1: confirm the mobile token carries a broader delete permission

So he obtained a Facebook-for-Android access token, the kind issued to Facebook's own official mobile app, and sent the same request against his own album. The request is four lines long:

HTTP
DELETE /518171421550249 HTTP/1.1Host: graph.facebook.comContent-Length: 245access_token=<Facebook_for_Android_Access_Token>

Line by line:

  1. DELETE /518171421550249 HTTP/1.1 is the request line. DELETE is the verb: remove this thing. /518171421550249 is the path, the number identifying the album, and here it is his own album. HTTP/1.1 is simply the version of the language the request is written in.
  2. Host: graph.facebook.com says which server the request is addressed to: Facebook's Graph API server.
  3. Content-Length: 245 is a header saying how many bytes of data follow in the request body. The server uses it to know when it has received everything.
  4. access_token=<Facebook_for_Android_Access_Token> is the parameter carrying the credential. The angle brackets are a placeholder: in the real request, the actual Android token string sat there. It is left out here because a token is a secret, like a password.

The answer that came back was:

Text
Response: true

true is the API's way of saying "done". The album was deleted. This confirmed that the mobile token carried a broader delete permission than the standard one, exactly as the earlier error message had hinted.

On its own, this is already a real finding: a permission boundary that should not exist between officially sanctioned clients and the standard API surface. But it is not yet a vulnerability. An app having elevated access to its own data is expected behaviour. Facebook's own mobile client is supposed to be able to manage a user's own albums. If you delete your own album with your own app, nothing has gone wrong.

From the original on medium.com

Step 2: swap the album ID for someone else's

The escalation, the moment this stopped being "my app can manage my own stuff" and became a real vulnerability, was the next test. He took a different album's ID entirely, one belonging to someone else, and sent the identical request again with the same Android token. Only the ID in the path was swapped out. Nothing else about the request changed at all.

How did he get the other person's album ID? Simply by looking at the numeric ID sitting in that album's own URL. When you open an album in a browser, the address bar contains a number that identifies it. That number is visible in the album's own URL.

HTTP
DELETE /<victim_album_id> HTTP/1.1Host: graph.facebook.comContent-Length: 245access_token=<Facebook_for_Android_Access_Token>

Line by line, this is the same request as before with one substitution:

  1. DELETE /<victim_album_id> HTTP/1.1 is the request line. The verb is still DELETE, but the path now holds <victim_album_id>, a placeholder for the number of an album belonging to somebody else.
  2. Host: graph.facebook.com is unchanged: the same Graph API server.
  3. Content-Length: 245 is unchanged: the same size of request body.
  4. access_token=<Facebook_for_Android_Access_Token> is unchanged: the same Android token, the one that was only ever supposed to manage his own albums.

The answer was:

Text
Response: true

Deleted. An album with zero connection to his own account was gone, using a token that was only ever supposed to manage his own.

From the original on medium.com

Root cause: authentication versus authorization

Two words get confused constantly, and this bug is exactly the difference between them.

  • Authentication answers "who are you?". Showing your passport at a border is authentication.
  • Authorization answers "are you allowed to do this particular thing?". Having a visa that lets you work in one country does not let you work in another. That is authorization.

The server did authentication correctly. It verified that the access token belonged to a real, logged-in user who held delete permission on albums in general. It never took the second, equally necessary step: checking whether the specific album ID in the request actually belonged to that token's owner.

That gap, between "is this a valid request from a real user" and "does this real user actually own the specific thing they are asking to modify", is the definition of an IDOR. The name says it: an object (here, an album) is referenced directly by its ID, and the server trusts the ID without checking that the caller is entitled to that object.

This is about as pure an example of an IDOR as exists in bug bounty history.

Impact: what could and could not be done

The real impact was serious but not unlimited, despite what some headlines implied afterwards.

Deleting a specific album still required knowing its numeric ID. And critically, it still required that Muthiyah himself had permission to view that album under its own privacy settings: public albums, or ones shared with him specifically. He could not delete a stranger's fully private album that he had never been granted view access to. The bug skipped the delete-ownership check but did not touch the separate, still-working view-permission check underneath it.

That distinction matters when deciding how severe a bug is. The blast radius is everything an attacker can already see, not literally everything that exists on the platform. Getting that boundary right is the kind of precision that makes a finding credible instead of overstated. A report that claims "any album on Facebook" when the truth is "any album the attacker can view" is easier to dismiss, and rightly so.

Fix

Facebook patched the issue within two hours of the report landing. The report does not describe the change itself. The fix the behaviour calls for is an ownership check on the object being deleted: before acting on an album ID, verify that the album belongs to the owner of the token, not merely that the token is valid and carries delete permission in general.

Variants to test

The lesson sits in the gap between authentication and object-level authorization, and it applies to every endpoint that acts on an object, not just delete actions. Any time an API lets you act on something by ID, whether deleting, editing, viewing or transferring it, the test that matters is swapping that ID for an object you do not own while keeping your own valid token attached, and watching whether the server stops you or quietly complies.

  1. Delete by ID on other object types. Send a DELETE against a post, photo, comment or page ID you do not own, using your own valid token. A positive result is a success response where an ownership error was expected.
  2. Edit and update by ID. Repeat with POST or PUT requests that modify an object you do not own. A positive result is the object changing under the victim's account.
  3. View by ID. Request an object you should not be able to read. A positive result is the object's content returned rather than a permission error.
  4. Transfer or ownership-change by ID. Attempt to move an object to another owner. A positive result is the ownership changing without the owner's consent.
  5. Client-specific tokens. Where a feature exists in an official or first-party client, obtain that client's token type and replay the same request. A positive result is a permission the standard token does not have, which then needs the ID swap to become a vulnerability.
  6. Read the error wording. When a request is refused, check whether the message ties the restriction to the calling app rather than to the object. A message that implies another client could do it is a pointer to the token type to hunt for.

Muthiyah needed no scanner, no chained exploit and no obscure technique. He needed to ask the one question most people stop short of once their own version of the request already works: does this check who I am, or does it check what I am touching? Here, it only ever checked the first one.

Glossary

  • API: a fixed set of requests that programs can send to a server and the answers that come back; the waiter between the app you see and the data behind it.
  • Access token: a long string a server issues after login, shown on later requests so the server knows who is asking; like a hotel key card.
  • Album: a named collection of photos on Facebook.
  • Authentication: the process of proving who you are.
  • Authorization: the process of deciding whether you are allowed to do a particular thing to a particular object.
  • Body: the data carried inside a request, as opposed to the address and headers.
  • Content-Length: a header stating how many bytes of data follow in the request body.
  • DELETE: the HTTP method meaning "remove this thing".
  • Documentation: the written instructions a company publishes describing what its API can and cannot do.
  • Endpoint: one specific address in an API that performs one specific job.
  • GET: the HTTP method meaning "give me this thing".
  • Graph API: Facebook's API, the standard interface apps use to read and write Facebook data.
  • Graph Explorer: Facebook's free tool for developers to try out API requests, which issues a generic access token.
  • Header: a labelled line of extra information sent with a request, such as its size.
  • Host: the header naming which server a request is addressed to.
  • HTTP: the language browsers and servers use to exchange requests and responses.
  • IDOR (Insecure Direct Object Reference): a bug where an object is named directly by its ID and the server does not check that the caller is entitled to that object.
  • Method: the verb at the start of an HTTP request, such as GET, POST, PUT or DELETE.
  • Parameter: a named value sent with a request, such as access_token.
  • Path: the part of a URL identifying the specific thing being acted on, such as an album ID.
  • POST / PUT: HTTP methods used to create or change things.
  • Privacy settings: the rules an owner sets deciding who may view an album.
  • Request: one message sent from a client to a server asking it to do something.
  • Response: the message a server sends back after a request.
  • Root cause: the underlying mistake in the software that makes a bug possible.
  • Severity: how serious a bug is judged to be, based on what an attacker can actually do with it.
  • URL: the address of something on the web, visible in a browser's address bar.
  • Vulnerability: a flaw in software that lets someone do something they should not be able to do.

More by L4ZZ3RJ0D

View all

7 more disclosed reports, best first.

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.