Skip to content
DoS Audit finding Intermediate

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.

IllIllI Follow

Originally disclosed on Code4rena

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;
    }

BaseRewardPool.sol#L105-L115

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       }

YieldManager.sol#L129-L136

Recommended Mitigation Steps

Include an offset and length as is done in YieldManager.distributeYield().

sforman2000 (Sturdy) confirmed

atozICT20 (Sturdy) commented:

Fix the issue of processYield()‘s run out of gas due to convex’s extra rewards sturdyfi/code4rena-may-2022#4

hickuphh3 (judge) commented:

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).


The original report as published on Code4rena, by IllIllI. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

  1. An attacker sends a tiny amount of each extra reward token to the contract.
  2. When processYield() is called, it loops over all extra rewards and attempts to transfer each token.
  3. 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.

More by IllIllI

View all

119 more disclosed reports, best first.

More from Sturdy contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.