Bug in claim allows users who are disqualified to claim their previously earned emissions
The claim function checked a user's reward eligibility before refreshing their status, so a user whose collateral value had fallen below the required threshold after a price change could still claim previously earned emissions. An attacker could therefore collect rewards they were no longer entitled to.
Submitted by rscodes, also found by pkqs90
In ChefIncentivesController.sol:
function claim(address _user, address[] memory _tokens) public whenNotPaused {
if (eligibilityMode != EligibilityModes.DISABLED) {
-> if (!eligibleDataProvider.isEligibleForRewards(_user)) revert EligibleRequired();
-> checkAndProcessEligibility(_user, true, true);
}
........
}
The function calls isEligibleForRewards without calling refresh; hence, things like disqualification resulting from a change in price will not be accounted for. This transaction will go through without reverting, allowing the user to claim even though his total value locked is now below 5% of his debt due to the price change of the token.
The checkAndProcessEligibility(_user, true, true); function, however, does include refresh, which will update the user’s status. Hence, that line should be called first, so that the transaction will revert in the if statement, to prevent malicious lockers from calling this function even when they are not eligible.
Recommended Mitigation Steps
function claim(address _user, address[] memory _tokens) public whenNotPaused {
if (eligibilityMode != EligibilityModes.DISABLED) {
- if (!eligibleDataProvider.isEligibleForRewards(_user)) revert EligibleRequired();
- checkAndProcessEligibility(_user, true, true);
// swap the order !!
+ checkAndProcessEligibility(_user, true, true);
+ if (!eligibleDataProvider.isEligibleForRewards(_user)) revert EligibleRequired();
}
_updateEmissions();
uint256 currentTimestamp = block.timestamp;
uint256 pending = userBaseClaimable[_user];
userBaseClaimable[_user] = 0;
uint256 _totalAllocPoint = totalAllocPoint;
uint256 length = _tokens.length;
for (uint256 i; i < length; ) {
if (!validRTokens[_tokens[i]]) revert InvalidRToken();
VaultInfo storage pool = vaultInfo[_tokens[i]];
if (pool.lastRewardTime == 0) revert UnknownPool();
_updatePool(pool, _totalAllocPoint);
UserInfo storage user = userInfo[_tokens[i]][_user];
uint256 rewardDebt = (user.amount * pool.accRewardPerShare) / ACC_REWARD_PRECISION;
pending = pending + rewardDebt - user.rewardDebt;
user.rewardDebt = rewardDebt;
user.lastClaimTime = currentTimestamp;
unchecked {
i++;
}
}
_vestTokens(_user, pending);
eligibleDataProvider.updatePrice();
}
Assessed type
Invalid Validation
amarcu (LoopFi) confirmed and commented:
Other users can claim if a user becomes ineligible, if no one claims the user can, but the check can be added. Would consider this a Medium.
Koolex (judge) decreased severity to Medium and commented:
@amarcu - per my understanding, the issue is, users are claiming based on outdated eligibility check since
checkAndProcessEligibilityis called after.
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 eligibility check reads a stale status because the refresh that updates eligibility runs after the check instead of before it.
Impact
A user who is no longer eligible, for example because a price change pushed their collateral below the required share of debt, could still claim their pending emissions.
What the attacker needed
User has pending emissions; user becomes ineligible via price change
The fix
The order should be swapped so eligibility is refreshed and processed before the eligibility check, causing the claim to revert for ineligible users.
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 pays out rewards only to users who keep enough collateral compared with their debt. The contract checked that condition using old data, then updated the data afterwards, so someone who had just become ineligible could still take the payout. Swapping the two actions fixes it.
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.