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

Password can be read by anyone from storageslot

Summary

The password variable can be directly accessed from the memory slot.

Vulnerability Details

address private s_owner; //slot 0
string private s_password; //slot 1

In this scenario, the password is stored in the variable s_password, which has been designated as private. It's crucial to understand that marking a variable as private does not imply that it cannot be accessed. In fact, we can directly retrieve the password from memory slot 1.

function test_contract_memory_read() public {
bytes32 password = vm.load(address(passwordStore), bytes32(uint256(1)));
console.logString(string(abi.encodePacked(password)));
}

above code can be used to retrieve data from memory slot 0

Impact

anyone can read passwords from memory slots.

Tools Used

vscode

Recommendations

Before storing the password in the blockchain, utilize encryption methods to secure it, and then proceed with the storage process.

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.