Accounted balance of GlpStrategy does not match withdrawable balance, allowing for attackers to steal unclaimed rewards
The GlpStrategy's reported balance excludes unclaimed rewards, so share pricing understates the strategy's true value. An attacker can deposit before rewards are harvested, receive too many shares, then harvest and withdraw to capture a disproportionate share of the unclaimed rewards.
Submitted by kaden, also found by kaden (1, 2) and cergyk
Attackers can steal unclaimed rewards due to insufficient accounting.
Proof of Concept
Pricing of shares for Yieldbox strategies is dependent upon the total underlying balance of the strategy. We can see below how we mint an amount of shares according to this underlying amount.
// depositAsset()
uint256 totalAmount = _tokenBalanceOf(asset);
if (share == 0) {
// value of the share may be lower than the amount due to rounding, that's ok
share = amount._toShares(totalSupply[assetId], totalAmount, false);
} else {
// amount may be lower than the value of share due to rounding, in that case, add 1 to amount (Always round up)
amount = share._toAmount(totalSupply[assetId], totalAmount, true);
}
_mint(to, assetId, share);
The total underlying balance of the strategy is obtained via asset.strategy.currentBalance.
function _tokenBalanceOf(Asset storage asset) internal view returns (uint256 amount) {
return asset.strategy.currentBalance();
}
GlpStrategy._currentBalance does not properly track all unclaimed rewards.
function _currentBalance() internal view override returns (uint256 amount) {
// This _should_ included both free and "reserved" GLP:
amount = IERC20(contractAddress).balanceOf(address(this));
}
As a result, attackers can:
-
Deposit a high amount when there are unclaimed rewards
- Receiving a higher amount of shares than they would if accounting included unclaimed rewards
- Harvests unclaimed rewards, increasing
_currentBalance, only after they received shares
-
Withdraw all shares
-
Now that the balance is updated to include previously unclaimed rewards, the attacker profits their relative share of the unclaimed rewards
- The more the attacker deposits relative to the strategy balance, the greater proportion of interest they receive
-
Recommended Mitigation Steps
It’s recommended that _currentBalance include some logic to retrieve the amount and value of unclaimed rewards to be included in it’s return value.
cryptolyndon (Tapioca confirmed)
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 strategy's balance function only counts the held token balance and omits unclaimed rewards, so share minting is priced against an understated total.
Impact
An attacker could steal a portion of unclaimed rewards, with the proportion growing the more they deposit relative to the strategy balance.
What the attacker needed
Unclaimed rewards present in the strategy; attacker can deposit and withdraw
The fix
The balance function should be changed to include the amount and value of unclaimed rewards in its return value.
How it was found
- Deposit a large amount while rewards are unclaimed, receiving more shares than the true value warrants.
- Harvest the unclaimed rewards so the strategy balance increases.
- Withdraw all shares to take a disproportionate share of the 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 strategy holds funds and hands out shares representing a portion of those funds. The share price is based on how much the strategy says it holds, but here that figure leaves out rewards that have been earned but not yet collected. Because the price is too low, someone can buy in cheaply, trigger collection of the rewards, and then cash out with more than they put in.
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.