Skip to content
Business logic Audit finding Intermediate

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.

MarsKittyHacker Follow

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

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:

Solidity
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

https://github.com/immunefi-team/audit-comp-yeet/blob/da15231cdefd8f385fcdb85c27258b5f0d0cc270/src/Reward.sol#L187

Proof of Concept

Proof of Concept

  1. Deploy the Reward and RewardSettings contracts.
  2. Set MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR to a small number (e.g., 10).
  3. Allow users to accumulate unclaimed rewards over several epochs.
  4. Before users claim, increase the factor to a large number (e.g., 1000).
  5. Have users call getClaimableAmount() — notice their claimable amounts are drastically lower than expected.

The original report as published on Immunefi, by MarsKittyHacker. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

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

  1. Deploy the Reward and RewardSettings contracts.
  2. Set MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR to a small number.
  3. Let users accumulate unclaimed rewards over several epochs.
  4. Increase the factor to a large number before users claim.
  5. 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.

More from Yeet

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.