withdrawAllAndUnwrap() the clpToken transfer to AMO.sol may be locked in the contract
The withdrawAllAndUnwrap function can send clpToken to the operator address, which is set to AMO.sol. AMO.sol has no way to use these pre-existing tokens, so they become locked in the contract.
bin2chen Follow with ronnyx2017
Originally disclosed on Code4rena
Submitted by bin2chen, also found by ronnyx2017
in withdrawAllAndUnwrap() the clpToken transfer to AMO.sol may be locked in the contract
Proof of Concept
withdrawAllAndUnwrap() You can specify sendToOperator==true to transfer the clpToken to operator
The code is as follows:
function withdrawAllAndUnwrap(
bool claim,
bool sendToOperator
) external onlyOwner {
IBaseRewardPool(cvxPoolInfo.rewards).withdrawAllAndUnwrap(claim);
if (sendToOperator) {
uint256 totalBalance = clpToken.balanceOf(address(this));
clpToken.safeTransfer(operator, totalBalance); //<------@audit transfer to operator (AMO)
}
}
current protocols, operator is currently set to AMO.sol as normal
But AMO.sol doesn’t have any way to use the transferred clpToken. The reason is that in AMO.sol, the method that transfers the clpToken, the number of transfers is from the newly generated clpToken from curvePool
It doesn’t include clpToken that already exists in AMO.sol contract, for example (rebalanceDown/addLiquidity/addLiquidityOnlyStETH)
example rebalanceDown:
function rebalanceDown(
RebalanceDownQuote memory quote
)
...
lpAmountOut = curvePool.add_liquidity(amounts, quote.minLpReceived);
IERC20(address(curvePool)).safeTransfer(
address(cvxStaker),
lpAmountOut //<---------@audit this clpToken from curvePool
);
cvxStaker.depositAndStake(lpAmountOut);
So the clpToken transferred to ‘AMO.sol’ by withdrawAllAndUnwrap() will stay in the AMO contract and it is locked.
Recommended Mitigation Steps
modify withdrawAllAndUnwrap() , directly transfer to msg.sender.
Assessed type
Context
Change
sendToOperatortosendToOwner.PR: https://github.com/code-423n4/2023-05-xeth/commit/a840dc0b8a1de59a3ea06e0814ea3ce26707bdae
Status: Mitigation confirmed. Full details in reports from ronnyx2017, bin2chen and d3e4.
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 withdrawAllAndUnwrap function transfers tokens to the operator address without checking whether the operator can handle pre-existing tokens.
Impact
Tokens sent to AMO.sol via withdrawAllAndUnwrap become locked and unusable.
What the attacker needed
Operator set to AMO.sol; owner calls withdrawAllAndUnwrap with sendToOperator true
The fix
The function was changed to send tokens to the owner instead of the operator.
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 function can send tokens to another contract, but that other contract only handles tokens it creates itself. Tokens sent to it from outside are never used, so they get 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.