sherlock-audit / 2024-10-gamma-rewarder-judging

7 stars 3 forks source link

Special Mercurial Elk - user can create a Distribution with fee = 0 #220

Closed sherlock-admin2 closed 2 weeks ago

sherlock-admin2 commented 2 weeks ago

Special Mercurial Elk

Low/Info

user can create a Distribution with fee = 0

Summary

For low values of _amount and protocolFee, a user can call createDistribution() avoiding paying fees to protocol

Root Cause

In GammaRewarder.sol:125 fee amount calculation does not consider that if _amount * protocolFee is < BASE_9, then fee is zero

https://github.com/sherlock-audit/2024-10-gamma-rewarder/blob/main/GammaRewarder/contracts/GammaRewarder.sol#L125

Internal pre-conditions

none

External pre-conditions

none

Attack Path

let's say that protocolFee = 10**7 (1%)

  1. user can calculate the amount in order to avoid taxes
  2. in this case _amount would be 99
  3. user can call createDistribution with _amount == 99 and avoid taxes

Impact

I know amount is very very low, but a script could automate this and protocol could loose funds from taxes

PoC

No response

Mitigation

// require amount to distribute meets the minimum to be taxed require(_amount protocolFee >= BASE_9, "..."); uint256 fee = _amount protocolFee / BASE_9;