Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

Non-owner can set password

Summary

Non-owner of the contract is allowed to set a new password.

Vulnerability Details

setPassword does not check if msg.sender = s_owner.

Impact

Anyone can set a new password which defeats the purpose of this contract.

Tools Used

Forge test on this function:
function test_non_owner_can_set_password() public {
vm.startPrank(address(1));
string memory fakePassword = "New Password But Not Owner's";
passwordStore.setPassword(fakePassword);
vm.startPrank(owner);
string memory actualPassword = passwordStore.getPassword();
assertEq(actualPassword, fakePassword);
}

Recommendations

Add a require or if statement like the one in getPassword.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 2 years ago
inallhonesty Lead Judge about 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-lacking-access-control

Anyone can call `setPassword` and set a new password contrary to the intended purpose.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.