Skip to content
Business logic Audit finding Intermediate

After closing synthetix position we don't update global data for liquidations

The function that closes a Synthetix short position does not update any global accounting variables, unlike the normal liquidation path. As a result, dCDS depositors cannot withdraw their share of the liquidation proceeds because the protocol never records the available collateral.

Audinarey Follow with valuevalk

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2024-11-autonomint-judging/issues/178

Found by

Audinarey, valuevalk

Summary

After admin closes synthetix position we don't update any global variables, which means that dCDS depositors and the whole protocol cannot benefit from the liquidation and the potential gains from its shorted position.

Root Cause

closeThePositionInSynthetix() function in borrowLiquidation.sol only closes the position and does not update any global variables like in the liquidation type 1

Solidity
    function closeThePositionInSynthetix() external onlyBorrowingContract {
        (, uint128 ethPrice) = borrowing.getUSDValue(borrowing.assetAddress(IBorrowing.AssetName.ETH));
        // Submit an order to close all positions in synthetix
        synthetixPerpsV2.submitOffchainDelayedOrder(-synthetixPerpsV2.positions(address(this)).size, ethPrice * 1e16);
    }

For reference in liquidation type 1 we update many values to make the protocol aware of the fact that we have a position liquidated and its collateral is ready to be taken from dCDS depositors opted-in for that. ( other values related to yield for ABOND also shall be updated, just like in liquidation type 1 )

Solidity
      // Update the CDS data
        cds.updateLiquidationInfo(omniChainData.noOfLiquidations, liquidationInfo);
        cds.updateTotalCdsDepositedAmount(cdsAmountToGetFromThisChain);
        cds.updateTotalCdsDepositedAmountWithOptionFees(cdsAmountToGetFromThisChain);
        cds.updateTotalAvailableLiquidationAmount(cdsAmountToGetFromThisChain);
        omniChainData.collateralProfitsOfLiquidators += depositDetail.depositedAmountInETH;

        // Update the global data
        omniChainData.totalCdsDepositedAmount -= liquidationAmountNeeded - cdsProfits; //! need to revisit this
        omniChainData.totalCdsDepositedAmountWithOptionFees -= liquidationAmountNeeded - cdsProfits;
        omniChainData.totalAvailableLiquidationAmount -= liquidationAmountNeeded - cdsProfits;
        omniChainData.totalInterestFromLiquidation += uint256(borrowerDebt - depositDetail.borrowedAmount);
        omniChainData.totalVolumeOfBorrowersAmountinWei -= depositDetail.depositedAmountInETH;
        omniChainData.totalVolumeOfBorrowersAmountinUSD -= depositDetail.depositedAmountUsdValue;
        omniChainData.totalVolumeOfBorrowersAmountLiquidatedInWei += depositDetail.depositedAmountInETH;

        // Update totalInterestFromLiquidation
        uint256 totalInterestFromLiquidation = uint256(borrowerDebt - depositDetail.borrowedAmount);

        // Update individual collateral data
        --collateralData.noOfIndices;
        collateralData.totalDepositedAmount -= depositDetail.depositedAmount;
        collateralData.totalDepositedAmountInETH -= depositDetail.depositedAmountInETH;
        collateralData.totalLiquidatedAmount += depositDetail.depositedAmount;
        // Calculate the yields
        uint256 yields = depositDetail.depositedAmount - ((depositDetail.depositedAmountInETH * 1 ether) / exchangeRate);

        // Update treasury data
        treasury.updateTotalVolumeOfBorrowersAmountinWei(depositDetail.depositedAmountInETH);
        treasury.updateTotalVolumeOfBorrowersAmountinUSD(depositDetail.depositedAmountUsdValue);
        treasury.updateDepositedCollateralAmountInWei(depositDetail.assetName, depositDetail.depositedAmountInETH);
        treasury.updateDepositedCollateralAmountInUsd(depositDetail.assetName, depositDetail.depositedAmountUsdValue);
        treasury.updateTotalInterestFromLiquidation(totalInterestFromLiquidation);
        treasury.updateYieldsFromLiquidatedLrts(yields);
        treasury.updateDepositDetails(user, index, depositDetail);

        globalVariables.updateCollateralData(depositDetail.assetName, collateralData);
        globalVariables.setOmniChainData(omniChainData);

Internal pre-conditions

No response

External pre-conditions

No response

Attack Path

  • Liquidation Type 2 occurs.
  • 1x short position is submitted for the liquidated collateral
  • After some time and profits from the short position, admin closes it
  • Global variables are not updated, which means that the collateral is unused.

Impact

  • The dCDS depositors won't be able to withdraw their portion of that liquidation, as we never registered it on the global omnichain fields.

PoC

No response

Mitigation

After closing the short position update the global variables, so the protocol can work with the collateral thats now available to be withdrawn from dCDS depositors. Other factors such as yield for abond apply as well.

The original report as published on Sherlock, by Audinarey. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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 closeThePositionInSynthetix function only submits an order to close the Synthetix position and does not update the global variables that track liquidation proceeds and available collateral, unlike the liquidation type 1 path.

Impact

The dCDS depositors won't be able to withdraw their portion of that liquidation, as the protocol never registered it on the global omnichain fields.

What the attacker needed

Liquidation type 2 occurs; Admin closes the short position

The fix

After closing the short position, the global variables should be updated so the protocol can work with the collateral that is now available to be withdrawn by dCDS depositors, including yield for ABOND.

How it was found

  1. A liquidation of type 2 occurs.
  2. A short position is submitted for the liquidated collateral.
  3. After some time and profits from the short position, the admin closes it.
  4. Global variables are not updated, so the collateral remains unused.

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 a borrower is liquidated, the protocol sometimes opens a short position to protect the collateral. Later, an admin closes that short position, hopefully with a profit. This report says that closing step forgets to update the protocol's shared records, so the profit and freed collateral are invisible to the people who deposited into the dCDS pool and they cannot withdraw their share.

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.

More by Audinarey

View all

10 more disclosed reports, best first.

More from Autonomint Colored Dollar V1

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.