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

setPassword() function does not validate password, therefore malicious values can be stored

Summary

The PasswordStore::setPassword() function does not validate the new password value before storing.

Vulnerability Details

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

Malicious or invalid password values could be stored, like empty or too long strings.

Impact

Unintended consequences from storing unexpected password values later. PoC:

function setPassword(string memory newPassword) external onlyOwner {
require(bytes(newPassword).length > 0, "Password is empty");
s_password = newPassword;
emit SetNetPassword();
}

Tools Used

  • Foundry

  • Slither

Recommendations

Add validation checks on password like minimum length requirements before storing.

+ require(bytes(newPassword).length > 0, "Password is empty");
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
JCM Submitter
almost 2 years ago
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.