Users may receive fewer rewards due to the change in reward limits
The reward contract calculates a per-epoch maximum claimable amount using a global factor that can be changed by the owner. If the factor is lowered, users who have not yet claimed rewards for past epochs will receive less than they were originally entitled to, and the difference is permanently lost.
- Disclosed after under an hour
#41664 [SC-Low] Users may receive fewer rewards due to the change in reward limits
Submitted on Mar 17th 2025 at 12:22:20 UTC by @zaevlad for Audit Comp | Yeet
- Report ID: #41664
- Report Type: Smart Contract
- Report severity: Low
- Target: https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/Reward.sol
- Impacts:
- Permanent freezing of unclaimed yield
Description
Brief/Intro
The max reward amount is based on the calculation of epoch rewards and MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR value. If its value will be changed, users may get less rewards than expected.
Vulnerability Details
After every game users can claim thier rewards by clalling claim() in the REwards contract.
The function defines the max reward amount and max aount that can be claimed by a user:
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;
@> 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;
}
MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR is a base value for each epoch that can be changed in the RewardsSettings contract. The default value is 30. This means that the maximum claimable amount for each user cannot exceed 30% of the total amount for the epoch.
From a functional point of view, there is no mechanism in the code to carry over 'surpluses' to the next epoch. So any unclaimed rewards are lost.
Also there is no requirement for the user to call the claim() function after the epoch ends. He can wait for several epochs to end to get rewards from all of them.
If MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR is changed to a lower value, such as 25, users will lose a portion of their rewards forever.
Impact Details
Users may receive fewer rewards due to the change in reward limits, and these rewards will be lost.
References
https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/RewardSettings.sol#L41\\ https://github.com/immunefi-team/audit-comp-yeet/blob/main/src/Reward.sol#L187
Proof of Concept
Proof of Concept
Let's make a simple example:
Alice: 500 YEET
Bob: 300 YEET
Rob: 200 YEET
epochRewards[epoch] = 1000 tokens
MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR = 2 (maxClaimable = 500)
For Alice the amount of rewards can be the max amount and she will not loose anything:
Alice:
userShare = (500 * 1e18) / 1000 = 0.5e18
claimable = (0.5e18 * 1000) / 1e18 = 500 tokens
maxClaimable = 1000 / 2 = 500 tokens
Finaly Alice gets 500 tokens
However if the MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR will be cahnged to 3:
maxClaimable = 1000 / 3 = 333 tokens
Alice will get 333 tokens instead of 500. So she looses 167 reward tokens.
And this amount will be lost forever. If she's trying to claim rewards for more than one epoch, the amount lost may be higher.
Consider storing the MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR separately for each epoch.
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 uses a single, mutable global factor to compute the per-epoch claim cap for all past epochs, so changing the factor retroactively alters the maximum claimable amount for epochs that have already ended.
Impact
Users may receive fewer rewards than expected, and the lost portion is permanently lost.
What the attacker needed
User has unclaimed rewards from a past epoch; owner changes the reward cap factor
The fix
The factor should be stored separately for each epoch so that changing it does not affect past epochs.
How it was found
- A user earns rewards in an epoch but does not claim immediately.
- The owner changes MAX_CAP_PER_WALLET_PER_EPOCH_FACTOR to a lower value.
- The user later calls claim() for that past epoch.
- The claimable amount is recalculated using the new lower factor, reducing the payout.
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.
In this reward system, each user can earn a share of a pool for each period (epoch). There is a cap on how much one user can claim per epoch, set by a number that the owner can change. If that number is changed after an epoch ends but before a user claims, the user may get less than they earned, and the missing amount is not saved for later.
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.