Incorrect Application of MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR on Historical Epochs
The Reward contract calculates each historical epoch's claimable cap using the current MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR value rather than the value that applied during that epoch. If governance increases the factor before users claim, their accumulated rewards from past epochs are retroactively reduced.
Originally disclosed on Immunefi
- Disclosed after under an hour
#42008 [SC-Low] Incorrect Application of MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR on Historical Epochs
Submitted on Mar 19th 2025 at 23:53:44 UTC by @MarsKittyHacker for Audit Comp | Yeet
- Report ID: #42008
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/Reward.sol
- Impacts:
- Theft of unclaimed yield
Description
Brief/Intro
The Reward contract calculates user claimable rewards across multiple epochs. During this calculation, it applies the current MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR() setting to all past epochs. This behavior creates an unintended dependency on the current cap value rather than the historical one. It is valid when claimable is more than maxClaimable.
Vulnerability Details
The formula used in the contract is:
uint256 maxClaimable = (epochRewards[epoch] / rewardsSettings.MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR());
The larger MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR is, the smaller the maxClaimable value becomes.
The vulnerability arises from the fact that:
- Users accumulate rewards over many epochs without claiming.
- When they eventually claim, the contract calculates each epoch's cap based on the current value of MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR.
- If governance increases this factor before users claim, the users' historical claimable amounts are dramatically reduced.
For example, if a user has unclaimed rewards over 100 epochs when the factor was 10, and governance changes it to 100 right before claiming, each epoch’s cap is reduced tenfold (from epochRewards/10 to epochRewards/100), effectively slashing the user's rewards retroactively.
Impact Details
- Retroactive change of the MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR enables governance to arbitrarily reduce user rewards for past epochs.
- Users who delay claiming are most affected, potentially losing significant portions of rewards.
- The economic fairness of the protocol can be compromised, undermining trust in the reward mechanism.
References
Proof of Concept
Proof of Concept
- Deploy the Reward and RewardSettings contracts.
- Set MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR to a small number (e.g., 10).
- Allow users to accumulate unclaimed rewards over several epochs.
- Before users claim, increase the factor to a large number (e.g., 1000).
- Have users call getClaimableAmount() — notice their claimable amounts are drastically lower than expected.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The contract reads the live MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR setting when computing caps for historical epochs instead of storing and using the factor that was in effect for each epoch.
Impact
Governance could retroactively reduce users' unclaimed rewards for past epochs, with users who delay claiming losing the most.
What the attacker needed
Governance changes the factor before claims; users leave rewards unclaimed across epochs
The fix
The contract should store the factor value per epoch at the time rewards are recorded and use that historical value when calculating each epoch's cap.
How it was found
- Deploy the Reward and RewardSettings contracts.
- Set MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR to a small number.
- Let users accumulate unclaimed rewards over several epochs.
- Increase the factor to a large number before users claim.
- Have users call getClaimableAmount() and observe drastically lower claimable amounts.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A smart contract lets people earn rewards over many time periods called epochs. Each epoch has a maximum amount a wallet can claim, calculated by dividing the epoch's reward pool by a setting called MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR. The bug is that when someone finally claims, the contract uses today's setting for every past epoch, so if the setting was changed to a larger number, the old caps shrink and the user gets less than they earned.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.