Cross-chain wrsETH amount is wrapped before the treasury have received it, which could revert the whole transaction
The protocol attempts to wrap wrsETH before it has been received from another chain during a dCDS withdrawal, causing the transaction to revert. This prevents users from withdrawing their funds.
Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/69
Found by
0x37, John44, valuevalk
Summary
When performing a dCDS withdrawal, if the user has opted in for liquidations, there are cases where we need to retrieve collateral (ETH/rsETH or other) from another chain. However, the protocol attempts to wrap the wrsETH before it has been received, causing the transaction to revert.
Root Cause
In the case of liquidation opt-in for a dCDS depositor, we may need to retrieve ETH from another chain. This situation occurs when liquidations happen on a different chain, and the collateral retrieved from them is stored there.
In CDSLib.sol, the liquidation calculation logic is implemented here - CDSLib.sol#L624-L777.
The issue arises because the protocol attempts to wrap the funds in the treasury before they have been received, leading to a transaction revert.
interfaces.globalVariables.oftOrCollateralReceiveFromOtherChains{value: msg.value - params.fee}(
IGlobalVariables.FunctionToDo(
// Call getLzFunctionToDo in cds library to get, which action needs to do in dst chain
getLzFunctionToDo(params.optionsFeesToGetFromOtherChain, collateralToGetFromOtherChain)
),
IGlobalVariables.USDaOftTransferData(
address(interfaces.treasury), params.optionsFeesToGetFromOtherChain
),
IGlobalVariables.CollateralTokenTransferData(
address(interfaces.treasury)
ethAmountFromOtherChain,
weETHAmountFromOtherChain,
rsETHAmountFromOtherChain
),
IGlobalVariables.CallingFunction.CDS_WITHDRAW,
msg.sender
);
if (rsETHAmountFromOtherChain > 0) {
//@audit-issue this is incorrect. Its not yet received, and we wrap it here?
@>> interfaces.treasury.wrapRsETH(rsETHAmountFromOtherChain);
}
LayerZero needs technical time to process the transaction, send it to the other chain, and wait for the other chain to respond and send the requesting chain the collateral.
Internal Preconditions
Liquidations for rsETH have occurred on the other chain, and there are not enough rsETH resources on the current chain to cover the share of rsETH owed to the dCDS user depositor.
Attack Path
A normal dCDS depositor attempts to withdraw their position, which is opted-in for liquidations.
Impact
The transaction reverts, resulting in the inability to withdraw funds from the dCDS.
Mitigation
Avoid wrapping the rsETH before receiving 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
Impact
The transaction reverts, so the user cannot withdraw funds from the dCDS.
What the attacker needed
DCDS depositor opted in for liquidations; rsETH liquidations occurred on another chain; insufficient rsETH on current chain
The fix
The protocol should avoid wrapping rsETH before it has been received from the other chain.
How it was found
- A dCDS depositor who opted in for liquidations initiates a withdrawal.
- The protocol determines that rsETH collateral must be retrieved from another chain.
- The protocol sends a cross-chain message to fetch the collateral.
- Before the collateral is received, the protocol attempts to wrap the rsETH amount.
- The wrapping call fails because the funds are not yet present, reverting the entire transaction.
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.
When you withdraw, the system sometimes needs to fetch collateral from another blockchain. It tries to convert that collateral into a wrapped token before the collateral actually arrives, so the whole withdrawal fails. This means you cannot get your money out.
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.