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

Anyone can read the password.

Summary

Even though getPassword function has onlyOwner check and s_password variable is private, but nothing is truly private on the blockchain. Anyone can get the hex value from the storage slots of contracts and decode them.

Vulnerability Details

Value of s_password can be fetched from the respective storage slot (i.e. 1 here). So, it's not truly private.

Impact

Password is not private, anyone can get it.

Tools Used

Manual Review

Recommendations

Only one way is to store hashed value in the contract and do the hashing off-chain and then in the contract, there can be a function that takes password as param, and hashes it and returns boolean result if calculated hash and stored hash are same. If hashes are same, then password is correct, otherwise wrong.

Updates

Lead Judging Commences

inallhonesty Lead Judge
almost 2 years ago
inallhonesty Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-anyone-can-read-storage

Private functions and state variables are only visible for the contract they are defined in and not in derived contracts. In this case private doesn't mean secret/confidential

Support

FAQs

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