InstaBrute: Two Ways to Brute-force Instagram Account Credentials
Instagram's mobile login endpoint had a rate-limiting bug that made every other password guess unreliable, but an attacker could replay those guesses to get a reliable answer, allowing brute-force attacks. The web registration endpoint also acted as a credentials oracle, returning different responses for correct and incorrect passwords, enabling further brute-force attacks.
Published on arneswinnen.net
Authentication brute-force vulnerabilities are very serious issues for any web application. Users are known to pick weak passwords and reuse them and many dictionaries with millions of human-chosen passwords are publicly available to attackers to easily mount successful attacks.
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
Instagram's authentication surface at the time of this research had two distinct entry points: the mobile API used by the Instagram for Android application, and a newer web registration flow. The mobile application authenticated against the endpoint at https://i.instagram.com/api/v1/accounts/login/. The web registration flow had recently been introduced, allowing account creation via the website rather than only through the mobile applications.
Several properties of the platform made brute-force attacks against these flows particularly attractive:
- User Enumeration: Instagram usernames are public and enumerable via incremental userIDs, for example
https://i.instagram.com/api/v1/users/3/info/andhttps://i.instagram.com/api/v1/users/4/info/. - Weak Password Policy: at the time of submission, the password policy only enforced a minimum length of 6 characters, allowing choices such as "123456" and "password".
- Two-Factor Authentication: 2FA had only been introduced in February 2016 and was still not rolled out globally.
- Account Lockout Policy: no account lockout policy was in place, nor any other mitigating security controls.
Combined, these issues could have allowed an attacker to compromise many of the 400+ million active accounts, especially those with predictable passwords. Targeted attacks against high-profile (celebrity) accounts could have been very effective as well.
Setup
For Issue #1, the mobile authentication endpoint had to be reached through the Instagram for Android application. Two out-of-scope obstacles had to be dealt with first:
- SSL Pinning had to be bypassed in the Android application in order to identify the mobile authentication endpoint communication in an intercepting proxy.
- A key had to be phished from the Android application. That key is used to generate a HMACSHA256 signature over the POST parameters of every outgoing request. A Burp plugin was written that transparently hotpatches the signature for outgoing requests, including those generated by the Burp Intruder module.
A test account named bruteforceme with password perfectcrime was used for the mobile attack. A quick and dirty Python script with basic threading support, InstaBrutal.py, was written to prove the vulnerability, driven by a dictionary of 10000 popular passwords.
For Issue #2, a test account arneswinnen8168 with password passwd was registered through the website, and the underlying registration request and response were captured.
Finding it
Issue #1: rate limiting that can be reasoned around
A simple brute-force attack against the mobile authentication endpoint with Burp Intruder revealed that approximately 1000 reliable guesses could be made from one unique IP address, after which the response changed to "username not found", although the user obviously still existed. This looked like rate limiting.

However, only the next consecutive 1000 guesses resulted in the "username not found" response error message. From the 2000th consecutive guess onward, a reliable response (password correct/incorrect) was followed by an unreliable one (user not found).

That pattern is what made the issue exploitable: an attacker could reason on the reliable response messages and simply replay the unreliable ones until a reliable answer was received. The only limitation was that, on average, 2 authentication requests had to be made for one reliable password guess attempt.
Issue #2: a credentials oracle in web registration
Registering the test account arneswinnen8168 with password passwd issued an underlying request and response.



By simply replaying this exact request, a different response message was now encountered.

After removing all parameters in the request except username and password, the replay of a request with a correct password value and one of an incorrect password value highlighted the credentials oracle.


