Skip to content
Account takeover Write-up Intermediate

How I was able to revoke your Instagram 2FA

The Instagram signup flow allowed an attacker to brute-force the SMS verification code by rotating IP addresses to avoid rate limiting, and a correct code would remove the victim's phone number from their account. This could disable two-factor authentication if the victim used that number for 2FA.

Dhiyaneshwaran Follow

Published on dhiyaneshgeek.github.io

Bounty$5,000 View original

Back in November 2019, I was going through one of the Old Writeups on Facebook Bug Bounty Reports, “How I was able to remove your Instagram Phone number” by Neeraj Sonaniya

Dhiyaneshwaran, on dhiyaneshgeek.github.io

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Instagram's signup flow lets a new account be created with a mobile number. When the number entered already belongs to an existing account, the flow still proceeds to a six digit SMS verification step. Completing that step with the correct code removes the number from the original account and attaches it to the new one. If the original owner used that number for two factor authentication, the removal also disables 2FA on their account.

The report builds on an earlier write-up by Neeraj Sonaniya, "How I was able to remove your Instagram Phone number", which described the same number reuse behaviour. The researcher's contribution was a way to get past the per-IP limiting that, in the researcher's reasoning, stops an attacker from guessing the six digit code.

Setup

The work was done in November 2019 against the public Instagram signup page at https://www.instagram.com/. The only tooling described is Burp Suite, used as an intercepting proxy and for its Intruder and proxy configuration features, plus a pool of rotating IP addresses. No account credentials, victim interaction or special role is needed: the attacker only has to know a mobile number that is registered to someone else.

Finding it

Reading the older write-up, the researcher noticed that the signup flow accepts an existing user's number and then asks for an OTP. The obvious defence against guessing a six digit code is rate limiting, and the researcher reasoned that IP rotation could bypass it. That suggested the limit could be sidestepped by sending each guess from a different IP, a technique the report calls IP rotation.

From the original on dhiyaneshgeek.github.io

The report defines IP rotation as changing the IP address on each request sent to the server, with addresses assigned to a device at random or at scheduled intervals. With an ISP connection, for example, an address is attached automatically from a pool of IPs. It points to a separate article, "How to Rotate IP ADDRESS For Each Request in Burp Suite" by Lokesh Kumar, for the mechanics.

From the original on dhiyaneshgeek.github.io

Exploitation

Step 1: open the signup page with the victim's number

Navigate to https://www.instagram.com/ and fill in the signup page. Enter the mobile number of an already existing Instagram user and submit.

The flow does not reject a number that is already registered. Instead it moves on to the OTP screen.

From the original on dhiyaneshgeek.github.io

Step 2: submit a random code

Enter any random six digit OTP on that screen.

From the original on dhiyaneshgeek.github.io

Step 3: intercept the verification request

Capture the request with a client side proxy such as Burp Suite.

From the original on dhiyaneshgeek.github.io

Step 4: prepare the Intruder attack

Send the captured request to the Intruder tab and place a $$ placeholder in the sms_code parameter.

From the original on dhiyaneshgeek.github.io

Step 5: configure payloads and IP rotation

In the Payloads tab, set the payload options for the brute force. The report also shows two Burp configuration screenshots: the Burp Suite user options configuration and the proxy configuration.

From the original on dhiyaneshgeek.github.io

Step 6: run the attack and read the responses

Click Attack. Responses are distinguished by length. A length of 2547 means the submitted code was invalid.

From the original on dhiyaneshgeek.github.io

When the correct code is hit, the response length is 3453 and the body reports Account Created.

From the original on dhiyaneshgeek.github.io

Step 7: observe the effect on the victim

As a result of the successful signup, the number's owner receives an email stating "Phone number removed as Two Factor Authentication Method".

From the original on dhiyaneshgeek.github.io

Root cause

The signup flow accepts a mobile number that is already registered to another account and, once the correct OTP is entered, the number is removed from the original account. The only barrier to guessing the six digit code appears to be rate limiting, which the report implies is applied per source IP address. Because the attacker can present a fresh address for each attempt, the per-IP counter never accumulates and the full code space can be walked. The report does not describe the server side implementation, so the per-IP nature of the limit is inferred from the fact that rotation defeats it.

Impact

Two effects are described:

  1. A confirmed mobile number can be removed from another user's Instagram account and reused to register a new one, after the OTP step is passed with IP rotation.
  2. If the victim uses that number for two factor authentication, the 2FA is disabled without any interaction from them.

