The PasswordStore::s_password
variable is declared as private, but it is still accessible and readable by anyone outside of the contract.
The point of getPassword()
is that allows only the owner to retrieve the password but this is not the case because it is possible to read it from the storage.
Here is the PoC in foundry:
Unauthorized individuals can freely inspect the stored password, potentially compromising user data privacy.
foundry
There is not an ideal recommendation. Even if the clear text password is replaced with a hashed one it can be still readable and opens the door to another attack scenario by front-running the transaction of sending the password. So, a refactor of the implementation is needed and you can use the msg.sender
as a method of authentication instead of a 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.