sherlock-audit / 2024-06-makerdao-endgame-judging

1 stars 1 forks source link

newt - No minimum threshold for distribute function #49

Closed sherlock-admin2 closed 1 month ago

sherlock-admin2 commented 1 month ago

newt

Medium

No minimum threshold for distribute function

Summary

The function distribute in its current form ensures that the amount to be distributed is greater than 0. However, it does not account for scenarios where the amount might be very small (e.g 1 or 1.0), which could lead to issues in the distribution process. Small amounts may lead to rounding errors.

Vulnerability Detail

If the amount is very small (e.g., 1 or 1.0), it could lead to negligible distributions which might not be effective or could incur unnecessary gas costs. For some tokens, transferring very small amounts might lead to precision issues or might be blocked by the token contract if it has minimum transfer amount requirements.

Impact

The impact can range from moderate to high depending on the frequency and context of these small distributions. If small distributions occur frequently, the cumulative gas costs and operational inefficiencies can become significant. This results in inefficient use of resources.

Code Snippet

function distribute() external returns (uint256 amount) {
    require(vestId != INVALID_VEST_ID, "VestedRewardsDistribution/invalid-vest-id");

    amount = dssVest.unpaid(vestId);
    require(amount > 0, "VestedRewardsDistribution/no-pending-amount");

    lastDistributedAt = block.timestamp;
    dssVest.vest(vestId, amount);

    require(gem.transfer(address(stakingRewards), amount), "VestedRewardsDistribution/transfer-failed");
    stakingRewards.notifyRewardAmount(amount);

    emit Distribute(amount);
}

https://github.com/sherlock-audit/2024-06-makerdao-endgame/blob/dba30d7a676c20dfed3bda8c52fd6702e2e85bb1/endgame-toolkit/src/VestedRewardsDistribution.sol#L152-L165

Tool used

Manual Review

Recommendation

Implement minimum amount threshold

telome commented 1 month ago

There is no motivation for any keeper to trigger reward distribution for tiny amounts. Their gas cost would outweigh any potential profit (non of which was shown in the submission).

With regards to the precision issue that was raised - this is a known issue as per 5.1 in https://github.com/makerdao/endgame-toolkit/blob/5dc625fd6a07c7c24a97a45553c2287f38807e44/audits/ChainSecurity_Maker_EndGame_Toolkit_audit_v3.pdf