Beginner FriendlyFoundryNFT
100 EXP
View results
Submission Details
Severity: low
Valid

Can Feed İmaginery Horsies -Solidity Part

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{
//without minting
//fuzzing random value..
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);
_;
}
Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Validated
Assigned finding tags:

Nonexistent horses can be fed

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.