Anyone is able to set the password since there are no control validation in place
This function allows only the owner to set a new password
/*
* @notice This function allows only the owner to set a new password.
* @param newPassword The new password to set.
*/
function setPassword(string memory newPassword) external {
s_password = newPassword;
emit SetNetPassword();
}
Since it is external with no validation in place, anyone could call the setPassword and change it, POC as below:
function test_non_owner_set_password() public {
vm.startPrank(address(1));
string memory expectedPassword = "InsecurePassword2";
passwordStore.setPassword(expectedPassword);
vm.prank(owner);
string memory actualPassword = passwordStore.getPassword();
assertEq(actualPassword, expectedPassword);
}
Anyone could rewrite the owner's password.
Foundry and manual inspection.
Add control validation to only allow the owner to setPassword
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.