Skip to content
Account takeover Write-up Intermediate

Disable Any Unconfirmed Account in Facebook

The email confirmation endpoint for new Facebook accounts lacked effective rate limiting, allowing an attacker to brute-force the five-digit verification code. By rotating IP addresses, an attacker could disable any unconfirmed account without the owner's interaction.

Lokesh Kumar Follow

Published on medium.com

Bounty$1,000 View original

{{media:0}}

Lokesh Kumar, on medium.com

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. 4 min read.

Context

Facebook lets a new user sign up with an email address. To confirm ownership of that address, the platform sends a five digit verification code to the email. Because an attacker could also try to register an account using somebody else's email, the owner of the address has a way to disable that pending verification code, so the unconfirmed account is not created against their will.

The endpoint that performs this disabling is the target of this write-up. The researcher, Lokesh Kumar, describes a brute force attack against the five digit code that uses IP rotation to get around the rate limiting, and that lets an attacker disable any new unconfirmed account without the owner's interaction. The post is presented as a bypass of an earlier write-up on pagefault.me, which covered the same endpoint and whose fix dates from 2014.

Lokesh Kumar
Lokesh Kumar From the original on medium.com

Setup

The attack needs very little:

  1. The email address of an unconfirmed Facebook account, that is, an address for which a sign-up has started but the five digit code has not yet been entered.
  2. A way to send requests to the vulnerable endpoint repeatedly.
  3. A pool of IP addresses that can be rotated, so that each request in the brute force comes from a different address.

The researcher found the third item by searching online for a solution to IP based blocking and learning about IP rotation services. He wrote a separate post on how to rotate the IP address during a brute force attack, and used that setup here.

Finding it

The starting point was the older pagefault.me write-up, which described disabling Facebook accounts through the same confirmation flow. That issue was fixed in 2014, so the researcher assumed the remaining protection had to be IP based blocking rather than a change to the logic of the endpoint itself.

The vulnerable endpoint is:

Text
https://m.facebook.com/confirmemail.php?e=[redacted]@&c=15579&report=1&message=1

The code is five digits, so the search space is small enough for an online brute force if nothing slows the attacker down.

Exploitation

Step 1: confirm the rate limit

The endpoint does have a rate limit. After a certain number of attempts at brute forcing the five digit verification code, the researcher was temporarily blocked.

Step 2: test whether the block is tied to the IP address

Since the 2014 fix was assumed to be IP based blocking, the researcher changed his IP address and sent the request again. As expected, no blocking occurred from the new IP address.

Step 3: rotate the IP for every request

A single change of address is not enough for a brute force, because the block would return after the same number of attempts from the new address. The researcher needed a fresh IP for each request. He searched for a solution, found IP rotation services, and configured one. With rotation in place, he was able to brute force the five digit verification code without getting blocked.

Image for post
Image for post From the original on medium.com

A video proof of concept accompanies the post.

Root cause

The endpoint accepts guesses of the five digit verification code and only throttles them per source IP address. The researcher guessed the 2014 fix was IP based blocking, and changing the IP address avoided the block. The code space is only five digits, which makes a per-IP limit ineffective once addresses can be rotated cheaply.

Impact

The researcher lists two consequences:

  1. If the victim's email gets disabled, they cannot create a new Facebook account in future, because the email will be blacklisted on Facebook account creation.
  2. If the attacker knows the unconfirmed email address, they can brute force the code and disable that account without the owner's interaction.

Both depend on the attacker knowing the email address of an account that is still unconfirmed, and on being able to rotate IP addresses for the duration of the brute force.

Fix

Facebook confirmed the fix on 23 August 2019, the same day the bounty was awarded. The report does not describe what was changed.

Timeline

Date Event
30 June 2019 Report sent
3 July 2019 Further investigation by Facebook
23 August 2019 Fixed confirmed by Facebook and the researcher
23 August 2019 $1000 bounty awarded by Facebook
Image for post
Image for post From the original on medium.com

Variants to test

  1. Per-IP throttling on code confirmation. Look for any endpoint that verifies a short numeric code (email confirmation, phone verification, password reset PIN) and check whether the limit resets when the source address changes. A positive result is the same number of attempts being accepted again from a new address while the target account stays the same.
  2. Limits keyed to the wrong object. Try whether the counter follows the email, the pending account or the session instead of the IP. A positive result is a block that can be avoided by changing only the attribute the counter ignores.
  3. Small code spaces. Enumerate endpoints that accept four to six digit codes and estimate whether the space is reachable within the allowed attempts per address multiplied by the number of addresses available.
  4. Destructive actions behind the code. Check what happens after a correct guess: disabling a pending account, deleting a registration, unlinking an address. A positive result is a state change on the victim's account triggered by a guessed code with no owner interaction.

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. 9 min read.

