The setPassword() function is supposed to be only callable by the owner of the contract, however, there are no checks in place to confirm the owner is calling the function, meaning anyone can set the password.
The setPassword() function takes in a single string as input, then the first thing it does is set the s_password variable to whatever the input is. The second, and final, thing the function does is emit the SetNetPassword() event. Here you can see the function, and the developer's comment claiming the function "allows only the owner to set a new password".
To prove that anyone can set the password, here is a test I've added to the PasswordStore test file that allows a random address to set the password.
In this test you can see that address(1337) set the password to Froggy and we saved it in a variable called expectedPassword. After saving the variable we call the getPassword() function and store its current value to the actualPassword variable. Finally, we use assertEq() to ensure that the two variables are indeed the same.
Anyone is allowed to set the password, essentially destroying the developer's intentions.
Manual review.
To fix this I recommend you include the exact same if statement that was used inside the getPassword() function like so.
To prove that only the owner can now call the function I've modified the test I added.
As you can see, trying to call the setPassword() function from an address that isn't the owner will now revert with the PasswordStore__NotOwner() custom error.
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.