The protocol is using a private
state variable to store the owner's password under the assumption that being a "private" variable its value is a secret from everyone else except the owner; which is a completely false assumption.
In Solidity, marking a variable as private
doesn't mean that the data stored in that variable is entirely secret or private from all observers of the blockchain. While it restricts direct external access to the variable from other contracts, it's essential to understand that the data on the blockchain is inherently transparent and can be viewed by anyone. Other smart contracts and blockchain explorers can still access and read the data if they know where to look.
'Private' in Solidity primarily provides encapsulation and access control within the contract itself, rather than offering complete data privacy on the public blockchain.
Aforementioned is the s_password
variable which is being assumed as a secret by the protocol for it being a private
variable. This is a completely false assumption since all data on the blockchain is public.
Attacker: Any non-owner malicious actor on the network.
Victim: Owner of the PasswordStore protocol.
Protocol: PasswordStore is meant to allow only the owner to store and retrieve their password securely.
(Note : Though the following code fetches the Victim's password correctly in ASCII format; with my current skills in Solidity I've been struggling to make the assertEq()
function return true
when comparing the two strings. The problem seems to be with how the result of abi.encodePacked()
for anyoneCanReadPassword
variable fetched from vm.load
has a bunch of trailing zeroes in it while the same for victimPassword
doesn't.
Therefore my current POC proves the exploit by using console.log
instead of assertEq
)
Write and run the following test case in the PasswordStore.t.sol
test file.
Make sure to run the test command with -vv
flag to see the Logs
in command output.
This vulnerability completely compromises the confidentiality of the protocol and exposes the sensitive private data of the owner of the protocol to everyone on the blockchain.
Foundry
All data on the blockchain is public. To store sensitive information, additional encryption or off-chain solutions should be considered. Sensitive and personal data should never be stored on the blockchain in plaintext or weakly encrypted or encoded format.
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.