The attack requires knowledge of the victim's registered mobile number and the ability to send requests from many IP addresses. The report does not state how many attempts were needed or how long the attack took.

Fix

The issue was patched by the vendor. A fix would need to stop a correct OTP on a number already bound to another account from moving the number, and to rate limit verification attempts in a way that does not depend solely on the source IP address.

Timeline

Date and time Event
27 January 2020 at 01:40 Report submitted
31 January 2020 at 11:00 Not able to reproduce
6 February 2020 at 23:08 Detailed POC video sent
7 February 2020 at 01:01 Issue triaged
14 February 2020 at 22:12 Issue patched
14 February 2020 at 22:23 $5000 bounty awarded
From the original on dhiyaneshgeek.github.io

Variants to test

  • OTP verification on signup or number change. Submit an existing user's number and brute force the code with rotating source addresses. A positive result is a response that differs in length or body from the invalid-code response and reports success, followed by a notification to the number's owner.
  • Any per-IP rate limit in front of a short numeric secret. Password reset codes, email verification links with short tokens, and PIN entry screens are candidates. A positive result is that attempts continue to be processed after the limit that would normally trigger from a single address.
  • Account recovery flows that accept a number already in use. Check whether the flow discloses that the number exists and whether completing it moves the identifier to the attacker's account. A positive result is a confirmation email or message to the original owner about removal.

References

  • Bypassing IP Based Blocking with AWS API Gateway
  • How I Could Have Hacked Any Instagram Account
  • How I Hacked Instagram Again
  • Disable Any Unconfirmed Account in Facebook
  • Confirming any new Email Address bug in Facebook (Part-4)
From the original on dhiyaneshgeek.github.io

The author notes that the post is for educational purposes and that IP based blocking is common, so the technique should not be used for illegal activity.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

Instagram lets you create an account with a mobile phone number. When you type a number into the signup page, Instagram sends a six digit code to that phone by SMS and asks you to type the code back. That is how it checks the number really belongs to you.

The problem was this: if the number you typed already belonged to somebody else's Instagram account, Instagram did not stop you. It still sent the code and still asked you to type it in. And if you managed to type the correct code, Instagram took the number away from the original owner and gave it to your new account. If the original owner had been using that number as a second lock on their account (two factor authentication, explained below), that lock was switched off at the same moment.

So the whole attack comes down to one question: can you guess a six digit code? Six digits sounds like a lot, but a computer can try many guesses quickly. The normal defence is a rate limit: the server notices that one visitor is guessing over and over and refuses to answer any more. The researcher's insight was that this limit could be bypassed by changing the source IP address, the numeric label that identifies where a request comes from on the internet. If every guess arrives from a different IP address, the server never sees one visitor making many attempts. It sees many different visitors making one attempt each. That trick is called IP rotation, and it is what turned a blocked attack into a working one.

The report was submitted in January 2020, paid a $5000 bounty, and the issue was patched in February 2020.

Background: the earlier write-up

Back in November 2019 the researcher was reading an older public write-up on Facebook bug bounty reports, "How I was able to remove your Instagram Phone number" by Neeraj Sonaniya. That article described the strange behaviour of the signup flow: it accepts a phone number that is already registered to another account and carries on to the SMS code step.

Reading it, the researcher had an idea. The behaviour was known, and the researcher reasoned that IP rotation could bypass whatever limit stopped someone from simply guessing the code. So the barrier could be walked around by changing the source IP address on every request.

From the original on dhiyaneshgeek.github.io

What IP rotation is

The report defines IP rotation as the process of changing the IP address on each request sent to the server, where the assigned IP addresses are handed to a device at random or at scheduled intervals.

An everyday comparison: think of a shop that bans anyone who asks for the same item more than three times in a row. If you walk out and come back wearing a different coat each time, the shop assistant at the door does not connect the requests. IP rotation is the internet version of changing coats. Your internet provider normally gives you one address from a pool, and it can change over time; with the right setup you can make it change on purpose, request by request.

The report points to a separate detailed article, "How to Rotate IP ADDRESS For Each Request in Burp Suite" by Lokesh Kumar, for the mechanics of doing this inside Burp Suite.

From the original on dhiyaneshgeek.github.io

The tools you need to understand

Before the steps make sense, three ideas need explaining from zero.

A proxy. A proxy is a middleman that sits between your browser and the website. Instead of your browser talking straight to Instagram, it talks to the proxy, and the proxy forwards the message and hands you back the reply. That lets you read and edit the message in transit. Burp Suite is a well known proxy used by security testers; it runs on your own machine and you point your browser at it.

