Posting-Gifs-As-Anyone-On-Facebook
The visual poll creation endpoint accepted a pageid parameter that could be set to any user's ID, allowing an attacker to post a poll as another user. The attacker could create a published post on behalf of any user without their consent.
Published on philippeharewood.com
While digging through some old notes on Facebook in September, I noticed a Facebook tab for Facebook Page “Publishing Tools” that I didn’t see before. It seemed to be introduced around July.
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 Pages have a "Publishing Tools" tab that page administrators use to compose and publish content on behalf of the page. Among the tools is a visual poll composer, which lets an administrator build a poll where each option is a GIF rather than plain text. The feature was introduced around July 2017, and Facebook publicly wrote about it in June 2017 in a newsroom post celebrating 30 years of the GIF.
The report describes a server-side authorisation flaw in the endpoint that creates these visual polls. The endpoint took the identity to publish as from the pageid request parameter, and changing it to another user's identifier published the poll as that user.
Setup
The work was done against Facebook itself, using the researcher's own test pages. The only tooling mentioned is Chrome Developer Tools, used to inspect the network request the Publishing Tools composer made when a visual poll was created. No specific browser version, account type or page configuration is given beyond the use of test pages.
The starting point was a set of old notes from September, revisited later in the year after the researcher noticed the polling feature appearing in the main composer window for other members of a Facebook feedback group.
Finding it
While going through old notes, the researcher noticed a Publishing Tools tab on a Facebook Page that had not been seen before, apparently introduced around July. The newsroom post about the GIF anniversary had shown a feature that was overlooked at the time:
"You can also vote by visiting Facebook's official Page on your mobile phone. To find the Page, search for "Facebook" in the main Facebook app."
That line implied the post could be created through Publishing Tools. For Facebook's official page, the researcher reasoned the URL would be similar to:
https://www.facebook.com/Facebook-20531316728/publishing_tools/?section=POLLS_COMPOSER
Trying the equivalent on one of the researcher's test pages presented the poll composer screen, and filling out the form created a published post on the page.
The first avenue explored was a privacy leak: it was not apparent to the researcher that users knew their votes were public. Facebook replied that the display was intentional, so the feature was put on a backlog.
Later in the year, while taking part in a Facebook feedback group, the researcher saw from a seasoned member that the polling feature had started to appear in the composer window. Having trouble getting it to appear, the researcher went back to the old tab to check whether the legacy feature was still there. It was, and inspecting the network request in Chrome Developer Tools produced the following call, with session details omitted:
HTTP POST 'https://www.facebook.com/visual_poll/ajax/create/?pageid=PAGE_ID&title=1&option1_title=1&option1_url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7aD7KLo6jJF4VBhS%2Fgiphy.gif&option2_title=2&option2_url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7WTFBRiRQGh5c7vi%2Fgiphy.gif&dpr=1' --data '__user=&__a=1&__dyn=&fb_dtsg='
The response was:
for (;;);{"__ar":1,"__sf":"h0","payload":{"question_id":"9999"},"bootloadable":{},"ixData":{},"gkxData":{},"lid":"1"}
The response is the usual Facebook AJAX envelope: the for (;;); prefix guards against cross-site script inclusion, and the JSON body carries a payload with the identifier of the newly created question.
What stood out was the parameter name. Unlike previous AJAX calls for page posts the researcher had encountered, this one used pageid rather than page_id. The researcher had seen pageid appear in vulnerable endpoints before, so the next question was how flexible the parameter was about the input it accepted.
Exploitation
Step 1: Change the page identifier to a user identifier
The pageid value was replaced with the identifier of a user who was not the current session user:
HTTP POST 'https://www.facebook.com/visual_poll/ajax/create/?pageid=USER_ID&title=1&option1_title=1&option1_url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7aD7KLo6jJF4VBhS%2Fgiphy.gif&option2_title=2&option2_url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7WTFBRiRQGh5c7vi%2Fgiphy.gif&dpr=1' --data '__user=&__a=1&__dyn=&fb_dtsg='
The request is otherwise identical to the legitimate one: the same title, option1_title, option1_url, option2_title, option2_url and dpr parameters, and the same POST body fields. Only the identity in pageid changed.
Step 2: Observe the result
The poll was posted as that user. Visiting the target page showed the post had indeed been published on behalf of that user. The researcher notes that anyone who stumbled across this edge would eventually reach the same result.
Root cause
The create endpoint took the identity to publish as from a request parameter (pageid) and did not verify that the authenticated session was authorised to act for that identity. Because the parameter was also accepted as a user identifier, the same code path that published polls for a page would publish them for an arbitrary user.
The report does not describe the server-side check that was missing or how the parameter was resolved internally; the behaviour above is what was observed. The fb_dtsg field in the body is the standard Facebook anti-CSRF token; the captured request shows its value omitted. The pageid naming, rather than page_id, was the signal that led the researcher to probe the parameter in the first place.
Impact
Visual polls could be created as anyone. An attacker with a valid session could publish a GIF poll on behalf of another user, without that user's involvement, by supplying that user's identifier in pageid. The report does not state any further constraints, such as whether the target had to be a friend, whether the target had to have interacted with the attacker, or whether the same technique worked against pages the attacker did not administer.
Fix
Facebook mitigated the issue on the day it was reported and fixed it a few days later. A fix for this class of flaw would derive the publishing identity from the authenticated session and check server-side that the session is authorised to publish as the requested identity.
Timeline
| Time | Event |
|---|---|
| Oct 26, 2017 at 8:07 am | Report sent |
| Oct 26, 2017 at 10:57 am | Further investigation by Facebook |
| Oct 26, 2017 at 11:51 am | Mitigation by Facebook |
| Oct 30, 2017 | Fixed by Facebook |
| Halloween | $10,000 bounty awarded by Facebook |
Variants to test
- Other identity parameters on legacy endpoints. Look for AJAX endpoints that take an owner or actor identifier under a non-standard name (
pageid,actor_id,owner,profile_id) and try substituting a user identifier for a page identifier and vice versa. A positive result is a successful response whose payload contains a new object identifier, followed by that object appearing on the target's profile or page. - Composer features that predate the main composer. Legacy Publishing Tools sections such as polls, milestones and job posts may still be reachable after the feature moves into the main composer. A positive result is a working request to a legacy path that the current UI no longer exposes.
- Parameter name mismatches. Where the rest of the API uses
page_id, an endpoint usingpageidmay have been written separately and skip the shared authorisation checks. A positive result is a request that succeeds with an identity the session does not control. - Cross-type identifiers. Supply a user identifier where a page is expected, and a page identifier where a user is expected. A positive result is content published under the wrong object type rather than a validation error.
- Anti-CSRF token scope. Confirm whether the standard
fb_dtsgtoken is bound to the acting identity or only to the session. A positive result is a forged request that carries a valid token for the session but targets a different identity, as in this report.
What happened, in plain words
Facebook Pages are public profiles that businesses, brands and public figures use on Facebook. Each Page has administrators: people who are allowed to post on the Page's behalf. Facebook gives those administrators a set of tools called "Publishing Tools", and one of those tools is a visual poll composer. A poll is a question with options people can vote on; a visual poll is the same thing, except each option is a GIF (a short looping animation) instead of plain text.
This report is about a flaw in the part of Facebook's website that actually creates those visual polls. When an administrator filled in the poll form and pressed the button, their browser sent a request to Facebook's server. That request contained an identifier saying which Page the poll should appear on. The server used that identifier to decide which Page the poll appeared on, and changing it to a user's identifier published the poll as that user. Worse, the same identifier could be a user's identifier instead of a Page's, so the server would happily publish a poll as an ordinary user. That is an authorisation flaw: the server knew who was asking (the session was valid) but never checked whether that person was allowed to do what they were asking for.
The researcher noticed the tab while digging through old notes, then confirmed the behaviour by watching the network traffic in Chrome Developer Tools. Facebook mitigated it the same day and fixed it a few days later, and paid a $10,000 bounty.
Background: what you need to know before reading the steps
A few ideas come up again and again below, so here they are from zero.
- A Page versus a user. A Facebook user is a person with a personal profile. A Facebook Page is a separate public entity, managed by one or more users. When you post "as a Page", the post appears under the Page's name, not yours.
- A session. When you log in, the server gives your browser a small piece of data (often called a cookie) that it sends back with every later request. That is how the server recognises you on the next page load without asking for your password again. Think of it as a wristband you get at an event: the door staff check the wristband, not your ID, every time you come back in.
- A request and a response. Your browser asks the server for something (a request) and the server answers (a response). A request has a method (GET for "give me something", POST for "here is data, do something with it"), a URL, and sometimes a body containing extra data.
- An endpoint. An endpoint is a specific address on the server that does a specific job, like a service counter in a large building.
https://www.facebook.com/visual_poll/ajax/create/is the endpoint that creates visual polls. - AJAX. AJAX is the technique web pages use to talk to the server in the background, without reloading the whole page. When you fill in a form and the page updates without a full refresh, AJAX is usually doing the work. Facebook's AJAX endpoints return data in a compact format called JSON, which is just text structured as labelled values.
- A parameter. A parameter is a named value attached to a request, usually in the URL after a
?, separated by&. In?pageid=123&title=1,pageidis a parameter name and123is its value. Think of a form with labelled boxes: the label is the parameter name, what you write in the box is the value. - URL encoding. Some characters cannot appear literally in a URL, so they are written as a percent sign and two hex digits.
%3Ais a colon,%2Fis a slash. Sohttps%3A%2F%2Fmedia.giphy.com%2F...is justhttps://media.giphy.com/...in disguise. - An identifier (ID). A number that uniquely names an object on the platform. Every user and every Page has one. If you know an object's ID, you can often refer to it directly in a request.
- Authorisation versus authentication. Authentication is proving who you are (logging in). Authorisation is whether you are allowed to do a particular thing. A flaw where you are properly logged in but the server lets you do something you should not be allowed to do is an authorisation flaw, sometimes called an access control flaw or IDOR (Insecure Direct Object Reference) when it involves swapping an identifier.
- CSRF and anti-CSRF tokens. CSRF (Cross-Site Request Forgery) is an attack where another website silently makes your browser send a request to a site you are logged into. To stop it, sites include a secret token in each form, which the other site cannot know. Facebook's token is called
fb_dtsg. It proves the request came from a real Facebook page, not a random site. It does not, by itself, prove which identity you are allowed to act for. - Chrome Developer Tools. A panel built into the Chrome browser (usually opened with F12) that shows every request the page makes, including the URL, the parameters and the response. It is the standard way to see what a web page is really doing behind the scenes.
The feature and how it was found
Facebook Pages have a "Publishing Tools" tab that page administrators use to compose and publish content on behalf of the Page. Among the tools is a visual poll composer, which lets an administrator build a poll where each option is a GIF rather than plain text. The feature was introduced around July 2017, and Facebook publicly wrote about it in June 2017 in a newsroom post celebrating 30 years of the GIF.
The researcher was going through old notes from September when they noticed a Publishing Tools tab on a Facebook Page that had not been seen before, apparently introduced around July. The newsroom post about the GIF anniversary had shown a feature that was overlooked at the time:
"You can also vote by visiting Facebook's official Page on your mobile phone. To find the Page, search for "Facebook" in the main Facebook app."
That line implied the post could be created through Publishing Tools. For Facebook's official page, the researcher reasoned the URL would be similar to:
https://www.facebook.com/Facebook-20531316728/publishing_tools/?section=POLLS_COMPOSER
Line by line: https://www.facebook.com/ is Facebook's address. Facebook-20531316728 is the Page's name followed by its numeric identifier, which is how Facebook addresses a Page directly. /publishing_tools/ is the tab. ?section=POLLS_COMPOSER is a parameter telling the tab which section to open, here the poll composer. The researcher was guessing the address from the pattern, not reading it from documentation.
Trying the equivalent on one of the researcher's test pages presented the poll composer screen, and filling out the form created a published post on the Page. A test page is a Page the researcher controls, so experimenting on it is safe and does not affect anyone else.
The first avenue explored was a privacy leak: it was not apparent to the researcher that users knew their votes were public. Facebook replied that the display was intentional, so the feature was put on a backlog. In other words, the first suspicion was not a security bug at all, just a design choice the researcher disagreed with.
Later in the year, while taking part in a Facebook feedback group, the researcher saw from a seasoned member that the polling feature had started to appear in the composer window. Having trouble getting it to appear, the researcher went back to the old tab to check whether the legacy feature was still there. It was. This matters because old features that have been replaced often stay reachable, and old code is less carefully maintained than new code.
Watching the request
Inspecting the network request in Chrome Developer Tools produced the following call, with session details omitted:
HTTP POST 'https://www.facebook.com/visual_poll/ajax/create/?pageid=PAGE_ID&title=1&option1_title=1&option1_url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7aD7KLo6jJF4VBhS%2Fgiphy.gif&option2_title=2&option2_url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7WTFBRiRQGh5c7vi%2Fgiphy.gif&dpr=1' --data '__user=&__a=1&__dyn=&fb_dtsg='
What each part means:
HTTP POSTsays this request is sending data to the server to create something, rather than just asking for a page.pageid=PAGE_IDis the identifier of the Page the poll should be published on.PAGE_IDis a placeholder standing in for the real number.title=1is the poll's question text, here a placeholder value.option1_title=1andoption2_title=2are the labels of the two options.option1_urlandoption2_urlare the GIF addresses for each option, URL-encoded. Decoded, the first ishttps://media.giphy.com/media/3o7aD7KLo6jJF4VBhS/giphy.gifand the second ishttps://media.giphy.com/media/3o7WTFBRiRQGh5c7vi/giphy.gif.dpr=1is a display-related value the page sends along.--data '__user=&__a=1&__dyn=&fb_dtsg='is the body of the request. These are standard Facebook fields;fb_dtsgis the anti-CSRF token described above. In the captured copy the values are blanked out, which is what "session details omitted" means.
The response was:
for (;;);{"__ar":1,"__sf":"h0","payload":{"question_id":"9999"},"bootloadable":{},"ixData":{},"gkxData":{},"lid":"1"}
This is the usual Facebook AJAX envelope. The for (;;); prefix is a deliberate guard: it makes the response invalid as a script, so another website cannot include it and run it as code (a trick called cross-site script inclusion). The rest is JSON. The payload object contains question_id, the identifier of the newly created poll, here shown as 9999. In plain terms: the server said "done, and here is the number of the thing I just made".
What stood out was the parameter name. Unlike previous AJAX calls for page posts the researcher had encountered, this one used pageid rather than page_id. The researcher had seen pageid appear in vulnerable endpoints before, so the next question was how flexible the parameter was about the input it accepted. The reasoning is worth spelling out: if most of the codebase uses one spelling and this endpoint uses another, it was probably written separately, and separately written code often misses the shared safety checks that the rest of the codebase gets for free.
Exploitation
Step 1: Change the Page identifier to a user identifier
The pageid value was replaced with the identifier of a user who was not the current session user:
HTTP POST 'https://www.facebook.com/visual_poll/ajax/create/?pageid=USER_ID&title=1&option1_title=1&option1_url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7aD7KLo6jJF4VBhS%2Fgiphy.gif&option2_title=2&option2_url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3o7WTFBRiRQGh5c7vi%2Fgiphy.gif&dpr=1' --data '__user=&__a=1&__dyn=&fb_dtsg='
The request is otherwise identical to the legitimate one: the same title, option1_title, option1_url, option2_title, option2_url and dpr parameters, and the same POST body fields. Only the identity in pageid changed, from PAGE_ID to USER_ID. The researcher was testing a simple question: does the server check that the identifier belongs to something I am allowed to post as, or does it just use whatever number I give it?
Step 2: Observe the result
The poll was posted as that user. Visiting the target page showed the post had indeed been published on behalf of that user. The researcher notes that anyone who stumbled across this edge would eventually reach the same result. In other words, the flaw was not hard to trigger once you knew the parameter existed; the hard part was noticing the parameter at all.
Root cause
The create endpoint took the identity to publish as from a request parameter (pageid) and did not verify that the authenticated session was authorised to act for that identity. Because the parameter was also accepted as a user identifier, the same code path that published polls for a Page would publish them for an arbitrary user.
A useful comparison: imagine a hotel reception where you fill in a form saying which room to charge a meal to. If the receptionist only checks that you are a guest of the hotel, and never checks that the room number you wrote is yours, you can charge dinner to any room. Here the "guest of the hotel" check is the session and the anti-CSRF token; the missing check is "is this room yours?".
The report does not describe the server-side check that was missing or how the parameter was resolved internally; the behaviour above is what was observed. The fb_dtsg field in the body is the standard Facebook anti-CSRF token; the captured request shows its value omitted. That is the key lesson: an anti-CSRF token protects against other websites, not against a logged-in user deliberately changing a parameter. The pageid naming, rather than page_id, was the signal that led the researcher to probe the parameter in the first place.
Impact
Visual polls could be created as anyone. An attacker with a valid session could publish a GIF poll on behalf of another user, without that user's involvement, by supplying that user's identifier in pageid. The report does not state any further constraints, such as whether the target had to be a friend, whether the target had to have interacted with the attacker, or whether the same technique worked against Pages the attacker did not administer.
Fix
Facebook mitigated the issue on the day it was reported and fixed it a few days later. A fix for this class of flaw would derive the publishing identity from the authenticated session and check server-side that the session is authorised to publish as the requested identity. In the hotel comparison: the receptionist should look up which room is actually yours from your booking, not from the number you wrote on the form.
Timeline
| Time | Event |
|---|---|
| Oct 26, 2017 at 8:07 am | Report sent |
| Oct 26, 2017 at 10:57 am | Further investigation by Facebook |
| Oct 26, 2017 at 11:51 am | Mitigation by Facebook |
| Oct 30, 2017 | Fixed by Facebook |
| Halloween | $10,000 bounty awarded by Facebook |
Variants to test
Each one is a way of asking the same question: does the server check that this identity is mine?
- Other identity parameters on legacy endpoints. Look for AJAX endpoints that take an owner or actor identifier under a non-standard name (
pageid,actor_id,owner,profile_id) and try substituting a user identifier for a Page identifier and vice versa. A positive result is a successful response whose payload contains a new object identifier, followed by that object appearing on the target's profile or Page. - Composer features that predate the main composer. Legacy Publishing Tools sections such as polls, milestones and job posts may still be reachable after the feature moves into the main composer. A positive result is a working request to a legacy path that the current interface no longer exposes.
- Parameter name mismatches. Where the rest of the API uses
page_id, an endpoint usingpageidmay have been written separately and skip the shared authorisation checks. A positive result is a request that succeeds with an identity the session does not control. - Cross-type identifiers. Supply a user identifier where a Page is expected, and a Page identifier where a user is expected. A positive result is content published under the wrong object type rather than a validation error.
- Anti-CSRF token scope. Confirm whether the standard
fb_dtsgtoken is bound to the acting identity or only to the session. A positive result is a forged request that carries a valid token for the session but targets a different identity, as in this report.
Glossary
- AJAX: a way for a web page to talk to the server in the background without reloading the whole page.
- Anti-CSRF token: a secret value placed in a form or request to prove it came from the real site, not from another website. Facebook's is called
fb_dtsg. - Authorisation: whether a logged-in person is allowed to perform a particular action.
- Authentication: proving who you are, usually by logging in.
- Bounty: a payment a company makes to someone who reports a security flaw responsibly.
- Chrome Developer Tools: a panel in the Chrome browser that shows the requests a page makes and the responses it gets.
- Cookie: a small piece of data a site stores in your browser so it can recognise you on later requests.
- CSRF (Cross-Site Request Forgery): an attack where another website causes your browser to send a request to a site you are logged into.
- Endpoint: a specific address on a server that performs a specific job.
- GIF: a short, usually looping, animated image format.
- Identifier (ID): a number that uniquely names an object such as a user or a Page.
- IDOR (Insecure Direct Object Reference): a flaw where a request refers to an object by its identifier and the server does not check that you are allowed to access that object.
- JSON: a text format for structured data, made of labelled values.
- Legacy feature: an older part of a product that has been replaced but may still be reachable.
- Mitigation: a temporary measure that stops an attack working, before a permanent fix is in place.
- Page (Facebook Page): a public profile for a business, brand or public figure, managed by administrators.
- Parameter: a named value attached to a request, usually in the URL after a
?. - Payload: the part of a response that carries the actual result data.
- Poll: a question with options that people can vote on.
- Publishing Tools: the tab on a Facebook Page where administrators compose and publish content.
- Request: what a browser sends to a server to ask for something or to submit data.
- Response: what the server sends back.
- Session: the server's record of your logged-in state, tied to a cookie in your browser.
- URL encoding: writing characters that are not allowed in a URL as a percent sign plus two hex digits, such as
%3Afor a colon. - Visual poll: a poll where each option is a GIF instead of plain text.