cannot forward extra rewards from both OCY_Convex to OCT_YDL
The OCY_Convex contracts incorrectly treat Convex's VirtualBalanceRewardPool as an ERC20 token, so they cannot claim or forward extra rewards to OCT_YDL. This results in a loss of additional rewards that accumulate over time.
0xpiken Follow with AllTooWell, BoRonGod and 4 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-03-zivoe-judging/issues/479
Found by
0xpiken, AllTooWell, BoRonGod, Drynooo, Ironsidesec, den_sosnovskyi, ether_sky
Summary
Convex specifies rewardContract to be a VirtualBalanceRewardPool, but all three OCY_Convex uses it as a ERC20 token, which make it impossible to claim extra rewards and forward them to the OCT_YDL.
Vulnerability Detail
According to Convex doc:
The BaseRewardPool has an array of child reward contracts called extraRewards. You can query the number of extra rewards via baseRewardPool.extraRewardsLength(). This array holds a list of VirtualBalanceRewardPool contracts which are similar in nature to the base reward contract but without actual control of staked tokens.
This means that if a pool has CRV rewards as well as SNX rewards, the pool's main reward contract(BaseRewardPool) will distribute the CRV and the child contract(VirtualBalanceRewardPool) will distribute the SNX.
But, in current implementation: (take OCY_Convex_A for example)
// Extra Rewards
if (extra) {
uint256 extraRewardsLength = IBaseRewardPool_OCY_Convex_A(convexRewards).extraRewardsLength();
for (uint256 i = 0; i < extraRewardsLength; i++) {
address rewardContract = IBaseRewardPool_OCY_Convex_A(convexRewards).extraRewards(i);
uint256 rewardAmount = IBaseRewardPool_OCY_Convex_A(rewardContract).rewardToken().balanceOf(
address(this)
);
//@Audit rewardContract is a VirtualBalanceRewardPool
if (rewardAmount > 0) { IERC20(rewardContract).safeTransfer(OCT_YDL, rewardAmount); }
}
}
Tokens cannot be sent to YDL.
Impact
Current OCY_Convex_A, OCY_Convex_B and OCY_Convex_C cannot forward extraRewards to YDL.
Code Snippet
https://github.com/sherlock-audit/2024-03-zivoe/blob/main/zivoe-core-foundry/src/lockers/OCY/OCY_Convex_A.sol#L263 https://docs.convexfinance.com/convexfinanceintegration/baserewardpool#extra-rewards
Tool used
Manual Review
Recommendation
Use the real token address for token transfer.
Discussion
sherlock-admin4
1 comment(s) were left on this issue during the judging contest.
panprog commented:
high, dup of #477, loss of additional reward from convex. Since it accumulates over 30-days period, the loss will be significant. Both
balanceOfandsafeTransferare incorrect - they should be called onrewardToken().token(). Different dups of this mention eitherbalanceOforsafeTransfer, but not both, but I consider them to be the same root cause, so all are dups.
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/Zivoe/zivoe-core-foundry/pull/273
sherlock-admin2
The Lead Senior Watson signed off on the fix.
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 code called balanceOf and safeTransfer on the reward contract address instead of on the actual reward token address returned by rewardToken().
Impact
Extra rewards from Convex cannot be forwarded to YDL, leading to a loss of additional rewards that accumulate over 30-day periods.
What the attacker needed
Convex pool with extra rewards; OCY_Convex contracts in use
The fix
The issue was fixed by using the real token address for token transfer.
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.
Convex is a platform that gives extra rewards when you stake certain tokens. The code tried to send those extra rewards to another contract, but it used the wrong address for the reward token, so the transfer failed and the rewards were stuck.
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.