A request. Every time a page does something, your browser sends a request to the server: a small text message with a method (such as POST, meaning "here is some data for you"), a URL, some headers (extra information such as what kind of data is being sent), and a body (the actual data, for example the phone number and the code you typed). The server answers with a response, which has a status, headers and a body. The body is what you see rendered as a page.

Brute force and Intruder. Brute forcing means trying every possibility until one works, rather than being clever. Burp Suite has a component called Intruder that takes one captured request and resends it many times, each time with a chosen part swapped for the next value in a list. You mark the part to swap with a placeholder, give it a list of values, and press Attack. Intruder then shows you a table of every response, so you can spot the one that differs.

Attack scenario

From the original on dhiyaneshgeek.github.io

Steps to reproduce

Step 1: open the signup page with the victim's number

  1. Navigate to https://www.instagram.com/ and fill in the signup page.
  2. Enter the mobile number of an already existing Instagram user and click submit.
  3. The flow moves you on to the code screen shown below.
From the original on dhiyaneshgeek.github.io

Why this step matters: a well built signup flow would refuse a number that is already registered. This one does not, and proceeds to prove ownership by SMS. It treats the number as available and proceeds to prove ownership by SMS. That is the first half of the bug.

Step 2: submit a random code

Enter any random six digit OTP number on that screen.

From the original on dhiyaneshgeek.github.io

Why a random code: you are not trying to succeed yet. You are trying to make the browser send the verification request once, so that you can capture it. Any value will do, because the request is what you are after, not the answer. OTP stands for one time password: a short code that is valid for a single use, here delivered by SMS.

Step 3: intercept the verification request

Capture the request with a client side proxy such as Burp Suite.

From the original on dhiyaneshgeek.github.io

Why: the request contains everything the server needs to decide whether the code is right: the phone number, the code, and whatever else the page attached. Once you hold that request in Burp, you can resend it as many times as you like with a different code each time, without touching the browser again.

Step 4: prepare the Intruder attack

Send the captured request to the Intruder tab and place a $$ placeholder in the sms_code parameter.

From the original on dhiyaneshgeek.github.io

Why: sms_code is the field in the request that carries the six digit code. Marking it tells Intruder which part to replace on each attempt. Everything else in the request stays exactly as the browser sent it, so the server sees a normal verification request every time.

Step 5: configure payloads and IP rotation

In the Payloads tab, set the payload options for the brute force. A payload, in this context, is simply the list of values Intruder will substitute into the marked position: here, the candidate codes.

The report also shows two Burp configuration screenshots: the Burp Suite user options configuration and the proxy configuration.

From the original on dhiyaneshgeek.github.io

Why two separate settings: one is the Burp Suite user options configuration, the other is the proxy configuration. The report shows both but does not explain how they combine. Without this, the server would see thousands of guesses from one address and the rate limit would kick in.

Step 6: run the attack and read the responses

Click the Attack button to start the attack.

Responses are distinguished by length. A length of 2547 means the submitted code was invalid.

From the original on dhiyaneshgeek.github.io

When the correct code is hit, the response length is 3453 and the body reports Account Created.

From the original on dhiyaneshgeek.github.io

Why length: every wrong code produces the same page, so every wrong response is the same size. The one right code produces a different page, so its size differs. Sorting the results by length turns a haystack of identical answers into one obvious outlier. The report gives the two lengths, 2547 for invalid and 3453 for success, and the success body contains the words Account Created.

Step 7: observe the effect on the victim

As a result of the successful signup, the number's owner receives an email stating "Phone number removed as Two Factor Authentication Method".

From the original on dhiyaneshgeek.github.io

Why this is the proof: the victim did nothing. They did not approve anything, did not click a link, did not reply to an SMS. The number simply left their account, and the email is Instagram telling them so after the fact. Two factor authentication (2FA) means logging in requires two things: your password plus a second proof, often a code sent to your phone. If the phone number is removed, that second proof is gone, so the account falls back to password only.

Root cause

The signup flow accepts a mobile number that is already registered to another account, and once the correct OTP is entered the number is removed from the original account. A correct code is taken to mean "this person holds the phone", so the number is transferred to the new account.

The only barrier to guessing the six digit code appears to be rate limiting, which the report implies is applied per source IP address. Because the attacker can present a fresh address for each attempt, the per-IP counter never accumulates, and the full code space can be walked. The report does not describe the server side implementation, so the per-IP nature of the limit is inferred from the fact that rotation defeats it.

In plain words: the lock was on the door of the building, not on the safe. Change which door you come in through and the lock never sees you twice.

Impact