Exploitation
Step 1: brute-force the mobile authentication endpoint
The InstaBrutal.py script was run against the test account with the 10k most common passwords dictionary. The tail of the dictionary and the script output were as follows:
# tail -f 10k_most_common.txt
hoes
howie
hevnm4
hugohugo
epson
evangeli
eeeee1
eyphed
perfectcrime
# python instabrutal.py
[INFO] Usage: python instabrutal.py <INSTAGRAM_USERNAME> <DICTIONARY_FILENAME> <THREADS> [DEBUG]
# python instabrutal.py bruteforceme 10k_most_common.txt 50
[INFO] Creating 50 worker threads...
[INFO] Total # passwords: 10001
[INFO] Total # threads: 50
147.20 pw/s [=] 7% (736/10001) (Good:686 Bad:0 Error:0)
105.00 pw/s [==] 10% (1050/10001) (Good:1000 Bad:272 Error:0)
70.00 pw/s [==] 10% (1050/10001) (Good:1000 Bad:706 Error:0)
55.00 pw/s [==] 10% (1100/10001) (Good:1050 Bad:1028 Error:0)
50.84 pw/s [==] 12% (1271/10001) (Good:1221 Bad:1218 Error:0)
50.60 pw/s [===] 15% (1518/10001) (Good:1468 Bad:1453 Error:0)
49.94 pw/s [===] 17% (1748/10001) (Good:1698 Bad:1696 Error:0)
49.50 pw/s [===] 19% (1980/10001) (Good:1930 Bad:1913 Error:0)
48.56 pw/s [====] 21% (2185/10001) (Good:2135 Bad:2132 Error:0)
48.18 pw/s [====] 24% (2409/10001) (Good:2359 Bad:2353 Error:0)
48.20 pw/s [=====] 26% (2651/10001) (Good:2601 Bad:2593 Error:0)
48.02 pw/s [=====] 28% (2881/10001) (Good:2831 Bad:2825 Error:0)
46.57 pw/s [======] 30% (3027/10001) (Good:2977 Bad:2973 Error:0)
46.96 pw/s [======] 32% (3287/10001) (Good:3237 Bad:3234 Error:0)
46.72 pw/s [=======] 35% (3504/10001) (Good:3466 Bad:3427 Error:0)
46.38 pw/s [=======] 37% (3710/10001) (Good:3660 Bad:3658 Error:0)
46.61 pw/s [=======] 39% (3962/10001) (Good:3912 Bad:3910 Error:0)
46.58 pw/s [========] 41% (4192/10001) (Good:4142 Bad:4130 Error:0)
45.88 pw/s [========] 43% (4359/10001) (Good:4309 Bad:4303 Error:0)
46.25 pw/s [=========] 46% (4625/10001) (Good:4575 Bad:4573 Error:0)
46.47 pw/s [=========] 48% (4879/10001) (Good:4829 Bad:4823 Error:0)
45.84 pw/s [==========] 50% (5042/10001) (Good:4992 Bad:4990 Error:0)
45.95 pw/s [==========] 52% (5284/10001) (Good:5234 Bad:5229 Error:0)
45.93 pw/s [===========] 55% (5512/10001) (Good:5462 Bad:5455 Error:0)
45.97 pw/s [===========] 57% (5746/10001) (Good:5696 Bad:5693 Error:0)
45.55 pw/s [===========] 59% (5921/10001) (Good:5871 Bad:5870 Error:0)
45.70 pw/s [============] 61% (6169/10001) (Good:6119 Bad:6115 Error:0)
45.84 pw/s [============] 64% (6418/10001) (Good:6368 Bad:6355 Error:0)
45.86 pw/s [=============] 66% (6649/10001) (Good:6599 Bad:6594 Error:0)
45.81 pw/s [=============] 68% (6872/10001) (Good:6822 Bad:6812 Error:0)
45.32 pw/s [==============] 70% (7025/10001) (Good:6975 Bad:6973 Error:0)
45.63 pw/s [==============] 73% (7301/10001) (Good:7251 Bad:7247 Error:0)
45.63 pw/s [===============] 75% (7529/10001) (Good:7479 Bad:7463 Error:0)
45.56 pw/s [===============] 77% (7746/10001) (Good:7696 Bad:7680 Error:0)
45.17 pw/s [===============] 79% (7905/10001) (Good:7855 Bad:7839 Error:0)
45.54 pw/s [================] 81% (8197/10001) (Good:8147 Bad:8134 Error:0)
45.36 pw/s [================] 83% (8392/10001) (Good:8342 Bad:8342 Error:0)
45.26 pw/s [=================] 85% (8599/10001) (Good:8549 Bad:8547 Error:0)
45.43 pw/s [=================] 88% (8858/10001) (Good:8807 Bad:8801 Error:0)
45.49 pw/s [==================] 90% (9098/10001) (Good:9047 Bad:9037 Error:0)
45.31 pw/s [==================] 92% (9289/10001) (Good:9238 Bad:9224 Error:0)
45.24 pw/s [===================] 95% (9501/10001) (Good:9450 Bad:9441 Error:0)
45.41 pw/s [===================] 97% (9763/10001) (Good:9712 Bad:9711 Error:0)
45.37 pw/s [===================] 99% (9982/10001) (Good:9931 Bad:9924 Error:0)
[SUCCESS] Found the right password: perfectcrime
44.45 pw/s [====================] 100% (10001/10001) (Good:9999 Bad:9992 Error:0)
[End] Total time: 227 seconds |
The first 1000 guesses were reliable ("good") guesses, followed by 1000 unreliable ones ("bad"), which were ignored by the Python script. Hereafter, the ratio remained closely around 50%. The numbers are slightly off due to lack of thread locks around the global variables storing them, as the purpose of the quick and dirty script was simply to prove the underlying vulnerability.
Step 2: log in from the attacking IP
Although the script made 10001 password guesses for the account bruteforceme, an attacker could simply log in from any IP address, including the one that was used to mount the brute-force attack. This indicated a lack of additional security controls against account compromise, such as account lockout, IP address location-based fraud detection, and similar measures.


