Instagram: a million codes and a limit that could be split up
To reset a forgotten password, Instagram sent a six-digit code. There was a limit on attempts, but it could be spread across many connections at once.
New here? Try the first lesson without an accountCompany or project
Instagram (Facebook)
When
Published by the researcher: 14 Jul 2019
Reference
Laxman Muthiyah’s blog (no CVE)
Severity and scale
Any account · USD 30,000 bounty
The story
In 2019, researcher Laxman Muthiyah studied how Instagram recovered accounts from its phone app. If you forgot your password, you got a six-digit code; you typed it and chose a new one. Six digits make one million combinations, so Instagram limited how many codes could be tried. Muthiyah confirmed that the limit existed, but that it was not enough. He reported it to the bug bounty program of Facebook, Instagram’s owner, which fixed it and paid him 30,000 dollars. He told the story on his blog in July 2019.
The term, explained simply
Think of a fair game where each person gets three throws. The attendant counts throws by looking at the face of whoever throws. If a hundred friends throw at the same time, each with their three throws, someone still wins the prize: the limit was placed on the wrong thing. A rate limit sets how many requests are accepted in a period of time. A race condition appears when many requests arrive at the same moment and the system does not finish counting one before handling the next.
The root cause
The limit counted attempts by the internet address (IP) they came from, not by account or by code. With many simultaneous requests from many addresses, the total number of attempts went far beyond what the limit was meant to allow.
What could happen
With enough attempts, someone could guess the code and change the password of any account, that is, take it over. The code expired after ten minutes, so it took a huge amount of capacity, but the researcher showed the attack was possible. Facebook paid a 30,000-dollar bounty.
How it was fixed and how to prevent it
Facebook fixed the flaw after the report; the blog does not say how. In general, it is prevented like this: the limit is counted per account and per code, not only per connection; the code is cancelled after a few failed attempts; and the counter is updated in a single indivisible step (atomically), so simultaneous requests cannot slip past the count.
Sources
Official documents and the researcher’s own write-up. We tell the story, the concept and the defense; there are no steps to repeat the attack.
