H-01 Lack of access control validation in a critical protocol function.
In PasswordStore.sol:29, the function setPassword
allows any address to set the password without any access control validation, as msg.sender
is not checked to be the contract owner. This poses a serious security risk as any user can arbitrarily change the password which might not be the intent of the contract design.
The following unit test case passes, meaning the address(1) successfully changed the contract password
The output is shown below.
The impact of this security vulnerability is HIGH as it can result in unauthorized access and potential misuse of the smart contract. In a scenario where the password acts as a validation for withdrawing funds, allowing to freely set any password can lead to loss of funds.
Manual Review
To mitigate this security risk, it is recommended to consider utilizing an access control implementation such as OpenZeppelin's Ownable contract and the onlyOwner
modifier. This contract provides a simple and secure way to restrict function call to only contract owner. Reference: OZ access control
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.