When calling the setPassword()
function, the function argument is publicly accessible using the input data from the transaction, therefore allowing anyone to retrieve the stored password.
The protocol's goal is to allow only s_owner
to call getPassword()
and retrieve the stored password in s_password
. However, when calling the setPassword()
function, the function argument is publicly accessible using the input data from the transaction, therefore allowing anyone to retrieve the password used in any transaction that called the setPassword()
function. By retrieving the password from the last transaction that called the setPassword()
function, anyone can retrieve the stored password.
Anyone can retrieve the password used in the last transaction that called the setPassword()
function, therefore rendering the entire protocol's goal useless.
The following Foundry commands show how to retrieve the password from a transaction that called the setPassword()
function:
Foundry
Don't use this protocol at all, since it's generally a bad idea to store private data on EVM compatible blockchains.
If you insist on using this protocol, you can encrypt the password off-chain before calling the setPassword()
function. However, in this case you need to store the encryption key off-chain, which renders the protocol redundant as you could use the encryption key or part of it as your 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.