Loss of reward tokens during initiating withdrawal due to cooldown
When a user initiates a withdrawal, the protocol skips claiming pending rewards from external protocols if a cooldown period has not elapsed. This causes the withdrawing user to receive fewer rewards than entitled, while remaining users later receive the unclaimed rewards.
0xDeoGratias Follow with Bigsam, crunter and 3 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2025-06-notional-exponent-judging/issues/669
This issue has been acknowledged by the team but won't be fixed at this time.
Found by
0xDeoGratias, Bigsam, crunter, touristS, xiaoming90, yaractf
Summary
Root Cause
Internal Pre-conditions
External Pre-conditions
Attack Path
In Line 191 below, if the cooldown has not over yet, the protocol will skip the claiming of rewards from external protocols.
File: AbstractRewardManager.sol
183: /// @notice Executes a claim against the given reward pool type and updates internal
184: /// rewarder accumulators.
185: function _claimVaultRewards(
186: uint256 effectiveSupplyBefore,
187: VaultRewardState[] memory state
188: ) internal {
189: RewardPoolStorage memory rewardPool = _getRewardPoolSlot(); // @audit-ok
190: if (rewardPool.rewardPool == address(0)) return;
191: if (block.timestamp < rewardPool.lastClaimTimestamp + rewardPool.forceClaimAfter) return;
Concerning tracking of rewards, the invariant is that whenever there is a change in effectiveSupplyBefore (aka total supply), the protocol must claim the rewards and update the reward accumulation state variable based on the current effectiveSupplyBefore before updating the new effectiveSupply value. However, this is not always true because the protocol will sometimes skip claiming rewards.
File: AbstractYieldStrategy.sol
149: function effectiveSupply() public view returns (uint256) {
150: return (totalSupply() - s_escrowedShares + VIRTUAL_SHARES); // @audit-info VIRTUAL_SHARES = 1e6
151: }
Assume the following states at Time T0.
rewardPool.forceClaimAfteris set to 15 minutes.- The current balance of yield tokens residing in the Yield Strategy vault, the vault is earning 1 WETH per minutes.
- The current
effectiveSupply()is 10. Bob holds 5 shares, while Alice holds 5 shares. accumulatedRewardPerVaultShare= 0.
At T5 (5 minutes later since T0), 5 WETH is earned, and accumulatedRewardPerVaultShare will increase by 0.5 (5 WETH rewards divided by 10 vault shares), per Line 267 below. This basically means that each share is entitled to 0.5 WETH.
The accumulatedRewardPerVaultShare will be 0.5 now and rewardPool.lastClaimTimestamp will be set to T5.
File: AbstractRewardManager.sol
259: function _accumulateSecondaryRewardViaClaim(
260: uint256 index,
261: VaultRewardState memory state,
262: uint256 tokensClaimed,
263: uint256 effectiveSupplyBefore
264: ) private {
265: if (tokensClaimed == 0) return;
266:
267: state.accumulatedRewardPerVaultShare += (
268: (tokensClaimed * DEFAULT_PRECISION) / effectiveSupplyBefore
269: ).toUint128();
270:
271: _getVaultRewardStateSlot()[index] = state;
272: }
At T10 (10 minutes later), Bob decided to call initiateWithdraw to initiate a withdrawal, the s_escrowedShares will increase by 9. Before s_escrowedShares is increased by 5, the following updateAccountRewards function at Line 131 will be executed to ensure that Bob claims or retrieves all the reward tokens he is entitled to before initiating the withdrawal. This is critical because, after initiating the withdrawal, Bob can no longer claim the rewards, as per the protocol's design.
File: RewardManagerMixin.sol
120: /// @dev Ensures that the account no longer accrues rewards after a withdraw request is initiated.
121: function _initiateWithdraw(
122: address account,
123: uint256 yieldTokenAmount,
124: uint256 sharesHeld,
125: bytes memory data
126: ) internal override returns (uint256 requestId) {
127: uint256 effectiveSupplyBefore = effectiveSupply();
128:
129: // Claim all rewards before initiating a withdraw shares not considered
130: // in the escrow state at this point.
131: _updateAccountRewards({
132: account: account,
133: accountSharesBefore: sharesHeld,
134: accountSharesAfter: sharesHeld,
135: effectiveSupplyBefore: effectiveSupplyBefore,
136: sharesInEscrow: false
137: });
138:
139: requestId = __initiateWithdraw(account, yieldTokenAmount, sharesHeld, data);
140: }
The updateAccountRewards function will internally execute the _claimVaultRewards function in Line 159 below. Since, it is still in cooldown, the claiming of rewards from external protocols will be skipped. Even though a total reward of 5 WETH has accumulated since T5 that is awaiting to be claimed at the external protocol, it is not claimed due to the cooldown. To recap, note that from T0 to T10, 10 minutes have already been passed and a total of 10 WETH is earned. 5 WETH has been claimed and the other 5 WETH has not been claimed.
Subsequently, at Line 173, the _claimRewardToken will be executed to claim the rewards for Bob. In this case, based on the current accumulatedRewardPerVaultShare (0.5), Bob will receive 2.5 WETH. Here, we can already see a valid issue that although a total of 10 WETH is earned, Bob only received 2.5 WETH instead of 5 WETH. This means that Alice will be able to obtain a rewards of 7.5 WETH later once the cooldown is over.
File: AbstractRewardManager.sol
148: function updateAccountRewards(
149: address account,
150: uint256 effectiveSupplyBefore,
151: uint256 accountSharesBefore,
152: uint256 accountSharesAfter,
153: bool sharesInEscrow
154: ) external returns (uint256[] memory rewards) {
155: // Short circuit in this case, no rewards to claim
156: if (sharesInEscrow && accountSharesAfter > 0) return rewards;
157:
158: VaultRewardState[] memory state = _getVaultRewardStateSlot();
159: _claimVaultRewards(effectiveSupplyBefore, state);
160: rewards = new uint256[](state.length);
161:
162: for (uint256 i; i < state.length; i++) {
163: if (sharesInEscrow && accountSharesAfter == 0) {
164: delete _getAccountRewardDebtSlot()[state[i].rewardToken][account];
165: continue;
166: }
167:
168: if (0 < state[i].emissionRatePerYear) {
169: // Accumulate any rewards with an emission rate here
170: _accumulateSecondaryRewardViaEmissionRate(i, state[i], effectiveSupplyBefore);
171: }
172:
173: rewards[i] = _claimRewardToken(
174: state[i].rewardToken,
175: account,
176: accountSharesBefore,
177: accountSharesAfter,
178: state[i].accumulatedRewardPerVaultShare
179: );
180: }
181: }
The root cause here is that, during initiating withdrawal, the cooldown should not be applicable and the claiming of reward tokens from external protocol must always occur. This is ensure that the accumulatedRewardPerVaultShare is updated to the latest state before Bob claims his reward for the last time.
Impact
High, loss of funds (reward tokens) for the affected victim as shown above.
PoC
No response
Mitigation
During initiating withdrawal, the cooldown should not be applicable and the claiming of reward tokens from the external protocol must always occur. This ensures that the accumulatedRewardPerVaultShare is updated to the latest state before Bob claims his reward for the last time.
Discussion
jeffywu
Won't fix, this is the design of the system and any loss would be considered marginal.
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 cooldown check in _claimVaultRewards prevents claiming external rewards during withdrawal initiation, so the reward accumulator is not updated before the user's final claim.
Impact
The withdrawing user loses a portion of their earned reward tokens, which are later captured by remaining users.
What the attacker needed
A reward pool with a cooldown period; user initiates withdrawal during cooldown
The fix
The cooldown should not apply during withdrawal initiation; rewards must always be claimed from external protocols before the final reward calculation.
How it was found
- Set up a reward pool with a cooldown period and two users holding equal shares.
- Let rewards accumulate and be claimed once, updating the accumulator.
- Have one user initiate a withdrawal before the cooldown expires.
- Observe that the protocol skips claiming new rewards from the external pool.
- The withdrawing user receives rewards based on the stale accumulator, getting less than earned.
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.
Rewards from outside sources are only collected periodically. If you withdraw during a waiting period, the system does not collect the latest rewards before calculating your share, so you get less than you earned. The leftover rewards go to the people who stay.
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.