Skip to content
Business logic Audit finding Intermediate

Potential loss of unclaimed rewards due to updating setting MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR

The claimable reward calculation reads the current global cap setting for every past epoch, so changing that setting retroactively alters rewards already earned. An attacker or governance change that lowers the cap causes users to lose unclaimed rewards from earlier epochs.

trtrth Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

#42462 [SC-Low] Potential loss of unclaimed rewards due to updating setting `MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR`

Submitted on Mar 24th 2025 at 06:10:31 UTC by @trtrth for Audit Comp | Yeet

Description

Brief/Intro

The claimable reward amount of an user is dependant on the global setting MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR, which is not the max cap at the specified epoch. This can cause user's unclaimed reward unexpectedly changed when the global setting MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR is updated.

Vulnerability Details

The function Reward::getClaimableAmount() calculates the amount of tokens that a user can claim, such that it calculates all rewards from user's last claimed epoch to current epoch considering the max cap per wallet per epoch.

Solidity
    function getClaimableAmount(address user) public view returns (uint256) {
        uint256 totalClaimable;

        // Fixed-point arithmetic for more precision
        uint256 scalingFactor = 1e18;

        for (uint256 epoch = lastClaimedForEpoch[user] + 1; epoch < currentEpoch; epoch++) {
            if (totalYeetVolume[epoch] == 0) continue; // Avoid division by zero

            uint256 userVolume = userYeetVolume[epoch][user];
            uint256 totalVolume = totalYeetVolume[epoch];

            uint256 userShare = (userVolume * scalingFactor) / totalVolume;

>> consider max cap >>            uint256 maxClaimable = (epochRewards[epoch] / rewardsSettings.MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR());
            uint256 claimable = (userShare * epochRewards[epoch]) / scalingFactor;

            if (claimable > maxClaimable) {
                claimable = maxClaimable;
            }

            totalClaimable += claimable;
        }

        return totalClaimable;
    }

Here, there exists scenario that user can lose rewards when the setting MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR is updated.

For example:

  1. The current MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR = 5, meaning the wallet cap is 20%
  2. At epoch 10, Alice has 25% volume shares and with the current max cap setting, Alice can claim up to 20% epoch reward
  3. At epoch 20, the Yeet governance decides to update the setting MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR to new value 10, meaning the wallet cap is 10%.
  4. Assume that Alice has not claimed rewards since the epoch 10. Now at epoch 30, Alice decides to claim rewards. Now, the claimable reward amount at epoch 10 is only 10% of the epoch reward. In other words, Alice loses 10% of the epoch reward at epoch 10.

Indeed, updating the max cap setting should have effects for the epochs in the future, not the epochs in the past.

Impact Details

  • Users can lose unclaimed rewards in past epochs when MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR is updated to a higher value (decreasing max cap per wallet per epoch)
  • It can be unfair for users who claims rewards before the setting is updated and the ones who claims rewards after the setting is updated.

References

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

Proof of Concept

Proof of Concept

  • Add the test function below to file test/Reward.Test.sol, and within the test contract Reward_runFor208weeks.
Solidity
    function test_lossOfUnclaimRewards() public {
      // max cap 20%
      reward.rewardsSettings().setYeetRewardsSettings(5);

      address alice = makeAddr('alice');

      // Alice takes 100% volume shares
      reward.addYeetVolume(alice, 1000);

      // this is to end epoch and transition to next epoch
      skip(1 days + 1);
      reward.addYeetVolume(alice, 1000);

      // claimable amount before updating setting
      uint claimableBefore = reward.getClaimableAmount(alice);

      skip(1 days + 1);

      // update setting -> cap is 10%
      reward.rewardsSettings().setYeetRewardsSettings(10);

      // claimable amount after updating setting
      uint claimableAfter = reward.getClaimableAmount(alice);

      assertEq(claimableAfter, claimableBefore);
    }
  • Run the test and console shows
Bash
Failing tests:
Encountered 1 failing test in test/Reward.Test.sol:Reward_runFor208weeks
[FAIL: assertion failed: 18754428571428571428571 != 37508857142857142857142] test_lossOfUnclaimRewards() (gas: 202467)

It means that the claimable is reduced after updating the global setting MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR to a lower value

The original report as published on Immunefi, by trtrth. 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 claimable amount loop applies the current global MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR to every historical epoch instead of a per-epoch stored cap.

Impact

Users could permanently lose unclaimed rewards from past epochs when the cap setting is tightened, and users claiming before and after the change are treated unfairly.

What the attacker needed

Governance updates the cap setting; user leaves rewards unclaimed across epochs

The fix

The cap applied to each epoch should be stored per epoch so that later setting changes only affect future epochs.

How it was found

  1. Set the cap factor so the wallet cap is 20 percent.
  2. Have a user take volume share in an epoch and leave rewards unclaimed.
  3. Advance to a later epoch and update the cap factor to a stricter value.
  4. Call the claimable amount function and observe the past epoch reward is now reduced.

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 reward contract lets people claim tokens based on how much they contributed in each past period. The limit on how much one wallet can earn per period is read from a single live setting rather than being saved for each period. So if that setting is changed later, the amount people can still claim for old periods changes too, and they can end up with 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 by trtrth

View all

7 more disclosed reports, best first.

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.