CVXStaker.sol Unable to process newly add rewardTokens
The CVXStaker contract stores a fixed list of reward tokens in its constructor and uses it to transfer rewards, but Convex can later add new extra reward tokens. As a result, any newly added reward tokens remain stuck in the contract and cannot be forwarded to the rewards recipient.
Submitted by bin2chen
The lack of a mechanism to modify rewardTokens[]
If convex adds new extraRewards
CVXStaker.sol cannot transfer the added token
Proof of Concept
CVXStaker.sol will pass in rewardTokens[] in constructor and in getReward(), loop this array to transfer rewardTokens
function getReward(bool claimExtras) external {
IBaseRewardPool(cvxPoolInfo.rewards).getReward(
address(this),
claimExtras
);
if (rewardsRecipient != address(0)) {
for (uint i = 0; i < rewardTokens.length; i++) { //<--------@audit loop, then tranfer out
uint256 balance = IERC20(rewardTokens[i]).balanceOf(
address(this)
);
IERC20(rewardTokens[i]).safeTransfer(rewardsRecipient, balance);
}
}
}
The main problem is that this rewardTokens[] does not provide a way to modify it but it is possible to add a new rewardsToken in convex.
The following code is from BaseRewardPool.sol of convex
https://github.com/convex-eth/platform/blob/main/contracts/contracts/BaseRewardPool.sol#L238
function addExtraReward(address _reward) external returns(bool){
require(msg.sender == rewardManager, "!authorized");
require(_reward != address(0),"!reward setting");
extraRewards.push(_reward);
return true;
}
This will result in a situation : if new extraRewards are added to IBaseRewardPool later on But since the rewardTokens of CVXStaker cannot be modified (e.g. added), then the new extraRewards cannot be transferred out of CVXStaker. After IBaseRewardPool(cvxPoolInfo.rewards).getReward(), the newly added token can only stay in the CVXStaker contract.
Recommended Mitigation Steps
Add a new method to modifyCVXStaker.rewardTokens[]
Assessed type
Context
carlitox477 (warden) commented:
Issue in QA #7 titled “CVXStaker::getReward: Possible DOS if rewardTokens is enough large” is a dup of this one
@carlitox477 - This is not true. The issue in QA#7 is related to a DoS if there are too many rewards in claim rewards. This issue says if new rewards are added to convex they will not be paid out by the contract since the locally stored list is not updated.
Add a
setRewardTokensfunction.PR: https://github.com/code-423n4/2023-05-xeth/commit/1f714868f193cdeb472ec097110901a997d87ec4
Status: Mitigation confirmed with comments. Full details in reports from bin2chen, d3e4 and ronnyx2017.
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
The rewardTokens array is set only in the constructor and has no function to add or update entries, so it cannot reflect new extra rewards added by Convex.
Impact
Newly added reward tokens cannot be transferred out of CVXStaker and remain stuck in the contract.
What the attacker needed
Convex adds a new extra reward token; CVXStaker has a fixed rewardTokens list
The fix
A setRewardTokens function was added to allow updating the rewardTokens array.
How it was found
- Deploy CVXStaker with an initial rewardTokens array.
- Convex adds a new extra reward token to the BaseRewardPool.
- Call getReward on CVXStaker to claim rewards.
- The new token is not in rewardTokens, so it is not transferred out and remains in CVXStaker.
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 smart contract called CVXStaker keeps a list of tokens it expects to receive as rewards. When it claims rewards, it only sends out tokens on that list. If the outside system later adds a new reward token, the contract has no way to update its list, so the new token stays trapped in the contract.
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.