Step 3: replay the web registration request
Registering the test account arneswinnen8168 with password passwd issued the underlying request and response shown above. Replaying this exact request produced a different response message.

Step 4: reduce the request to a credentials oracle


Step 5: brute-force the registration endpoint
A Burp Intruder brute-force attack of 10001 passwords, with the 10001th entry being the correct password passwd, confirmed the trivial brute-force attack.


Step 6: log in with the harvested credentials
Logging in with the harvested credentials again worked. No account lockout or other security controls were triggered during the successful brute-force attack.


Root cause
Issue #1 was an implementation bug in the mobile authentication brute-force protection, which produced a predictable pattern of reliable and unreliable responses. After roughly 1000 reliable guesses, the endpoint returned "username not found" for the next 1000 guesses, and from the 2000th consecutive guess onward it alternated between a reliable response (password correct/incorrect) and an unreliable one (user not found). Because the unreliable responses could be replayed until a reliable answer came back, the protection could be reasoned around at the cost of roughly two requests per reliable guess.
Issue #2 was a credentials oracle in the web registration endpoint. Replaying the registration request, and then reducing it to only username and password, produced responses that distinguished a correct password from an incorrect one. That turned the registration endpoint into a password-checking oracle that could be driven with Burp Intruder.
For Issue #1, the absence of account lockout, IP address location-based fraud detection and other mitigating controls meant a successful brute-force did not prevent subsequent login with the harvested credentials.
Impact
Exploitation of these issues could have resulted in the compromise of millions of the 400+ million active Instagram accounts, especially those with predictable passwords. The effectiveness depended on the weak password policy (minimum length of 6 characters, allowing choices such as "123456" and "password"), public and enumerable usernames, incomplete 2FA rollout, and the absence of account lockout or other mitigating controls.
Fix
Facebook applied the following mitigations:
- Issue #1 was resolved by fixing the rate-limiting bug in the mobile authentication endpoint.
- Issue #2 was resolved by introducing rate-limiting on the web registration endpoint.
- The password policy was slightly hardened, and extremely easy passwords such as "123456" and "password" are no longer allowed.
The fix for Issue #2 was not effective at first: Facebook was informed on 04/04/2016, reconfirmed a new fix on 10/05/2016, and the new fix was deemed working on 19/05/2016, when the issue was publicly disclosed.
Timeline
- 28/12/2015: Submitted bug report for issue #1 to Facebook Bug Bounty, including PoC python script.
- 08/02/2016: Submitted bug report for issue #2 to Facebook Bug Bounty.
- 11/02/2016: Facebook confirmed that issue #2 is patched.
- 13/02/2016: Facebook confirmed that issue #1 was patched earlier as well and granted a combined bounty of $5.000.
- 04/04/2016: Informed Facebook that fix for issue #2 is not effective.
- 10/05/2016: Facebook reconfirmed new fix for issue #2.
- 19/05/2016: New fix deemed working, public disclosure.
Variants to test
- Rate-limit pattern probing on login endpoints. Send a long series of authentication attempts from one IP and record the response for each. A positive result is a repeating pattern where unreliable responses (such as "user not found") can be replayed until a reliable correct/incorrect answer is returned, meaning the limit can be reasoned around.
- Registration endpoint as a credentials oracle. Register an account, capture the registration request, replay it, then strip all parameters except the username and password. A positive result is a response that differs between a correct and an incorrect password for an existing account.
- Post-brute-force login from the attacking IP. After a successful brute-force, log in with the harvested credentials from the same IP used for the attack. A positive result is a successful login with no lockout or fraud challenge.
- Username enumeration via incremental identifiers. Request public user information for sequential userIDs, as with
https://i.instagram.com/api/v1/users/3/info/andhttps://i.instagram.com/api/v1/users/4/info/. A positive result is a resolvable, enumerable mapping between identifiers and usernames. - Password policy probing. Attempt to set extremely easy passwords such as "123456" and "password" during registration or password change. A positive result is acceptance of a password that should be rejected by a hardened policy.
What happened, in plain words
Instagram had two separate weaknesses that each allowed someone to guess the password of an account over and over until they found it. This kind of guessing is called a brute-force attack: instead of being clever, you simply try a huge list of likely passwords, one after another, until one works. It is the same idea as trying every key on a keyring in a door until one turns.
Normally a website defends against this by slowing you down or locking the account after a few wrong tries. Instagram did not do that effectively at the mobile login endpoint, and its web registration endpoint leaked whether a password was correct. The researcher, Arne Swinnen, found both, Facebook fixed both, and paid a combined bounty of $5,000.
Before the details, a few words that come up constantly:
- An endpoint is a specific address on a server that accepts a particular kind of request, like a service counter in a large building.
https://i.instagram.com/api/v1/accounts/login/is the counter where the mobile app asks "is this username and password correct?". - An API (Application Programming Interface) is the set of those counters that a program, rather than a person clicking in a browser, talks to. The Instagram mobile app is a program, so it talks to Instagram's API.
- A request is the message your app or browser sends ("here is a username and password, please check it"). A response is the message that comes back ("wrong password" or "welcome").
- Rate limiting is a server's way of saying "too many requests from you, slow down". It is like a bouncer who lets you ask a question only so many times per minute.
- Account lockout is a stronger version: after too many wrong passwords, the account is frozen for a while, even for the real owner.
- User enumeration means being able to work out which usernames exist on a site. If you can tell "this user exists" from "this user does not", you can build a list of real targets.
- 2FA (two-factor authentication) means a password alone is not enough; you also need a second proof, such as a code from your phone.
Why Instagram was an attractive target
The report lists four reasons why guessing passwords was especially worthwhile against Instagram at that time:
- User Enumeration: Instagram usernames are public and can be enumerated via incremental userIDs, for example
https://i.instagram.com/api/v1/users/3/info/andhttps://i.instagram.com/api/v1/users/4/info/. In plain terms, the numbers at the end of those addresses are user identifiers, and they run in sequence. The report says Instagram usernames are public and enumerable via incremental userIDs. - Weak Password Policy: at the time of submission, the password policy only enforced a minimum length of 6 characters, allowing choices such as "123456" and "password". A password policy is the rulebook the site applies when you choose a password. Six characters with no other rule is very little.
- Two-Factor Authentication: 2FA had only been introduced in February 2016 and was still not rolled out globally. So for many accounts, the password was the only lock on the door.
- Account Lockout Policy: no account lockout policy was in place, nor any other mitigating security controls. Nothing stopped an attacker from trying again and again.
Put together, these issues could have allowed an attacker to compromise many of the 400+ million active accounts, especially those with predictable passwords. Targeted attacks against high-profile (celebrity) accounts could have been very effective as well.
Setting up the test
For Issue #1, the mobile authentication endpoint had to be reached through the Instagram for Android application. That is because the app, not the website, was the thing talking to that endpoint. Two obstacles had to be dealt with first, and the report marks both as out of scope, meaning they were not themselves the bug being reported:
- SSL Pinning had to be bypassed in the Android application in order to identify the mobile authentication endpoint communication in an intercepting proxy. SSL pinning is a technique where an app refuses to trust any certificate except the one it expects, which stops a tool sitting between the app and the server from reading the traffic. An intercepting proxy is exactly that tool: software on your computer that the app's traffic is routed through so you can read and edit it. Bypassing pinning is like removing a tamper seal so you can open the parcel and look inside.
- A key had to be phished from the Android application. That key is used to generate a HMACSHA256 signature over the POST parameters of every outgoing request. A signature here is a short code computed from the contents of the request plus a secret key, so the server can check the request really came from the official app and was not altered on the way. HMACSHA256 is simply the name of one well-known recipe for computing such a code. POST parameters are the fields of data sent with the request, such as the username and password. If you change a field, the signature no longer matches, so the server rejects the request. To send thousands of guesses, the researcher wrote a Burp plugin that transparently hotpatches the signature for outgoing requests, including those generated by the Burp Intruder module. Burp is a tool for inspecting and modifying web traffic; Intruder is its component for sending the same request many times with one part changed each time, which is exactly what password guessing needs. "Hotpatching" means recalculating the signature on the fly so each modified request still looks valid.
A test account named bruteforceme with password perfectcrime was used for the mobile attack. A quick and dirty Python script with basic threading support, InstaBrutal.py, was written to prove the vulnerability, driven by a dictionary of 10000 popular passwords. A dictionary in this context is just a text file with one candidate password per line, usually taken from lists of passwords that have leaked in the past and are known to be common. Threading means the script sends several requests at the same time instead of waiting for each one to finish, like using several checkout lanes at once.
For Issue #2, a test account arneswinnen8168 with password passwd was registered through the website, and the underlying registration request and response were captured. "Captured" means recorded in the intercepting proxy so they could be looked at and sent again later.
Finding it
Issue #1: rate limiting that can be reasoned around
A simple brute-force attack against the mobile authentication endpoint with Burp Intruder revealed that approximately 1000 reliable guesses could be made from one unique IP address, after which the response changed to "username not found", although the user obviously still existed. This looked like rate limiting. An IP address is the numeric label your internet connection has, roughly like a return address on an envelope; a site can use it to recognise "the same visitor again".

