The notifyRewardAmount function in the BaseGauge contract is responsible for updating the reward rate and tracking the total distributed rewards for a given period. When the function is called, it verifies that the new reward amount does not exceed the period’s maximum emission value. However, it lacks a critical check to ensure that the cumulative rewards distributed (i.e., periodState.distributed plus the new amount) do not exceed a predefined distributionCap.
Without this additional check, reward distribution can inadvertently exceed the intended cap, potentially depleting the reward pool or distorting the economic incentives of the protocol. This oversight may lead to a scenario where more rewards are allocated than intended, undermining the reward distribution mechanism, causing economic imbalance, and ultimately affecting governance and participant incentives.
The function is defined as follows:
Key Points:
The function first checks that the incoming reward amount does not exceed periodState.emission.
Missing Check:
There is no condition verifying that periodState.distributed + amount does not exceed a pre-defined distributionCap. The inline comment indicates that such a check should be in place:
After calculating the reward rate and updating periodState.distributed, the function ensures that the computed reward rate multiplied by the period duration does not exceed the contract’s reward token balance.
This helper function also performs reward cap validations:
While it checks that amount + state.distributed does not exceed state.emission, it does not enforce an external distribution cap (distributionCap), which may be designed as an upper limit on rewards distributed over a period.
Over-Distribution Risk:
Without a check against distributionCap, the contract might distribute rewards beyond the intended maximum for a given period, potentially depleting the reward token pool.
Economic Imbalance:
Excessive reward distribution can disrupt the tokenomics of the protocol, leading to unintended inflation or misaligned incentives.
Governance Impact:
Since reward rates can influence participation in governance decisions, an incorrect reward allocation mechanism could distort voting power and governance outcomes.
Intended Behavior:
The protocol should ensure that in any given period, the total distributed rewards (stored in periodState.distributed) plus the new reward amount does not exceed a predefined distributionCap.
Exploit Scenario:
Suppose the protocol’s intended distribution cap is 300,000 tokens per period. If periodState.distributed is 0 tokens and an admin(controller) calls notifyRewardAmount with an amount of 400,000 tokens, the expected behavior is to the should pass due to bug (missing conditional check)
Test Case Example:
Step 1: Create a Foundry project:
Step 2: Remove unnecessary files.
Step 3: Place all relevant contract files (including BaseGauge, RewardTokenMock, etc.) in the src directory.
Step 4: Create a test directory adjacent to src and add the test file (e.g., GaugeRewardTest.t.sol).
Step 5: Run the test:
Expected Outcome:
The test should pass when the cumulative reward distribution would exceed distributionCap.
Reward Distribution Errors:
Without a proper distribution cap check, rewards can be over-distributed beyond the intended limit, leading to depletion of the reward pool and unfair tokenomics.
Economic Imbalance:
Excessive rewards may cause unanticipated inflation, misaligning incentives and destabilizing the protocol's economic model.
Governance and Participation Distortion:
Since rewards and governance power are intertwined, excessive rewards could distort voting power and influence governance outcomes.
System Integrity:
Over time, these issues can erode user trust, reduce participation, and make the protocol vulnerable to economic attacks or manipulation.
Manual Review
Foundry
To remediate this vulnerability, update the notifyRewardAmount function to include an additional check that prevents the cumulative distributed rewards from exceeding a defined distributionCap.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.