The function HorseStore::feedHorse
allows to be fed horse ID that is not yet minted.
The intended behavior of the HorseStore::feedHorse
is to allow anyone to feed the horse of someone else. But the function does not check if the provided horseId
is actually of a minted horse token.
Therefore, user can feed a horse with horseId
which is not minted. After that another user can minted the horse token with the corresponding horseId
(within the 24 hours) and his horse will be happy.
Let's consider the following scenario:
Alice minted a horse token with ID 0
. But Alice feed a horse with wrong ID 1
, thinking this is her horseID
. So, the function HorseStore::isHappyHorse
will return true
for the horseId 1
, but Alice's horse with horseId 0
will be unhappy . Bob minted after Alice a horse token with ID 1
. And he calls the HorseStore::isHappyHorse
function without feeding the horse and the function returns true
.
The following test shows the described scenario. You can add this test to the file Base_Test.t.sol
and you can execute it with the Foundry command: forge test --match-test "testFeedingWrongHorse" -vvv
In the documentation is said that the horse happiness is the most important part of the protocol, therefore the impact of this issue is high. This issue allows a horse with unexisting ID to be happy and a created horse (minted horse token) to be not fed and to be unhappy.
Manual Review, Foundry
Add a check in HorseStore::feedHorse
to ensure that the provided horseId
is valid.
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.