DeFiHardhat
21,000 USDC
View results
Submission Details
Severity: low
Invalid

Underflow might occur while calculating the `notHarvestable`

Summary

Underflow might occur while calculating the notHarvestable

Vulnerability Details

The function rewardToHarvestable() is used to distributes Beans to the Field. The next amount Pods in the Pod Line become Harvestable. The issue is when calcuting the notHarvestable, it might underflow if s.f.pods < s.f.harvestable; and return an unexpected huge value.

function rewardToHarvestable(uint256 amount)
internal
returns (uint256 newHarvestable)
{
@> uint256 notHarvestable = s.f.pods - s.f.harvestable; // Note: SafeMath is redundant here.
newHarvestable = amount.div(HARVEST_DENOMINATOR);
newHarvestable = newHarvestable > notHarvestable
? notHarvestable
: newHarvestable;
s.f.harvestable = s.f.harvestable.add(newHarvestable);
}

Impact

rewardToHarvestable will be highly inflated.

Tools Used

Manual Review

Recommendations

Make sure the s.f.pods > s.f.harvestable; is done before performing the substraction.

Updates

Lead Judging Commences

giovannidisiena Lead Judge about 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.