DeFiHardhatOracleProxyUpdates
100,000 USDC
View results
Submission Details
Severity: low
Invalid

`claimGerminatingRoots` Doesn't handle if Stalk is greater than UnclaimedGerminating Stalk

Summary

In the LibGermiante:claimGerminatingRoots function, there is no check to ensure that the stalk parameter (representing the amount of stalk to be claimed) is not greater than the unclaimedGerminating[season].stalk. If stalk is greater than unclaimedGerminating[season].stalk, both stalk and roots final values would become negative after subtraction, which is not acceptable.

Vulnerability Details

You can see the function here:

function claimGerminatingRoots(address account, uint32 season, uint128 stalk, bool clearOdd)
private
returns (uint128 roots)
{
AppStorage storage s = LibAppStorage.diamondStorage();
roots = calculateGerminatingRoots(season, stalk);
if (clearOdd) {
delete s.a[account].farmerGerminating.odd;
} else {
delete s.a[account].farmerGerminating.even;
}
// deduct from unclaimed values.
s.unclaimedGerminating[season].stalk = s.unclaimedGerminating[season].stalk.sub(stalk);
s.unclaimedGerminating[season].roots = s.unclaimedGerminating[season].roots.sub(roots);
}

Impact

If the stalk parameter exceeds the unclaimedGerminating[season].stalk, it would result in negative values for both stalk and roots. Storing negative values in unsigned integer variables will lead to unexpected behavior and could potentially disrupt the entire unclaimed process. This issue could introduce inconsistencies in the system and may cause unintended consequences.

Tools Used

Manual Review

Recommendations

To address this issue, you should add a check to ensure that stalk does not exceed unclaimedGerminating[season].stalk before subtracting the values. If stalk exceeds unclaimedGerminating[season].stalk, you can handle this situation appropriately, such as reverting the transaction or logging an error message.

Updates

Lead Judging Commences

giovannidisiena Lead Judge over 1 year ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement
Assigned finding tags:

Informational/Invalid

Support

FAQs

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