29047 - [SC - Insight] Reward is lost when totalSupply
Submitted on Mar 5th 2024 at 18:52:00 UTC by @DuckAstronomer for Boost | ZeroLend
Report ID: #29047
Report type: Smart Contract
Report severity: Insight
Target: https://github.com/zerolend/governance
Impacts:
Permanent freezing of unclaimed yield
Description
Vulnerability Details
Affected asset: governance-main/contracts/voter/gauge/RewardBase.sol
The notifyRewardAmount() function within the GaugeIncentiveController() contract (derived from RewardBase.sol) allows rewards to be sent and distributed to holders of AToken based on their eligibility determined by the EligibilityCriteria contract.
However, a crucial check is missing in the notifyRewardAmount() function. It fails to verify whether totalSupply == 0 before accepting the reward. This issue could result in the complete loss of the reward or a portion of it, which would then be locked in the GaugeIncentiveController() contract's balance indefinitely.
Consider the following scenario:
Initially, there was a distribution of 10
ZeroLendrewards toGaugeIncentiveController().Subsequently, another 10
ZeroLendrewards were distributed after an hour.At this point,
totalSupplyequals 0.After 13 days, Alice mints 1
Atoken, nowtotalSupply > 0. She then waits an additional 14 days (as defined by theDURATIONvariable inRewardBase) and earns 1.4ZeroLend.Consequently, a total of 18.6
ZeroLendbecomes irreversibly locked inGaugeIncentiveController().
For the mitigation, add a check require(totalSupply > 0) to the notifyRewardAmount() of RewardBase.
Proof of Concept
To run the Poc put it's code to the governance-main/test/Gauge.poc.ts file, generate random private key, and issue the following command:
Last updated
Was this helpful?