processYield() and distributeYield() may run out of gas and revert due to long list of extra rewards/yields
The processYield() and distributeYield() functions loop over an unbounded list of extra reward tokens, and an attacker can force transfers by sending dust to each token, causing the transaction to run out of gas and revert. This prevents yield distribution to lenders.
Submitted by IllIllI, also found by leastwood and StErMi
Yields will not be able to be distributed to lenders because attempts to do so will revert.
Proof of Concept
The processYield() function loops overall of the extra rewards and transfers them
File: smart-contracts/ConvexCurveLPVault.sol #1
105 uint256 extraRewardsLength = IConvexBaseRewardPool(baseRewardPool).extraRewardsLength();
106 for (uint256 i = 0; i < extraRewardsLength; i++) {
107 address _extraReward = IConvexBaseRewardPool(baseRewardPool).extraRewards(i);
108 address _rewardToken = IRewards(_extraReward).rewardToken();
109 _transferYield(_rewardToken);
110 }
ConvexCurveLPVault.sol#L105-L110
There is no guarantee that the tokens involved will be efficient in their use of gas, and there are no upper bounds on the number of extra rewards:
function extraRewardsLength() external view returns (uint256) {
return extraRewards.length;
}
function addExtraReward(address _reward) external returns(bool){
require(msg.sender == rewardManager, "!authorized");
require(_reward != address(0),"!reward setting");
extraRewards.push(_reward);
return true;
}
Even if not every extra reward token has a balance, an attacker can sprinkle each one with dust, forcing a transfer by this function
_getAssetYields() has a similar issue:
File: smart-contracts/YieldManager.sol #X
129 AssetYield[] memory assetYields = _getAssetYields(exchangedAmount);
130 for (uint256 i = 0; i < assetYields.length; i++) {
131 if (assetYields[i].amount > 0) {
132 uint256 _amount = _convertToStableCoin(assetYields[i].asset, assetYields[i].amount);
133 // 3. deposit Yield to pool for suppliers
134 _depositYield(assetYields[i].asset, _amount);
135 }
136 }
Recommended Mitigation Steps
Include an offset and length as is done in YieldManager.distributeYield().
sforman2000 (Sturdy) confirmed
I’ve considered this issue. The reason why I chose not to raise it up is because adding reward tokens is restricted on Convex’s side. Given the number of integrations they have, it’s unlikely that they will add too many tokens or gas-guzzling ones that will cause claims to run OOG.
Nevertheless, it is a possibility, albeit an unlikely one, so I’ll let the issue stand (also since the sponsor confirmed it).
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 unbounded loop over extra rewards combined with the ability for anyone to add dust to each reward token, forcing costly transfers.
Impact
Yield distribution to lenders could be blocked, causing a denial of service, though the judge noted that adding reward tokens is restricted on Convex's side, making it unlikely.
What the attacker needed
Attacker can send tokens to the contract; extra rewards list can grow
The fix
The issue was fixed by including an offset and length parameter to limit the number of rewards processed per call, as done in YieldManager.distributeYield().
How it was found
- An attacker sends a tiny amount of each extra reward token to the contract.
- When processYield() is called, it loops over all extra rewards and attempts to transfer each token.
- The transaction runs out of gas and reverts, preventing yield distribution.
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.
Smart contracts have a limit on how much work they can do in one transaction; if they exceed it, the transaction fails and reverts. Here, a function loops over a list of reward tokens that can grow without limit, and an attacker can make each token require a transfer by sending a tiny amount, so the loop becomes too expensive and fails. This stops the normal distribution of yield to lenders.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.