multiHopSellCollateral() will fail due to call on an invalid market address causing bridged collateral to be locked up
The multiHopSellCollateral function fails because it calls getBorrowPartForAmount on a non-existent market on the destination chain, causing the cross-chain transaction to revert and bridged collateral to be locked. An attacker could not exploit this directly, but users attempting to leverage down would lose access to their bridged collateral.
Submitted by peakbolt
multiHopSellCollateral() allows users to leverage down by selling the TOFT collateral on another chain and then send it to host chain (Arbitrum) for repayment of USDO loan.
However, it will fail as it tries to obtain the repayableAmount on the destination chain by calling IMagnetar.getBorrowPartForAmount() on a non-existing market. That is because Singularity/BigBang markets are only deployed on the host chain.
function leverageDownInternal(
uint256 amount,
IUSDOBase.ILeverageSwapData memory swapData,
IUSDOBase.ILeverageExternalContractsData memory externalData,
IUSDOBase.ILeverageLZData memory lzData,
address leverageFor
) public payable {
_unwrap(address(this), amount);
//swap to USDO
IERC20(erc20).approve(externalData.swapper, amount);
ISwapper.SwapData memory _swapperData = ISwapper(externalData.swapper)
.buildSwapData(erc20, swapData.tokenOut, amount, 0, false, false);
(uint256 amountOut, ) = ISwapper(externalData.swapper).swap(
_swapperData,
swapData.amountOutMin,
address(this),
swapData.data
);
//@audit this call will fail as there is no market in destination chain
//repay
uint256 repayableAmount = IMagnetar(externalData.magnetar)
.getBorrowPartForAmount(externalData.srcMarket, amountOut);
Impact
The issue will prevent users from using multiHopSellCollateral() to leverage down.
Furthermore the failure of the cross-chain transaction will cause the bridged collateral to be locked in the TOFT contract on a non-host chain as the refund mechanism will also revert and retryMessage() will continue to fail as this is a permanent error.
Proof of Concept
Consider the following scenario where a user leverage down by selling the collateral on Ethereum (a non-host chain).
- User first triggers
Singularity.multiHopSellCollateral()on host chain Arbitrum. - That will call
SGLLeverage.multiHopSellCollateral(), which will conduct a cross chain message viaITapiocaOFT(address(collateral)).sendForLeverage()to bridge over and sell the collateral on Ethereum mainnet. - The collateral TOFT contract on Ethereum mainnet will receive the bridged collateral and cross-chain message via
_nonBlockingLzReceive()and thenBaseTOFTLeverageModule.leverageDown(). - The execution continues with
BaseTOFTLeverageModule.leverageDownInternal(), but it will revert as it attempt to callgetBorrowPartForAmount()for a non-existing market in Ethereum. - The bridgex collateral will be locked in the TOFT contract on Ethereum mainnet as the refund mechanism will also revert and
retryMessage()will continue to fail as this is a permanent error.
Recommended Mitigation Steps
Obtain the repayable amount on the Arbitrum (host chain) where the BigBang/Singularity markets are deployed.
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 assumes that the market contract exists on all chains, but Singularity/BigBang markets are only deployed on the host chain, so the call to getBorrowPartForAmount on a non-host chain reverts.
Impact
The issue prevents users from using multiHopSellCollateral() to leverage down, and the failure causes bridged collateral to be locked in the TOFT contract on a non-host chain because the refund mechanism also reverts and retryMessage() will continue to fail.
What the attacker needed
User uses multiHopSellCollateral; Destination chain is not host chain
The fix
Obtain the repayable amount on the Arbitrum (host chain) where the BigBang/Singularity markets are deployed.
How it was found
- User triggers Singularity.multiHopSellCollateral() on host chain Arbitrum.
- That calls SGLLeverage.multiHopSellCollateral(), which sends a cross-chain message via ITapiocaOFT.sendForLeverage() to bridge and sell collateral on Ethereum mainnet.
- The collateral TOFT contract on Ethereum receives the bridged collateral and message via _nonBlockingLzReceive() and then BaseTOFTLeverageModule.leverageDown().
- Execution continues with BaseTOFTLeverageModule.leverageDownInternal(), but it reverts because it calls getBorrowPartForAmount() for a non-existing market on Ethereum.
- The bridged collateral becomes locked in the TOFT contract on Ethereum mainnet because the refund mechanism also reverts and retryMessage() will continue to fail.
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.
This is a bug in a cross-chain lending system. When a user tries to sell collateral on another chain to repay a loan, the code asks a contract on that other chain for information that only exists on the main chain. Because that information is missing, the whole transaction fails and the user's collateral gets 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.