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

Solidity Contract - Underflow Issue with IsHappyHorse

Summary

In the Solidity contract the function isHappyHorse conditional will lead to an underflow when the block timestamp is less than 86400 seconds.

Vulnerability Details

Underflows/Overflows occur when arithmetic on an unsigned integer would go out of the bounds of maximum or minimum value that type can hold.
When subtracting HORSE_HAPPY_IF_FED_WITHIN from the block.timestamp that is less than 86400 seconds you will go below 0 and thus the function will return true.

Impact

Low, I assume this will only effect production blockchains who's block timestamp is less than 1 day/86400 seconds.

Tools Used

Foundry

Recommendations

Restructure the isHappyHorse conditional to compare horseIdToFedTimeStamp[horseid] + HORSE_HAPPY_IF_FED_WITHIN >= block.timestamp
this conditional will return true otherwise false.

Updates

Lead Judging Commences

inallhonesty Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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