Security researcher Laxman Muthiyah discovered a critical vulnerability that could have allowed remote attackers to reset the password of Instagram accounts, thus obtaining full access to the compromised accounts. The vulnerability resided in the password recovery mechanism in the mobile version of Instagram.
When a user enters his/her mobile number, they will be sent a six-digit passcode to their mobile number. They have to enter it to change their password. Therefore if we are able to try all the one million codes on the verify-code endpoint, we would be able to change the password of any account. But I was pretty sure that there must be some rate limiting against such brute-force attacks. I decided to test it, the researcher wrote.
Race Hazard and IP Rotation Issues
The researcher’s tests revealed the presence of rate limiting. Apparently, he sent around 1000 requests, 250 of which went through and the rest were rate limited. Muthiyah performed the same test with another 1000 requests, and discovered that Instagram’s systems were indeed validating and rate limiting the requests in a proper way. However, the researcher noticed two things that puzzled him – the number of requests he was able to send, and the lack of blacklisting:
I was able to send requests continuously without getting blocked even though the number of requests I can send in a fraction of time is limited.
After several other tests, the researcher discovered that race hazard and IP rotation could allow him to bypass the rate limiting mechanism.
When does a race condition happen? Shortly said, a race condition happens when a device or system attempts to perform two or more operations at the same time, but because of the nature of the device or system, the operations must be done in the proper sequence to be performed correctly.
Sending concurrent requests using multiple IPs allowed me to send a large number of requests without getting limited, the researcher explained. The number of requests we can send is dependent on concurrency of reqs and the number of IPs we use. Also, I realized that the code expires in 10 minutes, it makes the attack even harder, therefore we need 1000s of IPs to perform the attack.
The vulnerability was reported to Facebook but it took some time for Facebook’s security team to reproduce the issue as the information in the researcher’s report was not enough. However, the proof-of-concept video convinced them that “the attack is feasible”.