The PasswordStore::setPassword() function can be invoked by any user, not just the owner, allowing them to set a new password in the system. This means that any user has the ability to change the owner's password within the system. As a consequence, the owner loses the password saved in the system.
Attacker: The attacker can be anyone.
Victim: The owner of the system.
Using Remix:
deploy the PasswordStore contract and the AttackContract (before replace the targetContract with your PasswordStore contract deployment address)
call the callTargetFunction(string memory _password) on the AttackContract and set a new password
call the getPassword() on the PasswordStore to see that the password is changed.
Manual review
Evaluating to:
add an if statement in the PasswordStore::setPassword() function that reverts in case it isn't called by the owner
or:
add an onlyOwner modifier in the contract PasswordStore and delete the if conditions in the PassworStore_getPassword() function:
Anyone can call `setPassword` and set a new password contrary to the intended purpose.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.