Summary
Can Feed İmaginery Horsies
Vulnerability Details
There's no check for horse-ids that are minted by the protocol.Same vulnerability exist in Huff code too.
function testCanFeedNonExisthorseSolidity(uint256 _randomeId) public{
vm.startPrank(user);
horseStore.feedHorse(_randomeId);
vm.stopPrank();
vm.roll(horseStore.HORSE_HAPPY_IF_FED_WITHIN());
vm.warp(horseStore.HORSE_HAPPY_IF_FED_WITHIN());
assertEq(horseStore.isHappyHorse(_randomeId),true);
}
Impact
Can create fake happy(drugged XD) horses and can be checked via horseStore.isHappyHorse() function...
Tools Used
foundry test
Recommendations
Add simple modifier
* @param horseId the id of the horse to feed
* @notice allows anyone to feed anyone else's horse.
*/
function feedHorse(uint256 horseId) external ishorseExist(horseId) {
horseIdToFedTimeStamp[horseId] = block.timestamp;
}
modifier ishorseExist(uint256 _horseId){
ownerOf(_horseId);
_;
}