After about a thousand guesses from one address, the response changed to "username not found" although the user still existed.
However, only the next consecutive 1000 guesses resulted in the "username not found" response error message. From the 2000th consecutive guess onward, a reliable response (password correct/incorrect) was followed by an unreliable one (user not found).

From the 2000th consecutive guess onward, a reliable response was followed by an unreliable one.
That pattern is what made the issue exploitable: an attacker could reason on the reliable response messages and simply replay the unreliable ones until a reliable answer was received. Replaying means sending the very same request again. So when the server said "user not found", the attacker did not believe it; they sent the same guess again and, following the pattern, got a real answer the second time. The only limitation was that, on average, 2 authentication requests had to be made for one reliable password guess attempt. In other words, the protection doubled the work but did not stop it.
Issue #2: a credentials oracle in web registration
An oracle in security means any behaviour of a system that leaks a secret answer. Here the secret is "is this password correct for this account?". If the server's reply differs depending on whether the password is right, the server is answering that question for you, one guess at a time.
Registering the test account arneswinnen8168 with password passwd issued an underlying request and response. The word "underlying" matters: when you fill in a form on a website, your browser sends a request behind the scenes. That request is what was captured.



Registering the test account issued an underlying request and response.
By simply replaying this exact request, a different response message was now encountered.