Two effects are described:

  1. A confirmed mobile number can be removed from another user's Instagram account and reused to register a new one, once the OTP step is passed with IP rotation.
  2. If the victim uses that number for two factor authentication, the 2FA is disabled without any interaction from them.

The attack requires knowledge of the victim's registered mobile number and the ability to send requests from many IP addresses. The report does not state how many attempts were needed or how long the attack took.

Fix

The issue was patched by the vendor. A fix would need to stop a correct OTP on a number already bound to another account from moving the number, and to rate limit verification attempts in a way that does not depend solely on the source IP address.

Timeline

Date and time Event
27 January 2020 at 01:40 Report submitted
31 January 2020 at 11:00 Not able to reproduce
6 February 2020 at 23:08 Detailed POC video sent
7 February 2020 at 01:01 Issue triaged
14 February 2020 at 22:12 Issue patched
14 February 2020 at 22:23 $5000 bounty awarded
From the original on dhiyaneshgeek.github.io

A note on the timeline: the first answer was that the team could not reproduce it. The researcher then sent a detailed proof of concept video, and the issue was triaged the next day. POC stands for proof of concept: a recording or set of steps that shows the bug actually happening, so the receiving team can follow it exactly.

Variants to test

The same idea can be tried wherever a short numeric secret is protected only by a per-IP limit.

  • OTP verification on signup or number change. Submit an existing user's number and brute force the code with rotating source addresses. A positive result is a response that differs in length or body from the invalid-code response and reports success, followed by a notification to the number's owner.
  • Any per-IP rate limit in front of a short numeric secret. Password reset codes, email verification links with short tokens, and PIN entry screens are candidates. A positive result is that attempts continue to be processed after the limit that would normally trigger from a single address.
  • Account recovery flows that accept a number already in use. Check whether the flow discloses that the number exists and whether completing it moves the identifier to the attacker's account. A positive result is a confirmation email or message to the original owner about removal.

References

  • Bypassing IP Based Blocking with AWS API Gateway
  • How I Could Have Hacked Any Instagram Account
  • How I Hacked Instagram Again
  • Disable Any Unconfirmed Account in Facebook
  • Confirming any new Email Address bug in Facebook (Part-4)
From the original on dhiyaneshgeek.github.io

The author notes that the post is for educational purposes and that IP based blocking is common, so the technique should not be used for illegal activity.

Glossary

  • 2FA (two factor authentication): a login that needs two separate proofs, usually a password plus a code sent to your phone.
  • API: a way for one piece of software to talk to another, sending requests and getting structured answers back; here, the endpoints the signup page talks to behind the scenes.
  • Brute force: trying every possible value until one works, instead of reasoning about the answer.
  • Burp Suite: a tool used by security testers that sits between browser and website, letting you read, edit and resend requests.
  • Client side proxy: a proxy running on your own machine, which your browser is configured to send its traffic through.
  • Endpoint: a specific address on a server that accepts a particular kind of request, for example the one that checks an SMS code.
  • Header: extra information attached to a request or response, such as the type of data being sent.
  • Intruder: the part of Burp Suite that resends one request many times with a chosen field replaced by each value from a list.
  • IP address: the numeric label that identifies where a request comes from on the internet.
  • IP rotation: changing the source IP address on each request, so the server does not see one visitor making many attempts.
  • ISP: internet service provider, the company that connects you to the internet and assigns your IP address.
  • OTP (one time password): a short code valid for a single use, here sent by SMS.
  • Parameter: a named field inside a request that carries a value, such as sms_code.
  • Payload: in Intruder, the list of values substituted into the marked position on each attempt.
  • POC (proof of concept): a recording or set of steps that demonstrates a bug actually happening.
  • POST: an HTTP method meaning "here is some data for you", used when a form is submitted.
  • Proxy: a middleman that forwards requests between your browser and a website, so you can inspect and change them.
  • Rate limiting: a server refusing to answer after too many attempts in a period, to slow down guessing.
  • Request: the message your browser sends to a server, with a method, URL, headers and body.
  • Response: the server's reply, with a status, headers and body; the body is what becomes the page.
  • Root cause: the underlying design or coding mistake that makes the bug possible.
  • SMS code: the six digit code sent by text message to prove you hold a phone number.
  • Triaged: the stage where the receiving team has confirmed the report is valid and is working on it.
  • Upstream proxy: a proxy that Burp itself sends traffic through, rather than talking to the website directly.
  • Vulnerability class: the general category a bug belongs to, such as brute force or rate limiting bypass.

More from Meta

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.