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

function setPassword allows anyone to update s_password

Summary

The function setPassword allows anyone to update the password.

Vulnerability Details

The function setPassword does not check if the function caller is s_owner, this allows anyone to update s_password.

Impact

Unauthorised update to s_password storage variable.

cast send $PASSWORD_STORE_CONTRACT_ADDRESS "setPassword(string)" "newpassword123" --rpc-url $RPC_URL --private-key $PRIVATE_KEY

Tools Used

  • Foundry

  • Slither

Recommendations

Add a check if msg.sender is s_owner before updating s_password

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.