After removing all parameters in the request except username and password, the replay of a request with a correct password value and one of an incorrect password value highlighted the credentials oracle. Stripping the request down to just those two fields is a way of isolating the cause: if the answer still changes with only the username and password present, then those two fields are what the server is judging.


The replay with a correct password value and one with an incorrect value highlighted the credentials oracle.
Exploitation
Step 1: brute-force the mobile authentication endpoint
The InstaBrutal.py script was run against the test account with the 10k most common passwords dictionary. The tail of the dictionary and the script output were as follows:
# tail -f 10k_most_common.txt
hoes
howie
hevnm4
hugohugo
epson
evangeli
eeeee1
eyphed
perfectcrime
# python instabrutal.py
[INFO] Usage: python instabrutal.py <INSTAGRAM_USERNAME> <DICTIONARY_FILENAME> <THREADS> [DEBUG]
# python instabrutal.py bruteforceme 10k_most_common.txt 50
[INFO] Creating 50 worker threads...
[INFO] Total # passwords: 10001
[INFO] Total # threads: 50
147.20 pw/s [=] 7% (736/10001) (Good:686 Bad:0 Error:0)
105.00 pw/s [==] 10% (1050/10001) (Good:1000 Bad:272 Error:0)
70.00 pw/s [==] 10% (1050/10001) (Good:1000 Bad:706 Error:0)
55.00 pw/s [==] 10% (1100/10001) (Good:1050 Bad:1028 Error:0)
50.84 pw/s [==] 12% (1271/10001) (Good:1221 Bad:1218 Error:0)
50.60 pw/s [===] 15% (1518/10001) (Good:1468 Bad:1453 Error:0)
49.94 pw/s [===] 17% (1748/10001) (Good:1698 Bad:1696 Error:0)
49.50 pw/s [===] 19% (1980/10001) (Good:1930 Bad:1913 Error:0)
48.56 pw/s [====] 21% (2185/10001) (Good:2135 Bad:2132 Error:0)
48.18 pw/s [====] 24% (2409/10001) (Good:2359 Bad:2353 Error:0)
48.20 pw/s [=====] 26% (2651/10001) (Good:2601 Bad:2593 Error:0)
48.02 pw/s [=====] 28% (2881/10001) (Good:2831 Bad:2825 Error:0)
46.57 pw/s [======] 30% (3027/10001) (Good:2977 Bad:2973 Error:0)
46.96 pw/s [======] 32% (3287/10001) (Good:3237 Bad:3234 Error:0)
46.72 pw/s [=======] 35% (3504/10001) (Good:3466 Bad:3427 Error:0)
46.38 pw/s [=======] 37% (3710/10001) (Good:3660 Bad:3658 Error:0)
46.61 pw/s [=======] 39% (3962/10001) (Good:3912 Bad:3910 Error:0)
46.58 pw/s [========] 41% (4192/10001) (Good:4142 Bad:4130 Error:0)
45.88 pw/s [========] 43% (4359/10001) (Good:4309 Bad:4303 Error:0)
46.25 pw/s [=========] 46% (4625/10001) (Good:4575 Bad:4573 Error:0)
46.47 pw/s [=========] 48% (4879/10001) (Good:4829 Bad:4823 Error:0)
45.84 pw/s [==========] 50% (5042/10001) (Good:4992 Bad:4990 Error:0)
45.95 pw/s [==========] 52% (5284/10001) (Good:5234 Bad:5229 Error:0)
45.93 pw/s [===========] 55% (5512/10001) (Good:5462 Bad:5455 Error:0)
45.97 pw/s [===========] 57% (5746/10001) (Good:5696 Bad:5693 Error:0)
45.55 pw/s [===========] 59% (5921/10001) (Good:5871 Bad:5870 Error:0)
45.70 pw/s [============] 61% (6169/10001) (Good:6119 Bad:6115 Error:0)
45.84 pw/s [============] 64% (6418/10001) (Good:6368 Bad:6355 Error:0)
45.86 pw/s [=============] 66% (6649/10001) (Good:6599 Bad:6594 Error:0)
45.81 pw/s [=============] 68% (6872/10001) (Good:6822 Bad:6812 Error:0)
45.32 pw/s [==============] 70% (7025/10001) (Good:6975 Bad:6973 Error:0)
45.63 pw/s [==============] 73% (7301/10001) (Good:7251 Bad:7247 Error:0)
45.63 pw/s [===============] 75% (7529/10001) (Good:7479 Bad:7463 Error:0)
45.56 pw/s [===============] 77% (7746/10001) (Good:7696 Bad:7680 Error:0)
45.17 pw/s [===============] 79% (7905/10001) (Good:7855 Bad:7839 Error:0)
45.54 pw/s [================] 81% (8197/10001) (Good:8147 Bad:8134 Error:0)
45.36 pw/s [================] 83% (8392/10001) (Good:8342 Bad:8342 Error:0)
45.26 pw/s [=================] 85% (8599/10001) (Good:8549 Bad:8547 Error:0)
45.43 pw/s [=================] 88% (8858/10001) (Good:8807 Bad:8801 Error:0)
45.49 pw/s [==================] 90% (9098/10001) (Good:9047 Bad:9037 Error:0)
45.31 pw/s [==================] 92% (9289/10001) (Good:9238 Bad:9224 Error:0)
45.24 pw/s [===================] 95% (9501/10001) (Good:9450 Bad:9441 Error:0)
45.41 pw/s [===================] 97% (9763/10001) (Good:9712 Bad:9711 Error:0)
45.37 pw/s [===================] 99% (9982/10001) (Good:9931 Bad:9924 Error:0)
[SUCCESS] Found the right password: perfectcrime
44.45 pw/s [====================] 100% (10001/10001) (Good:9999 Bad:9992 Error:0)
[End] Total time: 227 seconds |
What each part of that output means, line by line in plain words:
# tail -f 10k_most_common.txtshows the end of the password list file. The script eventually reported the right password, perfectcrime.# python instabrutal.pywith no arguments prints the usage line, telling you the script wants a username, a dictionary file, a number of threads, and optionally a debug flag.# python instabrutal.py bruteforceme 10k_most_common.txt 50is the real run: guess passwords for the accountbruteforceme, using the file10k_most_common.txt, with 50 threads working in parallel.[INFO] Creating 50 worker threads...means 50 parallel workers were started, each sending guesses.[INFO] Total # passwords: 10001is the size of the list. The file is called 10k but holds 10001 entries.[INFO] Total # threads: 50repeats the parallelism setting.- Each progress line has the same shape.
147.20 pw/sis the speed in passwords per second.[=]and the growing row of=is a progress bar.7% (736/10001)means 736 of 10001 guesses have been handled.Good:686counts guesses that got a trustworthy answer,Bad:0counts guesses whose answer was the misleading "user not found", andError:0counts requests that failed outright. - Watching the
GoodandBadcounters tells the story: the first 1000 guesses are reliable ("good"), then 1000 unreliable ones ("bad") appear, and after that the two counters grow together at roughly the same rate, so the ratio stays close to 50%. [SUCCESS] Found the right password: perfectcrimeis the script reporting the password it found.[End] Total time: 227 seconds |is the total run time.
The first 1000 guesses were reliable ("good") guesses, followed by 1000 unreliable ones ("bad"), which were ignored by the Python script. Hereafter, the ratio remained closely around 50%. The numbers are slightly off due to lack of thread locks around the global variables storing them, as the purpose of the quick and dirty script was simply to prove the underlying vulnerability. A thread lock is a small guard that stops two parallel workers from updating the same counter at the same moment; without it, counts can drift slightly. That inaccuracy did not matter, because the point was to show the weakness existed, not to produce a polished tool.
Step 2: log in from the attacking IP
Although the script made 10001 password guesses for the account bruteforceme, an attacker could simply log in from any IP address, including the one that was used to mount the brute-force attack. This indicated a lack of additional security controls against account compromise, such as account lockout, IP address location-based fraud detection, and similar measures. Location-based fraud detection means noticing that a login comes from an unusual place or network and asking for extra proof. None of that happened here.


