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

Missing Access Control in setPassword()

Summary

The setPassword() function in the PasswordStore.sol contract omits important authorisation (AuthZ) checks, allowing anyone to update the password value.

Vulnerability Details

The contract is not checking whether the sender is actually the contract's owner while calling setPassword().

Impact

Anyone is able to modify the password to an arbitrary value.

Tools Used

Foundry, VSCode, Remix

Recommendations

Implement an additional check ensuring that only the contract's owner is able to set the password. It could look as follows:

/*
* @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 {
if (msg.sender != s_owner) {
revert PasswordStore__NotOwner();
}
s_password = newPassword;
emit SetNetPassword();
}
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.