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

Sensitive Data Exposure via Private State Variables in Solidity Contract

Title

Sensitive Data Exposure via Private State Variables in Solidity Contract

Summary

The PasswordStore smart contract is designed to allow a user to store a password in a private state variable, with the intention of hiding the password from unauthorized viewers. However, due to the inherent transparency of blockchain data, the password can still be accessed by individuals with the necessary skills and tools, thus leading to sensitive data exposure.

Vulnerability Details

  • Visibility Misconception: The contract uses a private state variable s_password to store the password, which only prevents other contracts from accessing it directly. However, all data on the blockchain is public, and the private visibility modifier does not hide the data from being viewed on the blockchain.

  • Function Restrictions: The contract provides a function getPassword which checks if the caller is the owner before returning the password. While this is a good practice, it only serves to restrict access at the function level and doesn't prevent the underlying data from being viewed directly on the blockchain.

  • Event Leakage: The contract emits an event SetNetPassword whenever the password is updated. Though the event does not contain the new password, it signals to potential attackers that the password has been changed, which might not be desirable.

Impact

The exposure of sensitive data like passwords could lead to unauthorized access if the password is used elsewhere. Additionally, the false assurance of privacy could lead to misuse or over-reliance on the contract for secure data storage, thereby potentially compromising user data.

Tools Used

Manual Review

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.