The absence of access control in the PasswordStore::setPassword() function allows anyone to access and modify the password.
When a msg.sender who is not the PasswordStore::s_owner attempts to change the password, the function currently permits it. To rectify this, we should restrict access to only the owner.
The test suite below illustrates the vulnerability's validity and severity.
Requirements
Install Foundry.
Clone the project codebase into your local workspace.
Add the tests from the Codebase section below to the PasswordStore.t.sol file in the test folder, placing it after line 33.
Step-by-step Guide to Run the Test
Ensure the above requirements are met.
Execute the following command in your terminal to run the test:
Note: Refer to the test function comments to understand the cases being tested.
The codebase below utilizes Foundry for testing.
Test Cases
Passing the above tests implies that the vulnerability:
Allows anyone to negatively affect the UX of the protocol.
Compromises the protocol's integrity.
Exposes users to potential application crashes.
Exploit Scenario
John sets a password as the account owner, but Sarah changes the password. As a result, John receives different values when attempting to retrieve the password, potentially leading to application crashes.
Foundry
To fix this bug, add a require statement that only allows the owner to successfully call the setPassword() function.
Anyone can call `setPassword` and set a new password contrary to the intended purpose.
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.