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

Storing s_password unencrypted makes the password readable by anyone

Summary

The Passwordstore::s_password is not encrypted in any way and stored on-chain. It is publicly visible.

Vulnerability Details

Even a variable marked as private is publicly accessible. By accessing the contract's immediate storage anybody can see the password's byte representation, which can be easily converted to its corresponding string.
s_password occupies the second storage slot in Passwordstore and could be read.

Using foundry cast:

$ cast storage <Passwordstore address> 1
0x6d7950617373776f726400000000000000000000000000000000000000000014
$ cast to-ascii 0x6d7950617373776f726400000000000000000000000000000000000000000014
myPassword

Impact

The supposed secret password is visible to anyone at any time.

Tools Used

  • foundry

  • manual review

Recommendations

Generally private data should not be stored on-chain. s_password should be encrypted to ensure it is only readable by the owner.

Updates

Lead Judging Commences

inallhonesty Lead Judge about 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.