The PasswordStore::s_password
private variable can be read from storage by everybody.
As mentioned in the comments, the password value is not supposed to be accessible by entities other than the owner. Even though, a private variable cannot be directly accessible from the contract, any data stored on the blockchain can still be read from storage no matter what visibility the stored variable has (immutables can be read from contract bytecode).
In this case, both PasswordStore::s_password
and PasswordStore::s_owner
variables can be read from storage.
Anyone can read the password ! If the password is used to lock/unlock something important like a vault, the protocol will be completely compromised.
For the contract PasswordStore
, the core functionality which limits access to the PasswordStore::s_password
is compromised.
You can execute the following test using the command : forge test --mt test_non_owner_can_read_password -vvvv
foundry
It's better not to store any sensitive data in the blockchain.
However, if storing a password is core to the protocol, then rather than storing the actual value, the value must be hashed before storing. This way, it would be impossible for anybody but the owner to figure out the real password.
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
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.