Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

newPassword can be an empty string

Summary

The PasswordStore::setPassword() function accepts an empty string as input, allowing the user to store a non-password value. While this behaviour doesn't lead to unexpected outcomes, it doesn't align with the purpose of a password storage to store an empty password.

Vulnerability Details

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

Impact

function test_can_set_empty_password() public {
vm.startPrank(owner);
string memory actualPassword = "";
passwordStore.setPassword(actualPassword);
console.log("Actual password: ", actualPassword);
assertEq(actualPassword, "");
}

Tools Used

Manual review

Recommendations

Add a checks in the PasswordStore::setPassword() function that reverts in case the password is an empty string.

function setPassword(string memory newPassword) external {
+ if (keccak256(abi.encodePacked(newPassword)) == keccak256(abi.encodePacked(""))){
+ revert SetNewPassord_EmptyPasswordNotAllowed();
+ }
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
Invalidated
Reason: Admin Input/call validation

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.