The owner can set the previous password as a newPassword
in the setPassword()
function.
The setPassword()
function in contract PasswordStore.sol
allows the owner to set the previous password as new password. The function doesn't perform any checks of the input argument newPassword
, directly assign the new value to the variable s_password
:
The setPassword()
function in contract PasswordStore.sol
does not checked if the input argument newPassword
is not the previous password. If a owner make a mistake and write the previous password as input argument, the function will not complain about that. This way the function does nothing, only the owner pays for the transaction used.
The following test function demonstrates this issue. The function can be added to the file PasswordStore.t.sol
and executed in Foundry
using the following command: forge test --match-test test_owner_can_set_the_previous_password
The result is that the test is passed:
VS Code, Foundry
Add a check that the input argument newPassword
is not the same as the previous password.
The function getPassword()
should be declared as public
to use it in the setPassword()
function.
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.