Usage of lastEligibleStatus can cause user to miss out on rewards on manualStopEmissionsFor invocation
When a user becomes eligible for rewards, the contract assumes all their vault balances were already updated and only refreshes the vault that triggered the action. If an admin had previously called manualStopEmissionsFor, the other vault balances were zeroed, so the user misses out on rewards from those vaults.
hash Follow with lanrebayode77 and novamanbg
Originally disclosed on Code4rena
Submitted by hash, also found by lanrebayode77 and novamanbg
Invoking manualStopEmissionsFor can cause the user to miss out on rewards from vaults even after the user becomes eligible.
Proof of Concept
If lastEligibleStatus and isCurrentlyEligible returns true, only the balance of the specific vault is updated. The idea is that whenever both these are true, all the other balances would have already been updated to the current value and hence need not be re-queried again.
function handleActionAfter(address _user, uint256 _balance, uint256 _totalSupply) external {
if (!validRTokens[msg.sender] && msg.sender != address(mfd)) revert NotRTokenOrMfd();
if (_user == address(mfd) || eligibilityExempt[_user]) {
return;
}
if (eligibilityMode == EligibilityModes.FULL) {
bool lastEligibleStatus = eligibleDataProvider.lastEligibleStatus(_user);
bool isCurrentlyEligible = eligibleDataProvider.refresh(_user);
if (isCurrentlyEligible) {
if (lastEligibleStatus) {
_handleActionAfterForToken(msg.sender, _user, _balance, _totalSupply);
} else {
_updateRegisteredBalance(_user);
}
} else {
But this assumption is broken when manualStopEmissionsFor is called which will set the balance corresponding to each vault as 0:
function manualStopEmissionsFor(address _user, address[] memory _tokens) public isWhitelisted {
if (_user == address(0)) revert AddressZero();
uint256 length = _tokens.length;
for (uint256 i; i < length; ) {
address token = _tokens[i];
....
uint256 newTotalSupply = pool.totalSupply - amount;
user.amount = 0;
user.rewardDebt = 0;
pool.totalSupply = newTotalSupply;
emit BalanceUpdated(token, _user, 0, newTotalSupply);
}
In this case, if an user’s vault position update makes the user eligible for rewards, only that specific vault associated debt will be earning rewards and all the other vault balances won’t be updated.
Recommended Mitigation Steps
The lastEligibleStatus check can be removed or it can be handled alongside the manualStopEmissionsFor implementation.
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
Likely the lastEligibleStatus shortcut assumes all vault balances are current, but manualStopEmissionsFor zeroes them without that assumption being revisited.
Impact
The user could miss out on rewards from vaults other than the one that triggered the eligibility update.
What the attacker needed
Admin calls manualStopEmissionsFor; user later becomes eligible
The fix
The lastEligibleStatus check should be removed, or manualStopEmissionsFor should be handled so the shortcut stays valid.
How it was found
- An admin calls manualStopEmissionsFor for a user, which sets each vault balance to zero.
- The user later performs an action that makes them eligible for rewards.
- Only the vault tied to that action is updated, so the other vaults earn no rewards.
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 rewards contract tracks how much each user holds in several vaults. It has a shortcut: if a user was already eligible last time, it assumes the other vault balances are up to date and skips re-checking them. An admin action can reset those balances to zero, so the shortcut leaves the user with no rewards from the other vaults.
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.