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

Access control attack

Summary

The problem with the code is that it does not adequately protect the stored password, and it relies solely on the msg.sender to check the owner's identity.

Vulnerability Details

function setPassword() don't check that the caller is owner or not

Impact

problem is that anyone who has the contract's address can become the owner and set or retrieve the password.

Tools Used

VScode

Recommendations

Use modifier to check that caller is owner

  • modifier onlyOwner() {
    require(msg.sender == s_owner, "Only the owner can call");
    _;
    }

  • function setPassword(string memory newPassword) external;

  • function setPassword(string memory newPassword) external onlyOwner;

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.