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

attacker can look up password by checking the associated storage slot on the blockchain

Summary

Malicious actors can look up the password without being able to call getPassword. They could just look up the appropriate storage slot on the blockchain

Vulnerability Details

Sensitive on-chain data should never be saved on the blockchain. Even when the variable 's_password' is private and getPassword is protected by a check that requires it can only be called by owner, attacker could still look up the asoociated storage slot of s_password and retrieve it. This is since by nature all blockchain data are available for everyone to see.

Impact

This contract is not appropriate tool to store a private password, because such password can always be recovered by malicious actors.

Tools Used

Foundry

Recommendations

Do not store sensitive data on-chain. If the s_password is already encrypted, it might be OK (so here owner is only storing the encrypted password, and only them has the key to decrypt the encrypted password), but there is no such mechanism mentioned in the contract, as far as I can see.

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.