The PasswordStore contract is designed to securely store a password while allowing only the contract owner to modify it. However, a critical flaw in the setPassword function permits any user to change the stored password, severely compromising the contract's integrity and security.
The setPassword function is intended to be restricted for use by the contract owner only. Nevertheless, the function lacks any access control mechanisms, such as the commonly used onlyOwner modifier, to enforce this restriction. Consequently, any malicious actor can call this function to change the password to a value of their choosing.
This vulnerability carries a high severity rating. Unauthorized users can change the password, potentially leading to unauthorized access or other malicious activities, if the password is used for critical operations within or outside the blockchain environment.
Add the POC function above to the PasswordStore.t.sol file
Output:
we an see that the password has changed.
Foundry
Manual Review
Implement the onlyOwner modifier on the setPassword function to ensure that only the contract owner can change the password. The onlyOwner modifier should verify that msg.sender is equal to the s_owner before proceeding with the function execution.
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.