This contract allows you to store a private password that others won't be able to see. It is possible to update the password at any time. The main problem in this contract is the misuse of a private variable to store a password.
The main vulnerability in this contract is the private variable s_password that is used to store the password. Private variables can only be read by the contract and are not accessible from an external contract. However, the information stored is public and can be retrieved from outside the blockchain.
The following example returns the storage value at an specific storage slot:
In this case the variable address is the contract address deployed, slot is the storage slot to retrieve information from and block the block number.
High impact.
Manual verification
Hardhat
Foundry
Solc Version: 0.8.1
Consider to store the password encrypted as a hash value and using the bytes32 data type instead of a string data type.
Add an access control mechanism to the function setPassword(). This is to prevent anyone but the owner can modify the password value.
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.