These two screenshots relate to logging in with the guessed password after the brute-force attack.
Step 3: replay the web registration request
Registering the test account arneswinnen8168 with password passwd issued the underlying request and response shown above. Replaying this exact request produced a different response message.

Step 4: reduce the request to a credentials oracle


Step 5: brute-force the registration endpoint
A Burp Intruder brute-force attack of 10001 passwords, with the 10001th entry being the correct password passwd, confirmed the trivial brute-force attack. "Trivial" here means it needed no special trick beyond sending the list: the endpoint simply answered each guess.


The brute-force run of 10001 passwords ended with the correct password passwd as the 10001th entry.
Step 6: log in with the harvested credentials
Logging in with the harvested credentials again worked. No account lockout or other security controls were triggered during the successful brute-force attack. "Harvested" simply means the credentials obtained from the guessing run.


Root cause
Issue #1 was an implementation bug in the mobile authentication brute-force protection. The rate limiting did not block guessing; it only made the response unreliable in a predictable pattern. After roughly 1000 reliable guesses, the endpoint returned "username not found" for the next 1000 guesses, and from the 2000th consecutive guess onward it alternated between a reliable response (password correct/incorrect) and an unreliable one (user not found). Because the unreliable responses could be replayed until a reliable answer came back, the protection could be reasoned around at the cost of roughly two requests per reliable guess. A protection that can be predicted is not much of a protection: it is like a guard who always looks away on every second visitor.
Issue #2 was a credentials oracle in the web registration endpoint. Replaying the registration request, and then reducing it to only username and password, produced responses that distinguished a correct password from an incorrect one. That turned the registration endpoint into a password-checking oracle that could be driven with Burp Intruder. A registration form should create accounts; it should never be usable as a password-checking machine.
For Issue #1, the absence of account lockout, IP address location-based fraud detection and other mitigating controls meant a successful brute-force did not prevent subsequent login with the harvested credentials.
Impact
Exploitation of these issues could have resulted in the compromise of millions of the 400+ million active Instagram accounts, especially those with predictable passwords. The attacks required no user interaction: the account owner did not have to click anything or be tricked. The effectiveness depended on the weak password policy (minimum length of 6 characters, allowing choices such as "123456" and "password"), public and enumerable usernames, incomplete 2FA rollout, and the absence of account lockout or other mitigating controls.
Fix
Facebook applied the following mitigations:
- Issue #1 was resolved by fixing the rate-limiting bug in the mobile authentication endpoint.
- Issue #2 was resolved by introducing rate-limiting on the web registration endpoint.
- The password policy was slightly hardened, and extremely easy passwords such as "123456" and "password" are no longer allowed.
The fix for Issue #2 was not effective at first: Facebook was informed on 04/04/2016, reconfirmed a new fix on 10/05/2016, and the new fix was deemed working on 19/05/2016, when the issue was publicly disclosed. A first fix that does not hold is common; the important part is that it was reported again and rechecked.
Timeline
- 28/12/2015: Submitted bug report for issue #1 to Facebook Bug Bounty, including PoC python script. A PoC (proof of concept) is a small demonstration that the problem is real, here the guessing script.
- 08/02/2016: Submitted bug report for issue #2 to Facebook Bug Bounty.
- 11/02/2016: Facebook confirmed that issue #2 is patched.
- 13/02/2016: Facebook confirmed that issue #1 was patched earlier as well and granted a combined bounty of $5.000.
- 04/04/2016: Informed Facebook that fix for issue #2 is not effective.
- 10/05/2016: Facebook reconfirmed new fix for issue #2.
- 19/05/2016: New fix deemed working, public disclosure.
Variants to test
If you want to look for similar problems on a site you are allowed to test, these are the same checks in general form:
- Rate-limit pattern probing on login endpoints. Send a long series of authentication attempts from one IP and record the response for each. A positive result is a repeating pattern where unreliable responses (such as "user not found") can be replayed until a reliable correct/incorrect answer is returned, meaning the limit can be reasoned around.
- Registration endpoint as a credentials oracle. Register an account, capture the registration request, replay it, then strip all parameters except the username and password. A positive result is a response that differs between a correct and an incorrect password for an existing account.
- Post-brute-force login from the attacking IP. After a successful brute-force, log in with the harvested credentials from the same IP used for the attack. A positive result is a successful login with no lockout or fraud challenge.
- Username enumeration via incremental identifiers. Request public user information for sequential userIDs, as with
https://i.instagram.com/api/v1/users/3/info/andhttps://i.instagram.com/api/v1/users/4/info/. A positive result is a resolvable, enumerable mapping between identifiers and usernames. - Password policy probing. Attempt to set extremely easy passwords such as "123456" and "password" during registration or password change. A positive result is acceptance of a password that should be rejected by a hardened policy.
Glossary
- 2FA (two-factor authentication): a login that needs a password plus a second proof, such as a code from your phone.
- Account lockout: freezing an account for a while after too many failed logins, even for its real owner.
- API (Application Programming Interface): the set of addresses and rules a program uses to talk to a service, as opposed to a person clicking in a browser.
- Brute-force attack: trying many candidate passwords in turn until one works.
- Burp: a tool for intercepting, inspecting and modifying web traffic between an app or browser and a server.
- Burp Intruder: the part of Burp that sends the same request many times with one part changed each time, used for password guessing.
- Credentials oracle: any server behaviour that reveals whether a given password is correct for a given account.
- Dictionary: a text file of candidate passwords, one per line, usually built from common or leaked passwords.
- Endpoint: a specific address on a server that accepts a particular kind of request.
- HMACSHA256: a well-known recipe for computing a signature from data plus a secret key.
- Hotpatch: recalculate or fix something on the fly, here the request signature, so each modified request still looks valid.
- Intercepting proxy: software that sits between an app and a server so you can read and edit the traffic.
- IP address: the numeric label of an internet connection, used by servers to recognise where requests come from.
- Location-based fraud detection: noticing that a login comes from an unusual place or network and asking for extra proof.
- PoC (proof of concept): a small demonstration that a vulnerability is real.
- POST parameters: the data fields sent with a request, such as a username and password.
- Rate limiting: a server's rule for how many requests a client may make in a period of time.
- Replay: send the very same request again.
- Request: the message a browser or app sends to a server.
- Response: the message a server sends back.
- Signature: a short code computed from a request's contents plus a secret key, so the server can check the request is genuine and unaltered.
- SSL pinning: an app refusing to trust any certificate except the one it expects, which blocks intercepting proxies.
- Thread lock: a guard that stops two parallel workers from updating the same value at the same moment.
- Threading: running several tasks at the same time instead of one after another.
- User enumeration: working out which usernames exist on a site, for example from responses or from sequential identifiers.
- UserID: the number a site uses internally to identify a user; here it appears in addresses such as
https://i.instagram.com/api/v1/users/3/info/.