The PasswordStore.sol allows only the owner to read the password while anyone can write the password.
The setPassword() does not verify that the msg.sender is the s_owner. This allows anyone to update the s_password to any value.
This can be proven by adding a test case in PasswordStore.t.sol that looks like this:
Then run make test and observe that the tests pass, which indicates that the password was indeed changed by someone other than the owner.
This would prevent the owner from being able to use the password as intended. The owner could always change the password to another value to continue using services that relied on this store. But it would leave any service and data relying on this store exposed.
Manual Review and Foundry
Add check in the setPassword() function that is similar to the one in the getPassword().
Alternatively, create a modifier that can be used for both functions:
Then, both functions could be simplified as:
Or, another alternative could be to inherit from OpenZeppelin's Ownable contract. This would remove the need for creating the modifier while allowing the function to remain simple.
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.