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

No check for setPassword

Summary

No authentication control in the setPassword() function.

Vulnerability Details

Password can be changed thanks to

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

Impact

Anyone can overwrite/modify the password.

Tools Used

Foundry cast :
cast send <CONTRACT_ADDRESS> "setPassword(string memory)" test --private-key $PRIVATE_KEY

Recommendations

Add a modifier to verify the owner address:

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