The PasswordStore::setPassword
function allows anyone to execute the function and set a new password.
As mentioned in the comments, the password value is not supposed to be accessible by entities other than the owner. However, the function does not restrict access. As of now, anyone who executes this function can change the password.
Anyone can change the password ! If the password is used to lock/unlock something important like a vault, the protocol will be completely compromised.
For the contract PasswordStore
, the core functionality which limits access to the PasswordStore::setPassword
function for setting up a new password is compromised.
You can execute the following test using the command : forge test --mt test_non_owner_can_set_password -vvvv
foundry
Restrict access to the function PasswordStore::setPassword
. There are many ways to do this :
Check that msg.sender
is the owner :
Add a modifier that restrict function use to the owner. The onlyOwner modifier from Openzeppelin can be used for this purpose :
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.