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:

  1. Initially, there was a distribution of 10 ZeroLend rewards to GaugeIncentiveController().

  2. Subsequently, another 10 ZeroLend rewards were distributed after an hour.

  3. At this point, totalSupply equals 0.

  4. After 13 days, Alice mints 1 Atoken, now totalSupply > 0. She then waits an additional 14 days (as defined by the DURATION variable in RewardBase) and earns 1.4 ZeroLend.

  5. Consequently, a total of 18.6 ZeroLend becomes irreversibly locked in GaugeIncentiveController().

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?