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

```HorseStore.huff::feedHorse()``` horse can't be feed all the time

Summary

In theHorseStore.huff::feedHorse() function the horses can't be feed all the time. The 0x11 timestamp mod operation causes the revert. This operation checks if the timestamp is odd. If it is, the function reverts. So the horses can't be feed if the timestamp is odd.

Vulnerability Details

#define macro FEED_HORSE() = takes (0) returns (0) {
timestamp // [timestamp]
0x04 calldataload // [horseId, timestamp]
STORE_ELEMENT(0x00) // []
// End execution
0x11 timestamp mod
endFeed jumpi
revert
endFeed:
stop
}

Impact

//Horses must be able to be fed at all times.
function testFuzz_testFeedingHorseAllTheTime(uint256 countTime) public {
uint256 horseId = horseStore.totalSupply();
console2.log("block.timestamp: %s", block.timestamp);
vm.warp(countTime);
// vm.roll(countBlock);
vm.prank(user);
horseStore.mintHorse();
uint256 lastFedTimeStamp = block.timestamp;
console2.log("lastFedTimeStamp: %s", lastFedTimeStamp);
console2.log("block.timestamp: %s", block.timestamp);
horseStore.feedHorse(horseId);
assertEq(horseStore.horseIdToFedTimeStamp(horseId), lastFedTimeStamp);
}
Failing tests:
Encountered 1 failing test in test/HorseStoreHuff.t.sol:HorseStoreHuff
[FAIL. Reason: EvmError: Revert; counterexample: calldata=0xcea30babffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
args=[115792089237316195423570985008687907853269984665640564039457584007913129639935 [1.157e77]]]
testFuzz_testFeedingHorseAllTheTime(uint256) (runs: 263, μ: 90315, ~: 90315)

Tools Used

Manual review

Recommendations

Delete the checks if the timestamp is odd.

#define macro FEED_HORSE() = takes (0) returns (0) {
timestamp // [timestamp]
0x04 calldataload // [horseId, timestamp]
STORE_ELEMENT(0x00) // []
// End execution
- 0x11 timestamp mod
- endFeed jumpi
- revert
- endFeed:
stop
}
Updates

Lead Judging Commences

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

FEED_HORSE() macro does not allow users to feed a horse if the timestamp is divisible by 17

Support

FAQs

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