Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: high
Valid

[H-01] Sensitive Data Exposure Due to Misunderstanding of Blockchain Transparency

Summary

The PasswordStore contract within the provided codebase is intended to securely hold a password for the contract owner. However, due to the transparent nature of blockchain technology, the private visibility specifier doesn't provide the expected level of data privacy. Despite the restrictions placed within the contract's functions, the value of the password stored in the s_password variable is publicly visible to anyone inspecting the blockchain's state.


Vulnerability Details

The contract utilizes a private variable s_password to store a password and restricts access to this password through the getPassword function, only allowing the contract owner to retrieve it. However, this mechanism is flawed due to the transparent nature of blockchain data. All data, including that marked as private, is visible to any party with access to the blockchain's state data. Additionally, the setPassword function emits an event SetNetPassword whenever the password is changed, which, while not leaking the password itself, could leak the timing of password changes.

Code Snippet:

string private s_password; // This private variable is not actually private due to blockchain transparency.
...
function setPassword(string memory newPassword) external {
s_password = newPassword;
emit SetNetPassword(); // This event can leak the timing of password changes.
}
...
function getPassword() external view returns (string memory) {
...
return s_password; // Only the owner can call this, but anyone can view s_password by inspecting the blockchain.
}

Impact

The impact of this vulnerability is high. The contract owner's password is exposed to the public, leading to a complete loss of confidentiality. This exposure could potentially lead to unauthorized access or other malicious activities if the password is reused elsewhere.


Tools Used

  • Manual Code Review


Recommendations

  • It is highly advised not to store sensitive information such as passwords on-chain. Blockchain's transparency makes it unsuitable for holding confidential data.

  • If authentication is necessary, consider implementing off-chain solutions or using cryptographic proofs, like signatures, to verify identities.

  • Replace the password storage and retrieval system with a more secure, off-chain solution to ensure the confidentiality and integrity of sensitive data.


Updates

Lead Judging Commences

inallhonesty Lead Judge
almost 2 years ago
inallhonesty Lead Judge almost 2 years ago
Submission Judgement Published
Validated
Assigned finding tags:

finding-anyone-can-read-storage

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

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.