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

setPassword - allows anyone to set a password

Summary

The setPassword function has no access restrictions, so anyone can change the password.

Vulnerability Details

The setPassword function’s comment says that only owner can set the password. However, there is no access control on the function, so anyone can call it and change the 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();
}

Impact

Anyone can change the password.

Tools Used

Manual Review

Recommendations

Add access restrictions.

function setPassword(string memory newPassword) external {
+ if (msg.sender != s_owner) {
+ revert PasswordStore__NotOwner();
+ }
s_password = newPassword;
emit SetNetPassword();
}
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.