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

Password Stored in Plain Text

Summary

The code stores the password as a plain string in the contract's storage. This approach is insecure as it exposes the password to anyone who can access the Ethereum blockchain's data, which is a significant security risk.

Vulnerability Details

The password is stored as a plain string in the s_password variable. Ethereum's blockchain is immutable and transparent, so any data stored in the contract's storage is visible to anyone. This means that the password can be easily read by anyone who inspects the contract's storage.

string private s_password;

Impact

Storing the password in plain text in the contract's storage has the following impact:

  • Anyone with access to the Ethereum blockchain can view the password, compromising the security and confidentiality of the stored password.

Tools Used

No specific tools are used for this analysis. It's a manual code review based on the provided code.

Recommendations

To mitigate the "Password Stored in Plain Text" vulnerability, you should consider encrypting the password before storing it. Here's an example of how you can implement password encryption in Solidity:

// Use a library like OpenZeppelin's Ownable for access control
import "@openzeppelin/contracts/access/Ownable.sol";
contract PasswordStore is Ownable {
bytes32 private encryptedPassword;
event SetNetPassword();
function setPassword(bytes32 newPassword) external onlyOwner {
encryptedPassword = newPassword;
emit SetNetPassword();
}
function getPassword() external view onlyOwner returns (bytes32) {
return encryptedPassword;
}
}

In this, the password is stored as a bytes32 type, which is more secure than plain text. Additionally, the Ownable contract from OpenZeppelin is used for access control. To enhance security further, you can use encryption libraries to securely store sensitive data.

Updates

Lead Judging Commences

inallhonesty Lead Judge
about 2 years ago
inallhonesty Lead Judge about 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.