Disclose private attachments in Facebook Messenger Infrastructure
An IDOR flaw in Facebook Messenger's attachment ID parameters allowed an attacker to disclose any private attachment by changing the ID to a victim's attachment ID. The attacker could obtain the ID by knowledge or brute-force.
Published on blog.flawminers.com
Messengeris a standalone instant messaging app by META. With features like text messaging, voice/video calls, and file sharing, it boasts over a billion users globally.
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
Messenger is Meta's standalone instant messaging application. It offers text messaging, voice and video calls, and file sharing, and is used by more than a billion people across multiple devices. The same messaging infrastructure is reachable from several surfaces: the main Facebook chat, Messenger, Workplace chat and Portal Facebook chat.
The feature at the centre of this finding is attachment sending. When a user sends an image, video, file or audio message, the client submits a request that references the attachment by an identifier. The report describes an Insecure Direct Object Reference (IDOR) in the parameters that carry those attachment IDs.
Setup
The report does not describe any special account setup, roles or versions. The only tool named is Burp Suite, used to intercept the send request. The precondition is simply the ability to send a message with an attachment from any of the surfaces listed above, since the report states they are all susceptible.
Finding it
While testing the Facebook Messenger platform, the researcher looked at the parameters governing attachment IDs: the IDs for video, image, file and audio messages. These parameters were not restricted, which is the classic IDOR condition. If the server accepts an attachment ID supplied by the client and returns or forwards the object behind it without checking that the caller owns it, then anyone who knows an attachment's fbid, or who can brute-force one, can reach a private attachment sent through the Messenger infrastructure.
Exploitation
Step 1: upload an attachment
The attacker starts by uploading any file within the Facebook ecosystem. The report names the main Facebook chat, Messenger, Workplace chat and Portal Facebook chat as all being susceptible.
Step 2: intercept the send request
With an image uploaded, the attacker intercepts the request in Burp Suite. The intercepted request takes this form:
POST /messaging/send/ HTTP/1.1
Host: www.facebook.com
client=mercury&action_type=ma-type%3Auser-generated-message&ephemeral_ttl_mode=0&has_attachment=true&image_ids[0]=123456&message_id=...etc
The body carries the message fields, including image_ids[0]=123456, the parameter the report identifies as vulnerable. The message_id and remaining fields are elided in the report.
Step 3: swap the attachment ID
The vulnerability lies in the image_ids[0] parameter. The attacker changes its value to the victim's image ID and resends the manipulated request to the Facebook server. The server then discloses the victim's private image.
Step 4: repeat for other attachment types
For other vulnerable parameters, the same manipulation discloses different kinds of attachment:
image_id[0] ==> file_id[0] ====> for disclosing files
image_id[0] ==> video_id[0] ====> for disclosing videos
image_id[0] ==> audio_id[0] ====> for disclosing audio messages
The report lists file_id[0], video_id[0] and audio_id[0] as the parameters for disclosing files, videos and audio messages.
Root cause
The report frames the flaw as the absence of restrictions on the attachment ID parameters, so a substituted ID is honoured. The report frames this as the absence of restrictions on the attachment ID parameters: the ID is trusted as supplied, and access control is not enforced against the authenticated user's ownership of the attachment. The report does not describe the server-side code, so the precise check that was missing is not stated; the observable behaviour is that a substituted ID is honoured.
Impact
An unauthorised party could unveil any private attachment transmitted through the Messenger infrastructure: images, files, videos and audio messages. Two conditions apply. The attacker must either know the attachment's fbid or brute-force it. The report names the main Facebook chat, Messenger, Workplace chat and Portal Facebook chat as susceptible surfaces.
Fix
Meta's bug bounty programme triaged the report on 04 Feb 2019 and fixed the bug on 13 Feb 2019. The researcher confirmed the fix the same day, and a bounty was awarded that day.
Variants to test
- Substitute IDs in the sibling parameters (
file_id[0],video_id[0],audio_id[0]) rather than only the image parameter. A positive result is any private file, video or audio message being disclosed.
What happened, in plain words
Messenger is Meta's own instant messaging app. You can send text, make voice and video calls, and share files with it, and more than a billion people use it on phones and computers. The same messaging machinery sits behind several places you can chat from: the main Facebook chat, Messenger itself, Workplace chat, and Portal Facebook chat.
This report is about one feature of that machinery: sending an attachment. When you send a picture, a video, a file or a voice message, your app does not send the whole thing in one go with a label saying "this is Alice's photo". Instead it sends a request that points at the attachment using an identifier, a short code that stands for that particular object on Facebook's servers. Think of it like a cloakroom ticket: you hand over your coat, you get a number, and later you show the number to get the coat back.
The problem the researcher found is called an Insecure Direct Object Reference, or IDOR. In plain terms: the server accepted whatever reference number the app handed it, without checking that the person sending the request actually owned the thing the number pointed at. That is the shape of this bug. By changing the attachment identifier in the request to somebody else's identifier, the researcher could get the server to reveal a private attachment that was never meant for them.
The report says this worked for images, files, videos and audio messages. To pull it off, an attacker needed either to know the attachment's fbid (Facebook's internal identifier for the object) or to brute-force it, which means trying many numbers in the hope that one of them belongs to someone else. The report does not say how long or how guessable these identifiers are, so it does not say how practical brute force would be.
The setup
The report does not describe any special account, role or software version. The only tool it names is Burp Suite, a program used to watch and edit the traffic between your browser or app and a website. The only precondition is that you can send a message with an attachment from one of the surfaces listed above, because the report says all of them are susceptible.
Finding it
While testing the Facebook Messenger platform, the researcher looked at the parameters that carry attachment IDs: the identifiers for video, image, file and audio messages. A parameter is simply one named field in a request, the way a form on a web page has a box labelled "name" or "email". These parameters were not restricted, which is the classic IDOR condition. If the server takes an attachment ID supplied by the client and acts on the object behind it without checking that the caller owns that object, then anyone who knows an attachment's fbid, or who can brute-force one, can reach a private attachment sent through Messenger.
Exploitation
Step 1: upload an attachment
The attacker starts by uploading any file within the Facebook ecosystem. The report names the main Facebook chat, Messenger, Workplace chat and Portal Facebook chat as all being susceptible.
Step 2: intercept the send request
With an image uploaded, the attacker intercepts the request in Burp Suite. Intercepting means catching the request on its way out, before it reaches Facebook, so you can read it and edit it. The intercepted request takes this form:
POST /messaging/send/ HTTP/1.1
Host: www.facebook.com
client=mercury&action_type=ma-type%3Auser-generated-message&ephemeral_ttl_mode=0&has_attachment=true&image_ids[0]=123456&message_id=...etc
Line by line, in plain words:
POST /messaging/send/ HTTP/1.1is the first line of an HTTP request. HTTP is the language browsers and servers use to talk.POSTis the method used when you are sending data to the server rather than just asking for a page./messaging/send/is the path on the server that handles sending a message.HTTP/1.1is the version of the protocol being used.Host: www.facebook.comtells the server which website the request is aimed at. One server can host many sites, so the request names the one it wants.- The blank line separates the headers (the labels at the top) from the body (the actual data being sent).
- The body is form-encoded, which means the fields are written as
name=valuepairs joined by&, the same format a web form produces when you press submit. client=mercuryis one of the fields in the request body.action_type=ma-type%3Auser-generated-messagemarks the action as a user-generated message. The%3Ais an encoded colon, so this readsma-type:user-generated-messageonce decoded.has_attachment=truesignals that the message carries an attachment.image_ids[0]=123456is the parameter the report identifies as vulnerable.message_id=...etcis the message identifier, and the report elides the rest of the fields with...etc.
Step 3: swap the attachment ID
The vulnerability lies in the image_ids[0] parameter. The attacker changes its value to the victim's image ID and resends the manipulated request to the Facebook server. The server then discloses the victim's private image. The report frames this as the absence of restrictions on the attachment ID parameters.
Step 4: repeat for other attachment types
For other vulnerable parameters, the same manipulation discloses different kinds of attachment:
image_id[0] ==> file_id[0] ====> for disclosing files
image_id[0] ==> video_id[0] ====> for disclosing videos
image_id[0] ==> audio_id[0] ====> for disclosing audio messages
Read this as a set of swaps. Where the request said image_ids[0], you instead put file_id[0] to reach files, video_id[0] to reach videos, and audio_id[0] to reach audio messages. The report lists file_id[0], video_id[0] and audio_id[0] as the parameters for disclosing files, videos and audio messages.
Why it worked
The report frames the flaw as the absence of restrictions on the attachment ID parameters, so a substituted ID is honoured. The report frames this as the absence of restrictions on the attachment ID parameters: the ID is trusted as supplied, and access control is not enforced against the authenticated user's ownership of the attachment. What can be observed is that a substituted ID is honoured.
What an attacker could do
An unauthorised party could unveil any private attachment transmitted through the Messenger infrastructure: images, files, videos and audio messages. Two conditions apply. The attacker must either know the attachment's fbid or brute-force it. The report names the main Facebook chat, Messenger, Workplace chat and Portal Facebook chat as susceptible surfaces.
The fix
Meta's bug bounty programme triaged the report on 04 Feb 2019 and fixed the bug on 13 Feb 2019. The researcher confirmed the fix the same day, and a bounty was awarded that day.
Other things worth testing
- Substitute IDs in the sibling parameters (
file_id[0],video_id[0],audio_id[0]) rather than only the image parameter. A positive result is any private file, video or audio message being disclosed.
Glossary
- API: a way for one piece of software to ask another to do something, like a service counter where you name what you want and get it back without entering the kitchen.
- Attachment: a file sent along with a message, such as an image, video, document or voice recording.
- Brute-force: trying many possible values one after another in the hope that one is correct, like guessing a combination lock by working through the numbers.
- Burp Suite: a tool that sits between your browser or app and a website so you can read and edit the requests and responses.
- Client: the app or browser you use, as opposed to the server that stores and serves the data.
- Endpoint: a specific address on a server that handles a particular kind of request, such as the path that sends a message.
- Entropy: the amount of randomness in a value; more entropy means harder to guess.
- fbid: Facebook's internal identifier for an object such as an attachment.
- Form-encoded: a way of writing request data as
name=valuepairs joined by&, the format a web form produces. - Header: a labelled line at the top of an HTTP request or response carrying information about it, such as the host.
- HTTP: the language browsers and servers use to exchange requests and responses.
- IDOR (Insecure Direct Object Reference): a bug where the server accepts a reference to an object supplied by the client without checking that the client is allowed to access that object.
- Identifier (ID): a short code that stands for a particular object on a server, like a cloakroom ticket number.
- Messenger: Meta's standalone instant messaging app for text, calls and file sharing.
- Parameter: a named field in a request, like a box on a form with a label and a value.
- Portal: a Meta device for video calling in the home; the report lists Portal Facebook chat as one of the affected surfaces.
- POST: the HTTP method used when sending data to a server rather than just requesting a page.
- Request: the message your app or browser sends to a server asking it to do something.
- Response: the message the server sends back.
- Server: the computer that stores data and answers requests from clients.
- Surface: one of the places the same messaging infrastructure can be reached from, such as Messenger or Workplace chat.
- Workplace: Meta's chat product for organisations; the report lists Workplace chat as one of the affected surfaces.