Skip to content
Business logic Audit finding Intermediate

Unprotected slippage tolerance can lead to user/protocol loss of funds

The rebalanceXChain() function allows any user to set the slippage tolerance for cross-chain swaps, and an attacker can front-run the transaction to set it to 100%. This could cause the protocol or users to lose funds due to unfavourable swap rates.

Ch_301 Follow with c7e7eff, cergyk and 3 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-01-derby-judging/issues/54

Found by

Ch_301, c7e7eff, cergyk, ff, tives, wzrdk3lly

Summary

Slippage is the difference between the expected price of an order and the price when the order actually executes. If the slippage tolerance is set too low, a transaction will not execute. If the slippage tolerance is set too high, users will lose money for paying more per token than intended during swaps. When a rebalance is ready to take place on Derby, any user can front run the rebalancXChain() call setting the slippage tolerance to be 100% for the xChain swap.

Vulnerability Detail

https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/MainVault.sol#L307-L320

  1. Any external user/attacker invokes the rebalanceXChain() by frontrunning the transaction when it hits the mempool

https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/XProvider.sol#L321-L333

  1. When the homechain is not equal to the controllerChain xTransfer() is called with the _slippage tolerance

https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/XProvider.sol#L152-L159

  1. This XCall will cause the rebalance to be performed, making the proper XChain swaps with the unprotected slippage tolerance.

Impact

Fulfilled swaps where the actual slippage is significantly higher than the standard tolerance of 30 (.03%) would result in loss of funds.

Code Snippet

The entrypoint for this attack occurs in the rebalanceXChain() function below https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/MainVault.sol#L307-L320

Tool used

Manual Review

Recommendation

Require minimum and maximum values that the protocol is willing to accept for a slippage tolerance that will not cause significant fund loss during Connext XChain swaps. Alternatively the rebalancXChain() call can leverage onlyDao or onlyKeeper modifiers to ensure that these are the only two trusted entities allowed to make this call as intended per the Derby Documentation.

The original report as published on Sherlock, by Ch_301. 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

Impact

Swaps could execute with slippage far above the standard 0.03%, leading to loss of funds for users or the protocol.

What the attacker needed

Attacker can front-run transactions; rebalanceXChain() is callable by anyone

The fix

The function should enforce minimum and maximum slippage bounds, or restrict callers to onlyDao or onlyKeeper.

How it was found

  1. An attacker sees a rebalanceXChain() transaction in the mempool and front-runs it with their own call.
  2. The attacker sets the slippage tolerance to 100% in their transaction.
  3. The attacker's transaction triggers xTransfer() with the high slippage tolerance.
  4. The cross-chain swap executes with the unprotected slippage, potentially at a very unfavourable rate.

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.

Slippage is the difference between the expected price of a trade and the price at which it actually executes. If someone can set the allowed slippage to a very high value, a trade might go through at a much worse price, causing a loss. Here, any user can set that high slippage by jumping ahead of the legitimate rebalance transaction.

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 Ch_301

View all

39 more disclosed reports, best first.

More from Derby

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.