Fixed : Brute-force Instagram account’s passwords
The Instagram account linking endpoint on mbasic.facebook.com did not enforce a server-side rate limit per victim account, only per Facebook account. An attacker could use many Facebook accounts to attempt millions of passwords daily against a victim's Instagram account.
Published on medium.com
{{media:0}}
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 allow an admin or editor of the page to add an Instagram account to that page. Once the Instagram account is connected, the page can create Instagram ads in Ads Manager without first connecting the Instagram account to a Business Manager. There is an endpoint to connect an Instagram account through the mobile browser at mbasic.facebook.com, which accepts the Instagram username and password.
That endpoint is the subject of this write-up: it accepted password submissions for an Instagram account, and the rate limiting that Facebook applies to password guessing could be bypassed.
Setup
The request carries the Instagram credentials together with the attacker's page identifier.
The request that performs the connection carries the Instagram credentials together with the attacker's page identifier:
fb_dtsg and jazoest are shown as sanitised in the published request. username and password are the victim's Instagram credentials, and page_id identifies the page the account would be attached to.
For volume, the researcher used Facebook's test users. Facebook documents that each Facebook application can create up to 2000 test accounts, the same kind of account that can be created through /whitehat/accounts/. The reference given is https://developers.facebook.com/docs/apps/test-users/.
Finding it
Facebook protects the login request with a rate-limiting mechanism against password guessing. In the researcher's testing, only a maximum of 20 wrong passwords could be attempted in a day. Exceeding 20 attempts produced a "too many requests" response, and further requests were blocked.
The problem was where that limit was applied. At this endpoint, Facebook failed to block attempts against the victim account on the server side. The limit of 20 requests was enforced per Facebook account, not per targeted Instagram account.
Exploitation
Step 1: Confirm the per-account limit
Submitting wrong passwords for the Instagram account from one Facebook account allowed a maximum of 20 attempts in a day. Exceeding 20 produced "too many requests" and further requests were blocked. This established the unit the limit was counted in.
Step 2: Multiply attempts across Facebook accounts
The arithmetic follows directly from the per-account enforcement:
- 1 Facebook account = 20 wrong password attempts.
- 10 Facebook accounts = 200 wrong password attempts.
At this point the researcher did not have a large pool of user accounts to draw on.
Step 3: Use test users to obtain accounts at scale
Facebook allows test accounts to be created for Facebook applications, up to 2000 per application. The researcher created around 15 Facebook applications:
- 15 apps x 2000 test accounts = 30,000 test users under a single Facebook user account.
- 10 regular Facebook user accounts were created.
- 10 x 30,000 = 300,000 test users in total.
Step 4: Calculate the resulting attempt rate
With 300,000 identities each entitled to 20 attempts per day, the researcher could attempt 6,000,000 passwords daily against the victim's Instagram account.
Root cause
The rate limit on this endpoint was keyed to the Facebook account making the request rather than to the Instagram account being targeted. The server therefore never saw the aggregate volume of guesses against one victim: each new Facebook identity, including test users belonging to applications, arrived with a fresh allowance of 20 attempts. Because test users can be generated in bulk per application, the per-account limit provided no meaningful ceiling on guesses against a single Instagram account.
Impact
An attacker holding an admin or editor role on a Facebook Page could run a sustained online password-guessing attack against an Instagram account through mbasic.facebook.com, using test users to reset the per-account allowance. The researcher calculated a capacity for 6,000,000 attempts per day. Whether any given account could actually be compromised depends on the strength of its password, which the report does not quantify.
Fix
Facebook marked the issue as fixed on 8 November 2018, and a bounty was awarded on 14 November 2018. The report does not describe the change that was made.
Timeline
| Date | Event |
|---|---|
| Sep 21, 2018 | Report sent |
| Sep 25, 2018 | Clarification requested by Facebook |
| Sep 26, 2018 | Clarification sent |
| Oct 3, 2018 | Triaged |
| Oct 3, 2018 | Closed as informative (impact is minimal) |
| Oct 4, 2018 | More details sent |
| Oct 8, 2018 | Triaged |
| Oct 26, 2018 | Asked for updates |
| Nov 8, 2018 | Fixed |
| Nov 14, 2018 | Bounty awarded |
Variants to test
- Per-identity limits on credential endpoints. Submit wrong credentials for the same victim from several accounts and watch whether the block follows the victim or the requester. A positive result is the victim being locked out or throttled across identities.
- Bulk-provisioned identities. Where a platform lets one user create many sub-accounts, test users or API clients, check whether each one receives an independent attempt allowance against the same target. A positive result is the total attempt count scaling with the number of provisioned identities.
- Account-linking flows. Features that attach a third-party account (social, ad or commerce integrations) often accept external credentials on a separate endpoint from the main login. Test whether that endpoint applies the same lockout as the primary login. A positive result is unlimited or per-requester-limited attempts on the linking endpoint.
- Server-side versus client-side enforcement. Replay the request directly, bypassing any client that hides or disables the form after failures. A positive result is the server continuing to process attempts after the client-side limit is reached.
What happened, in plain words
Facebook Pages let the people who run them (admins and editors) attach an Instagram account. Once attached, the page can create Instagram ads in Ads Manager without first connecting that Instagram account to a Business Manager. There is an endpoint to connect an Instagram account through the mobile browser at mbasic.facebook.com, and it accepts the Instagram username and password.
That screen is what this report is about. It accepted password submissions for an Instagram account, and the protection Facebook uses to stop people guessing passwords could be worked around.
To follow the rest, you need three ideas:
- A rate limit is a cap on how often you can do something in a period of time. Think of a cash machine that lets you try your card three times and then keeps the card. The point is to make guessing slow and expensive.
- A brute-force attack is guessing a password by trying many possibilities, one after another, until one works. It only works if the system lets you keep trying.
- A test user is a throwaway account that Facebook lets developers create for testing their apps. It behaves like a normal account for the purpose of making requests.
The bug was that the cap was counted per Facebook account doing the guessing, not per Instagram account being guessed at. So each new Facebook account arrived with a fresh allowance of 20 tries against the same victim. Because test users can be created in bulk, the researcher could multiply that allowance into millions of tries per day.
Setup
The request that performs the connection carries the Instagram credentials together with the attacker's page identifier:
- A Facebook Page where they had an admin or editor role. This is the attacker-controlled page: the page the victim's Instagram account would be attached to if a guess succeeded.
- A way to send many login attempts without being tied to a single Facebook account, because the limit was per Facebook account.
Line by line:
POST /Redacted HTTP/1.1is the request line.POSTmeans "here is some data for you to process", as opposed toGET, which just asks for a page. The path is redacted in the published report, so we do not know the exact address.HTTP/1.1is the version of the web protocol being spoken.Host: mbasic.facebook.comsays which website the request is for.mbasic.facebook.comis the lightweight mobile version of Facebook.fb_dtsgandjazoestare shown as sanitised in the published request. A token here is a short value the site gives your browser and expects back with each action, so the site can tell that the request came from a real page it served rather than from some other site. CSRF (cross-site request forgery) is an attack where another website tricks your browser into sending an action to a site you are logged into; the token is the defence. Sanitised means the real value was removed before publishing, so nobody can reuse it.usernameandpasswordare the victim's Instagram credentials. These are the values being guessed.page_ididentifies the page the Instagram account would be attached to. It is the attacker's page.
For volume, the researcher used Facebook's test users. Facebook documents that each Facebook application can create up to 2000 test accounts, the same kind of account that can be created through /whitehat/accounts/. The reference given is https://developers.facebook.com/docs/apps/test-users/.
Finding it
Facebook protects the login request with a rate-limiting mechanism against password guessing. In the researcher's testing, only a maximum of 20 wrong passwords could be attempted in a day. Exceeding 20 attempts produced a "too many requests" response, and further requests were blocked.
That is the cash-machine behaviour described above: after a small number of wrong tries, the door shuts. The question is what the door is attached to.
The problem was where that limit was applied. At this endpoint, Facebook failed to block attempts against the victim account on the server side. The limit of 20 requests was enforced per Facebook account, not per targeted Instagram account.
Server side means the check happens on Facebook's computers, where the request actually lands, rather than in the browser. A check done only in the browser can be skipped by anyone who sends the request directly. Here the check was on the server, but it was counting the wrong thing: it counted the requester, not the target.
Exploitation
Step 1: Confirm the per-account limit
Submitting wrong passwords for the Instagram account from one Facebook account allowed a maximum of 20 attempts in a day. Exceeding 20 produced "too many requests" and further requests were blocked. This established the unit the limit was counted in: one Facebook account, 20 tries.
This step matters because you cannot claim a bypass until you know exactly what the normal limit is and what triggers it. The researcher first measured the wall, then looked for a way around it.
Step 2: Multiply attempts across Facebook accounts
The arithmetic follows directly from the per-account enforcement:
- 1 Facebook account = 20 wrong password attempts.
- 10 Facebook accounts = 200 wrong password attempts.
If the wall is per requester, then more requesters means more total tries against the same victim. At this point the researcher did not have a large pool of user accounts to draw on, so the next problem was supply.
Step 3: Use test users to obtain accounts at scale
Facebook allows test accounts to be created for Facebook applications, up to 2000 per application. The researcher created around 15 Facebook applications:
- 15 apps x 2000 test accounts = 30,000 test users under a single Facebook user account.
- 10 regular Facebook user accounts were created.
- 10 x 30,000 = 300,000 test users in total.
A Facebook application here is a developer registration on Facebook's platform, the kind of thing you create when you build an app that uses Facebook login or Facebook data. Each application is allowed a batch of test users. The researcher used that legitimate feature as a source of many independent identities, each of which would get its own 20 tries.
Step 4: Calculate the resulting attempt rate
With 300,000 identities each entitled to 20 attempts per day, the researcher could attempt 6,000,000 passwords daily against the victim's Instagram account.
That number is the point of the report. A limit that looks reasonable per person becomes meaningless when one person can hold hundreds of thousands of identities.
Root cause
The rate limit on this endpoint was keyed to the Facebook account making the request rather than to the Instagram account being targeted. The server therefore never saw the aggregate volume of guesses against one victim: each new Facebook identity, including test users belonging to applications, arrived with a fresh allowance of 20 attempts. Because test users can be generated in bulk per application, the per-account limit provided no meaningful ceiling on guesses against a single Instagram account.
In plain terms: the guard was counting how many times each visitor knocked, not how many times the same door had been knocked on. A crowd of visitors, each knocking 20 times, is the same as one visitor knocking 6,000,000 times.
Impact
An attacker holding an admin or editor role on a Facebook Page could run a sustained online password-guessing attack against an Instagram account through mbasic.facebook.com, using test users to reset the per-account allowance. The researcher calculated a capacity for 6,000,000 attempts per day. Whether any given account could actually be compromised depends on the strength of its password, which the report does not quantify.
Online here means the guesses go to the real login system, one request at a time, as opposed to an offline attack where someone has stolen a copy of the password database and can guess at leisure on their own machine. Online guessing is normally slow, which is exactly why rate limits exist.
Fix
Facebook marked the issue as fixed on 8 November 2018, and a bounty was awarded on 14 November 2018. The report does not describe the change that was made.
In other words: count the knocks on the door, not the knocks per visitor.
Timeline
| Date | Event |
|---|---|
| Sep 21, 2018 | Report sent |
| Sep 25, 2018 | Clarification requested by Facebook |
| Sep 26, 2018 | Clarification sent |
| Oct 3, 2018 | Triaged |
| Oct 3, 2018 | Closed as informative (impact is minimal) |
| Oct 4, 2018 | More details sent |
| Oct 8, 2018 | Triaged |
| Oct 26, 2018 | Asked for updates |
| Nov 8, 2018 | Fixed |
| Nov 14, 2018 | Bounty awarded |
Triaged means the security team accepted the report into its queue and began assessing it. The report was first closed as informative with the note that impact was minimal; after more details were sent it was triaged again. That is common: the first reader may not see the scale until the arithmetic is spelled out.
Variants to test
These are the same ideas applied to other places, for anyone who wants to look for similar bugs.
- Per-identity limits on credential endpoints. Submit wrong credentials for the same victim from several accounts and watch whether the block follows the victim or the requester. A positive result is the victim being locked out or throttled across identities.
- Bulk-provisioned identities. Where a platform lets one user create many sub-accounts, test users or API clients, check whether each one receives an independent attempt allowance against the same target. A positive result is the total attempt count scaling with the number of provisioned identities.
- Account-linking flows. Features that attach a third-party account (social, ad or commerce integrations) often accept external credentials on a separate endpoint from the main login. Test whether that endpoint applies the same lockout as the primary login. A positive result is unlimited or per-requester-limited attempts on the linking endpoint.
- Server-side versus client-side enforcement. Replay the request directly, bypassing any client that hides or disables the form after failures. A positive result is the server continuing to process attempts after the client-side limit is reached.
An endpoint is a specific address on a server that accepts a particular kind of request, like a service window in a building: each window handles one kind of business. Replay means sending a captured request again yourself, outside the normal page, to see what the server does when the browser's guard rails are not there.
Glossary
- API: a defined way for one piece of software to talk to another, like a service counter with set forms to fill in.
- Brute force: guessing a secret by trying many possibilities in sequence until one works.
- Bounty: a payment a company makes to someone who reports a security problem to it.
- CSRF (cross-site request forgery): an attack where another website causes your browser to send an action to a site you are logged into; anti-CSRF tokens are the defence.
- Endpoint: a specific address on a server that accepts a particular kind of request.
- Facebook application: a developer registration on Facebook's platform, used to build apps that rely on Facebook; each can create test users.
- fb_dtsg / jazoest: Facebook's anti-CSRF token fields, sanitised in the published request.
- Fix: the change a company makes so the reported problem no longer works.
- Host: the part of a request that names which website it is for.
- HTTP: the language browsers and servers use to exchange requests and responses.
- Impact: what an attacker could actually achieve if the bug were used.
- Informative: a report status meaning the company decided the issue did not qualify, often because the impact was judged too small.
- mbasic.facebook.com: the lightweight mobile version of Facebook.
- Offline attack: guessing passwords against a stolen copy of a database on your own machine, without touching the real service.
- Online attack: guessing passwords by sending requests to the real login system.
- Per-account limit: a cap counted separately for each account making requests.
- POST: an HTTP method that sends data to the server to be processed.
- Rate limiting: a cap on how many actions can be performed in a period of time.
- Replay: sending a captured request again yourself, outside the normal page.
- Sanitised: with secrets or personal data removed before publishing.
- Server side: a check performed on the company's computers rather than in the browser.
- Test user: a throwaway account Facebook lets developers create for testing applications.
- Token: a short value a site gives your browser and expects back with an action, used to prove the request came from a page the site served.
- Triaged: accepted by the security team into its queue for assessment.
- Username: the name that identifies an account at login.