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

Missing access control on `PasswordStore::setPassword` allows anybody to overwrite the original password

Summary

Changing password is done via PasswordStore::setPassword and should be doable only by the owner of the contract (deployer).
Because of a missing check that caller is owner, anyone can overwrite the original password.

https://github.com/Cyfrin/2023-10-PasswordStore/blob/main/src/PasswordStore.sol#L22-L28

/*
* @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();

Tools Used

Manual review

Recommendations

Add a check that msg.sender is s_owner in setPassword.

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.