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

Password is not Private

Summary

The 'secret' password is actually stored publicly in the contracts storage and can easily be retrieved, the private keyword deals only with readability from other smart contracts on chain.

Vulnerability Details

the 32 byte password will be stored in the second slot of the contract storage. So this slot will contain the password and can easily be retrieved off chain.

Impact

The Contract is completely unsafe for use as any password is easily retrievable by anybody.

Tools Used

Foundry

Recommendations

Firstly, delete the @notice comment' @notice This contract allows you to store a private password that others won't be able to see. ' which is misleading and could result in end users trusting the contract to store their password.

You should not need to return the password itself from the smart contract. A better way is is to store only the hash of the password on chain.
If you truly need to be able to return the password itself, you can encrypt the password off chain in such a way that you as the owner know how to decrypt it, or you will need to use some off chain secret schema. but there is no way to securely store a password on chain which can be retrieved by the owner without any off chain aspect.

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-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.