How I was able to delete any image in Facebook community question forum
The attachment parameter in Facebook Community Question Forum's image upload feature was vulnerable to an IDOR, allowing an attacker to delete any image by manipulating the fbid value. An attacker could delete images from posts or comments by replacing the fbid with a victim's image ID.
Published on blog.flawminers.com
Facebook Community Question Forum is a dedicated space where users could seek assistance and connect with others by asking questions across various categories. Whether you were looking for advice, troubleshooting, or general information, this platform allowed you to engage with a supportive community.
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.
Context
Facebook Community Question Forum (also referred to in the report as the Facebook Help Community) is a space where users ask questions across categories and receive answers from other users and from the Facebook support team. One of the features of this forum lets a user attach an image when answering a question as a comment.
The report focuses on the parameter that manages those uploaded images. During testing of the image upload flow, the researcher found that this parameter was susceptible to an Insecure Direct Object Reference (IDOR) issue. If exploited, the bug could have allowed a malicious actor to delete any image, whether it was present in posts or in comments within the Facebook Help Community.
Setup
The testing was carried out from an ordinary attacker account. The only tool named in the report is Burp Suite, used to intercept the request that posts an answer. The researcher also credits Max Pasqua for the method used to derive the fbid of another user's image from its CDN link.
No specific browser, Burp Suite version or server version is given. The precondition for the attack is simply that the attacker can post an answer with an image to any question in the community, and that the victim has an image somewhere in the community whose CDN URL the attacker can obtain.
Finding it
While testing the feature that lets users upload images when responding to questions as comments, the researcher examined the parameter responsible for managing those images. That parameter, attachment, carries the identifier of the uploaded image in the form of an fbid. The value is supplied by the client in the POST request, and the report shows that a foreign fbid placed there was accepted. That is what made the parameter look wrong: the object reference was fully client-controlled.
Exploitation
Step 1: Initiate the attack
From the attacker's account, navigate to Facebook Community and select any question. Respond to the question by adding an image.
Step 2: Intercept the request
Use Burp Suite to intercept the request. The POST request resembles the following:
POST /help/community/async/post_answer/?view=top&question_id=[any_question_id]&helpCommunityPath=%2Fbusiness%2Fhelp%2Fcommunity%2F&dpr=
fb_dtsg=xxx&answer=test&attachment=%7B%22fbid%22%3A275252333010477%7D&view=top&__user= ...etc
Here attachment={"fbid":275252333010477} (URL-encoded in the body) and fbid represents the ID of the uploaded image. The answer field carries the comment text, and fb_dtsg is the usual Facebook form token. The endpoint is /help/community/async/post_answer/, with the question identified by question_id and the community path by helpCommunityPath.
Step 3: Extract the victim image fbid
To obtain the fbid of other users' images, the researcher used Max Pasqua's method:
- Retrieve the image link, for example:
https://scontent.febl3-1.fna.fbcdn.net/v/t39.2229-6/[redacted].jpg?oh=[redacted]&oe=5B05ACC9
- Extract the part of the URL after the last slash, i.e.
[redacted].jpg?oh=[redacted]&oe=5B05ACC9. - Retrieve the second number set between the underscores, in this case
500237376979766. - Subtract
3333333(a constant number) from this number. - The final formula is
fbid = 500237376979766-3333333, resulting in500237373646433as the fbid for the given image link.
In other words, the CDN filename embeds a value that is offset by a fixed constant from the actual fbid used by the application, so the object identifier can be computed from a URL that is visible to anyone who can see the image.
Step 4: Manipulate the POST request
Replace the victim image fbid (for example 500237373646433) in the value of the attachment parameter from Step 2. The altered POST request appears as follows:
POST /help/community/async/post_answer/?view=top&question_id=[any_question_id]&helpCommunityPath=%2Fbusiness%2Fhelp%2Fcommunity%2F&dpr=
fb_dtsg=xxx&answer=test&attachment=%7B%22fbid%22%3A500237373646433%7D&view=top&__user= ...etc
The only change is the fbid inside the attachment JSON: it now points at the victim's image rather than at the image the attacker uploaded.
Step 5: Exploit the deletion vulnerability
By deleting the answer containing the manipulated image, the attacker can unintentionally delete the victim's image, as both images share the same fbid. Deleting the answer containing the manipulated image deletes the victim's image.
Root cause
The attachment parameter is a direct object reference supplied by the client, and the server did not verify that the fbid in it belonged to the user making the request. Deleting the answer containing the manipulated image deleted the victim's image, as both shared the same fbid. The report does not describe the server-side code, so the exact check that was missing is only implied: an ownership or authorisation check on the fbid before it is attached to an answer and before it is deleted.
Impact
An attacker with an ordinary account could delete any image in posts or comments within the Facebook Help Community, provided they could obtain the image's CDN link in order to derive its fbid. The report frames this as a potential capability ("could have allow") rather than describing a mass exploitation. No bounty amount, CVSS score or severity rating is stated in the report.
Fix
According to the timeline, Meta fixed the issue on 13 February 2018 and the researcher confirmed the fix on 19 February 2018. The report does not describe the change that was made.
Timeline
| Date | Actor | Event |
|---|---|---|
| 27 Jan 2018 | Sarmad | Initial report |
| 07 Feb 2018 | Meta Bug Bounty | Report triaged |
| 13 Feb 2018 | Meta Bug Bounty | Issue fixed |
| 19 Feb 2018 | Sarmad | Fix confirmed |
| 23 Feb 2018 | Meta Bug Bounty | Bounty awarded |
Variants to test
- Other attachment-bearing endpoints. Look for any request that accepts an object identifier for an uploaded file (comment attachments, post attachments, profile media) and swap in an identifier you do not own. A positive result is the server accepting the foreign identifier and acting on it, for example deleting or reassigning the object.
- Deletion via the owning container. Where an object is deleted implicitly when its parent (an answer, comment or post) is removed, create a parent that references a foreign object and delete the parent. A positive result is the foreign object disappearing.
- Identifier derivation from public URLs. Check whether CDN filenames embed an offset or otherwise predictable form of the internal identifier, as in the
fbidminus3333333relationship here. A positive result is a computed identifier that the application accepts. - Ownership checks on read as well as write. Test whether the same identifier can be used to view or modify objects belonging to other users, not only to delete them. A positive result is any response that returns or changes another user's object.
What happened, in plain words
Facebook runs a help area called the Community Question Forum, where ordinary people post questions and other people, including Facebook's support team, reply with answers. One of the things you can do there is attach a picture to your answer, so you can show a screenshot or a photo instead of describing it in words.
When you upload that picture, your browser sends a small message to Facebook's servers telling them which picture you want to attach. That message contains a number that identifies the picture. In this report the number is called an fbid. The researcher, Sarmad Hassan, found that a number identifying someone else's picture could be placed in his own answer.
That is the whole bug. If you can work out the number of somebody else's picture, you can put that number into your own answer instead of your own picture's number. Then, when you delete your answer, the victim's image is deleted, as both share the same fbid. So an ordinary user could delete any image in the forum, in posts or in comments, as long as they could find that image's web address.
This kind of bug has a name: Insecure Direct Object Reference, or IDOR. The idea is simple. Imagine a hotel where the receptionist hands you a key with the room number on it, and you discover that the same key also opens any other room whose number you write on it. The key is supposed to be tied to you and your room, but the hotel only checks the number written on the key, not whether the room is yours. Here, the fbid is the room number, and the server accepted a number that was not yours.
The feature being tested
The Community Question Forum is a place to ask questions across categories and get answers from other users and from Facebook support. The specific feature under test is the image attachment on answers: when you reply to a question as a comment, you can add an image.
The report focuses on the parameter that manages those uploaded images. A parameter is a named piece of data in a request, like a field on a form. This particular one is called attachment, and it carries the identifier of the uploaded image, the fbid. The value is supplied by the browser, and the report shows a foreign fbid placed there was accepted. That is what made the parameter look wrong: the reference to the object was fully controlled by the client.
Setting up
The testing was done from an ordinary attacker account, not a special or internal one. The only tool named in the report is Burp Suite, which is used to intercept the request that posts an answer. Intercepting means pausing a request on its way from your browser to the server so you can read it and change it before letting it continue. Think of it as a postal worker who lets you open a letter, rewrite a line, and seal it again before delivery.
The researcher also credits Max Pasqua for the method used to work out the fbid of another user's image from its CDN link. A CDN, or content delivery network, is the network of servers that serves images and other files quickly to people around the world; the link to an image on a CDN is the web address you see when you open the image in a new tab.
The report does not name a specific browser, Burp Suite version or server version. The precondition for the attack is simply that the attacker can post an answer with an image to any question in the community, and that the victim has an image somewhere in the community whose CDN URL the attacker can obtain.
Finding it
While testing the feature that lets users upload images when responding to questions as comments, the researcher examined the parameter responsible for managing those images. That parameter, attachment, carries the identifier of the uploaded image in the form of an fbid. The value is supplied by the client in the POST request, and the report shows a foreign fbid placed there was accepted. That is what made the parameter look wrong: the object reference was fully client-controlled.
A POST request is one of the basic ways a browser talks to a server. When you fill in a form and press a button, the browser usually sends a POST request carrying your data. The server reads the data and does something with it, here, attaching an image to an answer.
Exploitation
Step 1: Initiate the attack
From the attacker's account, navigate to Facebook Community and select any question. Respond to the question by adding an image.
Why this step: you need a real answer with a real image of your own, because that is the request you are going to capture and then edit. You are creating a normal, harmless post first so you have something to work with.
Step 2: Intercept the request
Use Burp Suite to intercept the request. The POST request resembles the following:
POST /help/community/async/post_answer/?view=top&question_id=[any_question_id]&helpCommunityPath=%2Fbusiness%2Fhelp%2Fcommunity%2F&dpr=
fb_dtsg=xxx&answer=test&attachment=%7B%22fbid%22%3A275252333010477%7D&view=top&__user= ...etc
Line by line, in plain words:
POST /help/community/async/post_answer/is the address on Facebook's server that handles posting an answer.POSTis the type of request, the one used to send data.?view=top&question_id=[any_question_id]&helpCommunityPath=%2Fbusiness%2Fhelp%2Fcommunity%2F&dpr=is the query string, the part of the address after the question mark. It carries small named values:view=top(which view),question_id=[any_question_id](which question you are answering, a placeholder in the report),helpCommunityPath=%2Fbusiness%2Fhelp%2Fcommunity%2F(the path of the community, where%2Fis just a slash encoded for a URL), anddpr=(left empty here).- The next line is the body of the request, the data being sent.
fb_dtsg=xxxis a form token Facebook uses to tie a request to your session;xxxstands for the real value, which is not shown. A token is a short string the server gives your browser so it can recognise that a request comes from a logged-in session, a bit like a wristband at an event. answer=testis the text of your comment.attachment=%7B%22fbid%22%3A275252333010477%7Dis the interesting part. It is URL-encoded, meaning special characters are written in a safe form. Decoded, it reads{"fbid":275252333010477}. That is a small piece of JSON, a common text format for structured data, shaped like a labelled box: the label isfbidand the value is275252333010477.view=top&__user= ...etcare further fields, with__userstanding for the user identifier and...etcmeaning the request continues with more fields not shown.
So attachment={"fbid":275252333010477} and fbid represents the ID of the uploaded image. The answer field carries the comment text, and fb_dtsg is the usual Facebook form token. The endpoint is /help/community/async/post_answer/, with the question identified by question_id and the community path by helpCommunityPath.
Why this step: you want to see exactly what your browser sends when it attaches an image, so you know which field to change later. You cannot change what you cannot see.
Step 3: Extract the victim image fbid
To obtain the fbid of other users' images, the researcher used Max Pasqua's method:
- Retrieve the image link, for example:
https://scontent.febl3-1.fna.fbcdn.net/v/t39.2229-6/[redacted].jpg?oh=[redacted]&oe=5B05ACC9
- Extract the part of the URL after the last slash, i.e.
[redacted].jpg?oh=[redacted]&oe=5B05ACC9. - Retrieve the second number set between the underscores, in this case
500237376979766. - Subtract
3333333(a constant number) from this number. - The final formula is
fbid = 500237376979766-3333333, resulting in500237373646433as the fbid for the given image link.
In other words, the CDN filename embeds a value that is offset by a fixed constant from the actual fbid used by the application, so the object identifier can be computed from a URL that is visible to anyone who can see the image.
Why this step: the fbid is the number that identifies the picture inside Facebook's system, but it is not printed anywhere on the page. The image's web address, however, is visible to anyone who can see the image. The method turns the visible address into the hidden number, so you can point at someone else's picture. The fixed subtraction is like knowing that house numbers on one side of a street are always ten higher than the numbers on the other side: once you know the rule, you can work out the number you cannot see.
Step 4: Manipulate the POST request
Replace the victim image fbid (for example 500237373646433) in the value of the attachment parameter from Step 2. The altered POST request appears as follows:
POST /help/community/async/post_answer/?view=top&question_id=[any_question_id]&helpCommunityPath=%2Fbusiness%2Fhelp%2Fcommunity%2F&dpr=
fb_dtsg=xxx&answer=test&attachment=%7B%22fbid%22%3A500237373646433%7D&view=top&__user= ...etc
The only change is the fbid inside the attachment JSON: it now points at the victim's image rather than at the image the attacker uploaded.
Line by line, in plain words:
- Everything before
attachment=is the same as before: same address, same question, same token, same answer text. attachment=%7B%22fbid%22%3A500237373646433%7Ddecodes to{"fbid":500237373646433}. The only difference from Step 2 is the number:275252333010477has been replaced with500237373646433, the victim's image.- The rest of the request is unchanged.
Why this step: this is the actual attack. You are telling Facebook to attach a picture that is not yours to your answer. The report shows the server accepted the foreign fbid.
Step 5: Exploit the deletion vulnerability
By deleting the answer containing the manipulated image, the attacker can unintentionally delete the victim's image, as both images share the same fbid. In effect, the attacker's own answer becomes a handle on someone else's image: removing the answer removes the referenced object.
Why this step: the deletion happens as a side effect. You do not need a special delete-image request. You delete your own answer, and the victim's image is deleted, as both share the same fbid. It is like borrowing a coat check ticket, hanging your own coat on it, and then finding that when you hand the ticket back, someone else's coat is gone too.
Root cause
The attachment parameter is a direct object reference supplied by the client, and a foreign fbid placed in it was accepted. Because the deletion path followed the same reference, an answer created with a foreign fbid gave the attacker a way to trigger deletion of an image they did not own. The report does not describe the server-side code, so the exact check that was missing is only implied: an ownership or authorisation check on the fbid before it is attached to an answer and before it is deleted.
In everyday terms: the server accepted a picture number that was not yours.
Impact
An attacker with an ordinary account could delete any image in posts or comments within the Facebook Help Community, provided they could obtain the image's CDN link in order to derive its fbid. The report frames this as a potential capability ("could have allow") rather than describing a mass exploitation. No bounty amount, CVSS score or severity rating is stated in the report.
Fix
According to the timeline, Meta fixed the issue on 13 February 2018 and the researcher confirmed the fix on 19 February 2018.
"Server-side" means the check has to happen on Facebook's computers, not in the browser. A check in the browser can always be bypassed, because the attacker controls the browser. It is like a bouncer at the door rather than a sign on the wall.
Timeline
| Date | Actor | Event |
|---|---|---|
| 27 Jan 2018 | Sarmad | Initial report |
| 07 Feb 2018 | Meta Bug Bounty | Report triaged |
| 13 Feb 2018 | Meta Bug Bounty | Issue fixed |
| 19 Feb 2018 | Sarmad | Fix confirmed |
| 23 Feb 2018 | Meta Bug Bounty | Bounty awarded |
"Triaged" means the security team reviewed the report, confirmed it was a real issue and started work on it. A bounty is a reward paid to the researcher for finding and reporting the problem.
Variants to test
- Other attachment-bearing endpoints. Look for any request that accepts an object identifier for an uploaded file (comment attachments, post attachments, profile media) and swap in an identifier you do not own. A positive result is the server accepting the foreign identifier and acting on it, for example deleting or reassigning the object.
- Deletion via the owning container. Where an object is deleted implicitly when its parent (an answer, comment or post) is removed, create a parent that references a foreign object and delete the parent. A positive result is the foreign object disappearing.
- Identifier derivation from public URLs. Check whether CDN filenames embed an offset or otherwise predictable form of the internal identifier, as in the
fbidminus3333333relationship here. A positive result is a computed identifier that the application accepts. - Ownership checks on read as well as write. Test whether the same identifier can be used to view or modify objects belonging to other users, not only to delete them. A positive result is any response that returns or changes another user's object.
Glossary
- API: a way for one piece of software to talk to another, like a waiter taking your order to the kitchen and bringing back the food.
- Attachment: the file, here an image, that is added to a post or answer.
- Authorisation check: a check that the person making a request is allowed to do what they are asking to do.
- Bounty: a reward paid to a researcher who reports a security problem.
- Burp Suite: a tool that sits between your browser and a server so you can read and change requests.
- CDN (content delivery network): a network of servers that delivers files such as images quickly to users.
- Client: the browser or app on your side, as opposed to the server.
- Cookie / token: a short string the server gives your browser so it can recognise your logged-in session, like a wristband at an event.
- CVSS: a standard scoring system for how severe a security issue is.
- Endpoint: a specific address on a server that handles a particular action.
- fbid: the identifier Facebook uses for an uploaded image, a number.
- fb_dtsg: a form token Facebook includes in requests to tie them to your session.
- IDOR (Insecure Direct Object Reference): a bug where the server lets you name an object by its identifier without checking that the object is yours, like a hotel key that opens any room whose number you write on it.
- JSON: a common text format for structured data, written as labelled values in curly braces.
- Parameter: a named piece of data in a request, like a field on a form.
- POST request: a request that sends data to a server, typically used when you submit a form.
- Query string: the part of a web address after the question mark, carrying small named values.
- Root cause: the underlying reason a bug exists, as opposed to its symptoms.
- Server-side: happening on the server, where the user cannot tamper with it.
- Session: the period during which a server recognises you as logged in.
- Triaged: reviewed and confirmed as a real issue by the security team.
- URL-encoded: written in a safe form where special characters are replaced by codes such as
%7Bfor{. - Victim: the person whose data or account is affected by the attack.