BTC
ETH
HTX
SOL
BNB
View Market
简中
繁中
English
日本語
한국어
ภาษาไทย
Tiếng Việt

Detailed analysis of Ethereum DEX "clip" transaction attack

星球君的朋友们
Odaily资深作者
This article is about 1618 words, reading the full article takes about 3 minutes
Ethereum DEX "clip" transaction arbitrage, and BCH split past.
AI Summary
Expand
Ethereum DEX "clip" transaction arbitrage, and BCH split past.

Editor's Note: This article comes fromLightning HSL (ID: H13116885), Author: Huang Shiliang, reproduced by Odaily with authorization.

Lightning HSL (ID: H13116885)

Lightning HSL (ID: H13116885)

, Author: Huang Shiliang, reproduced by Odaily with authorization.
A special kind of arbitrage has appeared on the Ethereum network, which reminds me of a feature upgrade that led to the split between BCH and BSV in late 2018, CTOR, which regulates transaction ordering.
secondary title
Clip Uniswap trading arbitrage
Don't care about the moral point of view of "clip trading" arbitrage attack, let's figure out what kind of black technology this is.
For the transactions of uniswap, a decentralized exchange, there is the following arbitrage logic. Take the trading pair USDT/ETH as an example.
The user, namely the victim, sent a transaction tx1, using usdt to buy ETH in the usdt/eth transaction pair of uniswap.
Assume that the initial value of the usdt/eth fund pool is (x, y). That is x usdt, y ETH.
The user initiates a transaction tx1, exchanging dx usdt for dy ETH. Note that dx is the determined amount of user spending, but the value of dy is a range before the transaction is packaged, i.e. slippage results in an upper and lower bound.
For the convenience of understanding, we directly define the attacker as a mining pool. Although technically non-mining pools can also handle it.
The attacker constructs a transaction tx0, using dx' usdt in exchange for dy' ETH.
Then the attacker constructs a transaction tx2, using dy'' ETH in exchange for dx' usdt.
As a mining pool, the attacker has the ability to pack the three transactions tx0, tx1, and tx2 into the same block, and sort and pack them strictly in the order of tx0, tx1, and tx2.
In the end, the attacker will get (0.3% fee-gas of dy''-dy'-tx0 and tx2) ETH profit.
The whole process is like this,
1. The attacker discovers the user's transaction tx1 and uses Usdt to buy ETH.
2. The attacker arranges the transaction tx0 first, raises the price of ETH, and buys dy' ETH with dx' usdt.
4. The attacker then arranges a tx2 transaction, sells dy''ETH, and recovers his own dx'Usdt cost. And because both steps 2 and 3 have raised the price of ETH, dy'' must be smaller than dy'. (dy''-dy'-fee-gas) is profit.

In the above process, the attacker can use the smart contract to calculate whether the final (dy''-dy'-fee-gas) is greater than 0, and if so, execute "package tx0-tx1-tx2", otherwise not execute. Risk-free arbitrage can be achieved.

The core of the whole attack is that the attacker can arrange the packaging order of the three transactions.
Generally speaking, Ethereum transactions are sorted in the block according to the gas fee paid by the user. But this is not a consensus rule, and mining pools can be arranged in any order. Non-mining pool attackers "clip transaction attack" use gas fees to arrange the order of two transactions.
secondary title
BCH 2018-end standard transaction order upgrade
This "clip transaction" attack strategy reminds me of the split between BCH and BSV at the end of 2018.
On November 15, 2018, the upgrade feature of BCH has a feature called CTOR, which regulates the ordering of transactions. CTOR sorts the transactions in the block in ascending order of transaction ID.
Before the upgrade, the sorting rule of packaged transactions in the BCH block is called topological sorting TTOR, which is not a consensus rule in essence, and the mining pool can arrange the sorting of transactions arbitrarily.
However, CTOR uses the order of transactions packaged into blocks as a consensus rule, that is, mining pools can only package and sort transactions in ascending order of transaction IDs. The position of all transactions in the block becomes part of the consensus.

BCH
DEX
ETH
Welcome to Join Odaily Official Community