An attacker can exploit the protocol and change owner's password directly by calling the setPassword function.
An attacker can call the setPassword function anytime and pass in a string to change the owner's password. This is due to no require or condition present in the setPassword function which should check if the msg.sender is the owner.
Attacker: Any Address can be the attacker. The attacker will call setPassword function passing in their own desired password which will overwrite the owner's current password.
Victim: The Owner will call getPassword function after the attack is completed. The owner will receive the overwritten/wrong password.
Protocol: The protocol provides two functions setPassword and getPassword. In the initial state the owner has set their password to MyPassword but due to a check for owner missing in setPassword, any address can call the function and set Owner's password to a different string.
There's a severe disruption of protocol functionality since the protocol is supposed to store the password for the owner so they can never forget about their password, attacker can change the password and the owner's password will be overwritten with the new password set by the Attacker.
Manual Review, Forge Unit Test
Owner check used in getPassword function should also be used in setPassword function.
The lines of code will change for setPassword to the following:
This will ensure that the msg.sender is always the Owner else the function will revert with error PasswordStore__NotOnwer();
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.