What happened, in plain words

When you create a Facebook account, Facebook does not simply trust that the email address you typed belongs to you. It sends a short code, five digits long, to that email address. You read the code in your inbox and type it back into Facebook. Only then does Facebook treat the address as confirmed and finish creating the account.

This is a sensible design, because otherwise anyone could sign up using somebody else's email address. But it creates a problem in the other direction: if a stranger starts a sign-up using your email, you would keep receiving codes you never asked for. So Facebook gives the real owner of the address a way to cancel that pending sign-up. You can disable the unconfirmed account, and the code that was sent stops being useful.

Lokesh Kumar found that this cancel feature could be abused. If an attacker knows your email address and can guess the code, they can send the cancel request themselves and disable the pending account without you doing anything. Five digits is only 100,000 possible values, which is small enough for a computer to try one after another. That kind of repeated guessing is called a brute force attack.

Facebook did have a defence: after a certain number of wrong guesses, the attacker was temporarily blocked. Changing the IP address avoided the block. Change the address and the block no longer applies. The researcher used a service that gives a different IP address for every request, so no single address ever made enough failed attempts to be blocked. With that in place he could guess the code until he found the right one.

The post is presented as a bypass of an earlier write-up on pagefault.me, which described the same endpoint and whose fix dates from 2014.

Lokesh Kumar
Lokesh Kumar From the original on medium.com

The pieces you need to understand first

Before walking through the attack, here are the ideas it relies on, explained from scratch.

Sign-up and email confirmation. When a website wants to check that an email address is real and belongs to you, it sends a message to that address containing a short code or a link. You prove you can read that inbox by sending the code or clicking the link back to the site. Until you do, the account sits in a half-finished state, often called unconfirmed or pending.

A verification code. A short number, here five digits, that is meant to be hard for anyone else to guess. The security comes from two things: the code is only sent to the real inbox, and the site limits how many times someone can guess it.

An endpoint. A specific web address that a site's server listens on and that performs one action. Think of it as a particular counter in a large building: you walk to that counter and ask for one specific service. The endpoint in this report is the one that cancels a pending email confirmation.

Query parameters. The part of a web address after the question mark. Each parameter is a name and a value joined by an equals sign, and several are joined by ampersands. They are the details you hand to the counter: which email, which code, which options.

A brute force attack. Trying every possibility in turn until one works, like working through every combination on a padlock instead of picking it. It only succeeds when the number of possibilities is small and nothing stops you from trying them all.

Rate limiting. A rule that says "you may only do this so many times in a period". A website uses it to slow down anyone guessing codes or passwords. When you exceed the limit you get blocked, usually for a short while.

An IP address. The number that identifies a device or network on the internet, a bit like a return address on an envelope. Servers see the address a request came from, and many rate limits are counted per address.

IP rotation. Deliberately sending each request from a different IP address, usually through a paid service that owns many addresses. If a limit is counted per address, rotation means no single address builds up enough attempts to be blocked.

A proof of concept (POC). A demonstration, often a video or screenshots, showing that an attack really works rather than only being described.

Setting up

The attack needs very little:

  1. The email address of an unconfirmed Facebook account, that is, an address for which a sign-up has started but the five digit code has not yet been entered.
  2. A way to send requests to the vulnerable endpoint repeatedly.
  3. A pool of IP addresses that can be rotated, so that each request in the brute force comes from a different address.

The researcher found the third item by searching online for a solution to IP based blocking and learning about IP rotation services. He wrote a separate post on how to rotate the IP address during a brute force attack, and used that setup here.

Finding it

The starting point was the older pagefault.me write-up, which described disabling Facebook accounts through the same confirmation flow. That issue was fixed in 2014, so the researcher assumed the remaining protection had to be IP based blocking rather than a change to the logic of the endpoint itself. In other words: if the old trick no longer worked, something must now be stopping it, and the most likely something was a limit on how often one address could ask.

The vulnerable endpoint is:

Text
https://m.facebook.com/confirmemail.php?e=[redacted]@&c=15579&report=1&message=1

Reading it piece by piece:

  • https://m.facebook.com/confirmemail.php is the address of the counter: the mobile Facebook page that handles email confirmation.
  • ? marks the start of the parameters.

