The 'setPassword()' function, initially intended for the owner to set their password, lacks an 'onlyOwner' modifier or condition check. As a result, any external entity can access 'setPassword()' and change the password without the owner's consent, rendering it useless.
The below contract by Eve attacks the PasswordStore contract by calling the 'setPassword(string)' function in the PasswordStore contract and passes the new password as the argument. Eve will simply call the attackPasswordStore function and set the new password for the owner of the PasswordStore contract.
The owner of the password will not be able to apply his password for the desired service thus rendering the password and whole contract meaningless.
Solidity, Manual Review
The 'onlyOwner' modifier can be used for 'setPassword(string)' function to allow only owner of the contract to set a new password for himself.
A revert condition as used in the 'getPassword()' function can also mitigate this attack and only allow the owner to set a new password.
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.