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

'setPassword()' must check that the caller is owner of the contract

Summary

The setPassword function lacks the OnlyOwner modifier

Vulnerability Details

The function setPassword which does not have OnlyOwner modifier , which means that any one can change the current password of owner.

@> function setPassword(string memory newPassword) external {
s_password = newPassword;
emit SetNetPassword();
}

Impact

Any one can change the password of owner.

Tools Used

Manual Review.

Recommendations

Need to add OnlyOwner modifier on setNewpassword() to prevent attacker from changing the password of store.

+ modifier OnlyOwner(){
+ if(msg.sender != s_owner) revert PasswordStore__NotOwner();
+ _;
+ }
+ function setPassword(string memory newPassword) external OnlyOwner {
...
Updates

Lead Judging Commences

inallhonesty Lead Judge
almost 2 years ago
inallhonesty Lead Judge almost 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.