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

the state variables s_owner and s_password as private, but can still be accessed by potential intruders

Summary

The code declares the state variables s_owner and s_password as private, which is a good practice for encapsulation. However, it's important to note that their values can still be accessed externally through getter functions. To make them entirely inaccessible from outside the contract, you can use the internal visibility modifier.

Vulnerability Details

In the code, the state variables are declared as private:

address private s_owner;
string private s_password;

While these state variables are marked as private, their values can still be accessed externally using the getPassword function. Even though this access is subject to access control checks, there may be situations where you want to completely hide the variables from external access.

Impact

The impact of not making the state variables entirely inaccessible is relatively minor in this specific contract. Since the code already includes proper access control checks, the privacy of the variables is reasonably protected. However, making the variables internal would provide an extra layer of security and ensure that they cannot be accessed externally.

Tools Used

No specific tools are used for this analysis. It's a manual code review based on the provided code snippet.

Recommendations

To enhance the privacy and security of the state variables, it's recommended to use the internal visibility modifier. Here's an example of how to modify the state variable declarations:

address internal s_owner;
string internal s_password;

Using the internal modifier, you ensure that the state variables are only accessible within the current contract and its derived contracts. This makes them entirely inaccessible from outside the contract, even through getter functions.

Updates

Lead Judging Commences

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

Support

FAQs

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