The code is five digits, so the search space is small enough for an online brute force if nothing slows the attacker down. "Online" here means the guesses are sent to the real server one at a time, as opposed to an offline attack where an attacker has a copy of the data and can guess at leisure.

Exploitation

Step 1: confirm the rate limit

The endpoint does have a rate limit. After a certain number of attempts at brute forcing the five digit verification code, the researcher was temporarily blocked. This step matters because it tells you what defence exists before you try to get around it. If there were no limit at all, the attack would already be trivial; the block is the obstacle to understand.

Step 2: test whether the block is tied to the IP address

Since the 2014 fix was assumed to be IP based blocking, the researcher changed his IP address and sent the request again. As expected, no blocking occurred from the new IP address. The logic is simple: if the block followed the email or the pending account, changing your own address would not help. Because it did help, the counter must be attached to the address.

Step 3: rotate the IP for every request

A single change of address is not enough for a brute force, because the block would return after the same number of attempts from the new address. The researcher needed a fresh IP for each request. He searched for a solution, found IP rotation services, and configured one. With rotation in place, he was able to brute force the five digit verification code without getting blocked.

Image for post
Image for post From the original on medium.com

A video proof of concept accompanies the post.

Why it worked

The endpoint accepts guesses of the five digit verification code and only throttles them per source IP address. The researcher guessed the 2014 fix was IP based blocking, and changing the IP address avoided the block. The code space is only five digits, which makes a per-IP limit ineffective once addresses can be rotated cheaply.

A useful comparison: imagine a shop that lets each customer ask for a refund only three times a day, but identifies customers purely by the coat they are wearing. Change coats and the counter starts again. The rule looks like a limit, but it is attached to the wrong thing.

Impact

The researcher lists two consequences:

  1. If the victim's email gets disabled, they cannot create a new Facebook account in future, because the email will be blacklisted on Facebook account creation.
  2. If the attacker knows the unconfirmed email address, they can brute force the code and disable that account without the owner's interaction.

Both depend on the attacker knowing the email address of an account that is still unconfirmed, and on being able to rotate IP addresses for the duration of the brute force.

The fix

Facebook confirmed the fix on 23 August 2019, the same day the bounty was awarded. The report does not describe what was changed.

Timeline

Date Event
30 June 2019 Report sent
3 July 2019 Further investigation by Facebook
23 August 2019 Fixed confirmed by Facebook and the researcher
23 August 2019 $1000 bounty awarded by Facebook
Image for post
Image for post From the original on medium.com

Variants to test

Each one is a question you can ask about a website you are allowed to test.

  1. Per-IP throttling on code confirmation. Look for any endpoint that verifies a short numeric code (email confirmation, phone verification, password reset PIN) and check whether the limit resets when the source address changes. A positive result is the same number of attempts being accepted again from a new address while the target account stays the same.
  2. Limits keyed to the wrong object. Try whether the counter follows the email, the pending account or the session instead of the IP. A positive result is a block that can be avoided by changing only the attribute the counter ignores.
  3. Small code spaces. Enumerate endpoints that accept four to six digit codes and estimate whether the space is reachable within the allowed attempts per address multiplied by the number of addresses available.
  4. Destructive actions behind the code. Check what happens after a correct guess: disabling a pending account, deleting a registration, unlinking an address. A positive result is a state change on the victim's account triggered by a guessed code with no owner interaction.

Glossary

  • Brute force attack: trying every possible value of a secret, one after another, until the right one is found.
  • Bypass: a way of getting around a protection that is supposed to stop an attack.
  • Endpoint: a specific web address on a server that performs one particular action.
  • Flag: a parameter that acts as an on/off switch, usually with a value of 1 or 0.
  • IP address: the number identifying a device or network on the internet, used by servers to see where a request came from.
  • IP rotation: sending successive requests from different IP addresses, often through a paid service, so that per-address limits never trigger.
  • Parameter: a named value passed in a web address after the question mark, such as c=15579.
  • Pending (unconfirmed) account: a sign-up that has started but whose email code has not yet been entered.
  • Proof of concept (POC): a demonstration, often a video, showing that an attack works in practice.
  • Query string: the part of a web address after the question mark, holding the parameters.
  • Rate limiting: a rule restricting how many times an action may be performed in a period, used to slow down guessing.
  • Search space: the total number of possible values an attacker would have to try; for a five digit code, 100,000.
  • Throttling: another word for rate limiting, slowing down repeated requests.
  • Verification code: a short number sent to an email address or phone to prove the person controls it.

More by Lokesh Kumar

View all

5 more disclosed reports, best first.

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.