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

Lack of access control, any address can call the functions

Summary

No modifiers like onlyOwner are used to restrict functions to only the owner of the address.

Vulnerability Details

@> function setPassword(string memory newPassword) external {
s_password = newPassword;
emit SetNetPassword();
}
@> function getPassword() external view returns (string memory) {
if (msg.sender != s_owner) {
revert PasswordStore__NotOwner();
}
return s_password;
}

Any address can call the functions setPassword() and getPassword() and access the contract state without restrictions.

Impact

Loss of authorization and access control over contract functions and state.
Poc:

modifier onlyOwner();
function setPassword(string memory newPassword) external onlyOwner {
s_password = newPassword;
emit SetNetPassword();
}
function getPassword() external view onlyOwner returns (string memory) {
if (msg.sender != s_owner) {
revert PasswordStore__NotOwner();
}
return s_password;
}

Tools Used

  • Slither

  • Foundry

Recommendations

Add onlyOwner or similar modifiers to restrict functions to only the owner.

+ modifier onlyOwner();
Updates

Lead Judging Commences

inallhonesty Lead Judge
almost 2 years ago
inallhonesty Lead Judge almost 2 years ago
Submission Judgement Published
Invalidated
Reason: Other

Support

FAQs

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