The function PasswordStore::setPassword
is intended to allow only the contract's owner to set a new password. However, due to a missing ownership check, any address can call this function and change the password.
The function setPassword
does not check if the caller is the contract's owner.
This allows any address to call the function and set a new password, violating the intended access control.
Checking the msg.sender
and reverting the transaction if it doesn't correspond to s_owner
will prevent this behavior.
The contract's owner does not have the exclusive right to set a new password since the function can be called by anyone.
Here's my proof of code:
foundry
Add a check to setPassword
that reverts if the msg.sender
is not s_owner
.
To facilitate secure ownership operations, I strongly recommend implementing the Ownable
contract from the OpenZeppelin
library.
This contract provides a simple and reliable way to handle ownership of the contract, including an onlyOwner
modifier that can be used to restrict functions only to the contract's owner.
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.