Skip to content
DoS Audit finding Intermediate

No slippage protection when exchanging with synthethix

The liquidation contract exchanges sETH for sUSD on Synthetix without checking the received amount, then calculates a margin based on the original amount. If slippage causes less sUSD to be received, the subsequent margin transfer reverts, blocking the liquidation.

valuevalk Follow

Originally disclosed on Sherlock

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

Found by

valuevalk

Summary

The lack of slippage protection when exchanging assets on Synthetix can result in bricking the liquidation process for a borrower.

Root Cause

As it can be seen from the synthetix repo and from the interface we have in autonomint:

When calling exchange() in liquidationType2 when doing liquidation in borrowingLiquidations.sol

Solidity
   synthetix.exchange(
            0x7345544800000000000000000000000000000000000000000000000000000000,
            amount,
            0x7355534400000000000000000000000000000000000000000000000000000000
        );

we are supposed to get back the amount received:

Solidity
interface ISynthetix {
    function exchange(
        bytes32 sourceCurrencyKey,
        uint sourceAmount,
        bytes32 destinationCurrencyKey
@>> ) external returns (uint amountReceived);
}

as with every dex, its almost certain amountReceived != amount, it could be a very little difference, but it would be a difference, which is enough to break next parts of our code:

Solidity
        // Exchange sETH with sUSD
        synthetix.exchange(
            0x7345544800000000000000000000000000000000000000000000000000000000,
            amount,
            0x7355534400000000000000000000000000000000000000000000000000000000
        );

        // Calculate the margin
@>>     int256 margin = int256((amount * currentEthPrice) / 100);
        // Transfer the margin to synthetix
@>>     synthetixPerpsV2.transferMargin(margin);

After exchanging the sETH and receiving sUSD, the amount of margin to be transferred to synthetixPerpsV2 is calculated based on the exact amount of ETH exchanged. However, if slightly less sUSD is received due to slippage, there won't be enough margin, and the transaction will revert when calling synthetixPerpsV2.transferMargin(margin).

Internal Preconditions

No response

External Preconditions

No response

Attack Path

  • LiquidationType2 is supposed to be called by an admin.
  • The admin is unable to call it because the transaction reverts due to the absence of slippage tolerance in the current logic.
  • This results in bricking the liquidation process and causing a denial of service (DoS) for the transaction.

Impact

  • Liquidations must be consistently available. The current logic could cause a DoS, making LiquidationType2 unavailable.

Mitigation

Use the returned amountReceived and apply slippage protection with a small deviation, such as 0–0.5%.

The original report as published on Sherlock, by valuevalk. 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 code ignores the actual amount received from the Synthetix exchange and uses the original input amount to calculate the margin, causing a revert when slippage reduces the received amount.

Impact

LiquidationType2 could become unavailable, causing a denial of service for the liquidation process.

What the attacker needed

Admin calls LiquidationType2; Slippage occurs on Synthetix exchange

The fix

The contract should use the returned amountReceived and apply slippage protection with a small deviation, such as 0–0.5%.

How it was found

  1. Admin calls LiquidationType2 to liquidate a borrower.
  2. The contract exchanges sETH for sUSD on Synthetix.
  3. Due to slippage, the received sUSD is less than the original sETH amount.
  4. The contract calculates margin using the original amount and calls transferMargin.
  5. The transaction reverts because there is not enough margin.

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 swap one cryptocurrency for another, you often get a slightly different amount than you asked for. This code assumes it gets exactly the same amount and later tries to use that full amount, which fails if the swap gave less. That failure stops the liquidation from happening.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by valuevalk

View all

2 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.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.