Facebook has fixed a security flaw that allowed an attacker to take over any user’s account by abusing the social network’s password-reset mechanism.

The bug, discovered by Bangaluru-based researcher Anand Prakash, was found in Facebook sites used for beta-testing new features, and could have allowed straightforward access to any account.

“I was able to view messages, credit/debit cards stored under payment section, personal photos etc,” Prakash wrote in an advisory, adding that Facebook acknowledged and fixed the issue promptly, as well as paying out a $15,000 (£10,500) bounty.

Facebook allows anyone to reset the password for any account by entering the user’s telephone number or email address into a password recovery system. The site then sends a six-digit code to the user’s mobile phone that can be used to gain access to the account and set a new password.

Prakash found that two Facebook sites used for testing new features didn’t limit the number of times a user could enter an incorrect code. That meant a malicious user could write a simple script that kept guessing the code until it hit on the right one.

“I tried to takeover my account… and was successful,” he wrote. “I could then use the same password to login in the account.”

Facebook’s main website limited the number of incorrect guesses, Prakash noted.

He notified Facebook of the flaw on 22 February, and a fix was in place the next day. He said he received a bounty earlier this month.