Cointime

Download App
iOS & Android

Sandwich Attacks: Are You on the Menu?

Repost from Modern Consensus, Alice Kohn: “Sandwich Attacks: Are You on the Menu?” The full report and all related findings are available on the official website of Modern Consensus.

raditional “front running” is trading of stocks or other financial assets using privileged information about an upcoming transaction that is anticipated to significantly impact its price. For example, brokers could front run trades by using insider knowledge regarding their firm’s imminent issuance of a buy or sell recommendation to clients, a move expected to influence the asset’s price. Trading on this kind of non-public information is illegal in most jurisdictions, not only because it’s unfair to other market participants but also because it degrades the integrity of financial markets and erodes investor trust.

In the often “Wild West” of crypto markets, given that all too often lawmakers haven’t caught up with technology, regulators are preoccupied with increasing their own power or regulating by enforcement – and ultimately, the crypto community has largely failed to police itself – market participants are typically left to fend for themselves.

In the context of decentralized finance (DeFi), front running refers to the practice of a trader or bot capitalizing on advance knowledge of upcoming transactions in a blockchain network, typically on Ethereum given its outsized role, to make profitable trades.

Here’s a breakdown of how it typically works:

  • Observation: front runners use bots to monitor the pool of unconfirmed transactions (known as the mempool*) in a blockchain network. They look for large transactions that will significantly impact the price of a cryptocurrency.
  • Prediction: once a potentially profitable transaction is identified, front runners predict how this transaction will affect the market. For example, a large buy order could increase the price of a cryptocurrency.
  • Action: before the original large transaction is confirmed, the front runner quickly submits their own transaction with a higher gas fee. This higher fee incentivizes miners to prioritize and process the front runner’s transaction first.
  • Profit realization: the front runner’s transaction, processed before the large transaction, capitalizes on the anticipated price movement. For instance, they might buy a cryptocurrency before a large buy order is processed, expecting its price to increase. They then sell it at the higher price after the large transaction has influenced the market.

This practice is controversial and considered unethical by many in the crypto community. It exploits the transparent nature of blockchain transactions and can lead to market manipulation. Efforts to mitigate front running in DeFi include the development of more sophisticated transaction ordering mechanisms and privacy-enhancing technologies.

So what is a sandwich attack? This is a specific type of front running that involves placing not just one but two transactions around a large pending transaction, in order to profit from the price movement it causes. Here’s how it works:

  • First attacker transaction: the attacker spots a large trade (e.g., a buy order) in the mempool.* They then place a similar buy order just before the victim’s transaction executes, increasing the price of the asset.
  • Victim’s transaction: the large order by the victim gets executed at the now-inflated price.
  • Second attacker transaction: the attacker immediately sells the asset at this inflated price, profiting from the price difference caused by the victim’s large order.

So the attacker takes advantage of knowing a victim’s trade details in advance and manipulates the market price to their benefit, both before and after the victim’s transaction. This can lead to a worse trade outcome for the victim because of a phenomenon called “slippage” – the variance between the anticipated and executed prices of an order due to crypto’s inherent volatility when there are low trading volumes.

Ways to avoid being front run

There are several strategies and practices that can help users avoid becoming victims of front running and sandwich attacks in the DeFi space:

Slippage tolerance: setting a low slippage tolerance in decentralized exchanges (DEXes) can prevent your transaction from being executed if the price impact is too high, which is often the case in sandwich attacks.

Private transactions: some platforms offer private transaction services, where details of your transaction are not made public until they are executed. This prevents potential attackers from seeing and exploiting your transaction in advance.

Smaller transactions: large transactions are more likely to be targeted by front runners and sandwich attackers. Splitting a large transaction into smaller ones can reduce visibility and attractiveness to attackers.

Limit orders: using limit orders instead of market orders allows you to specify the maximum price you’re willing to pay or the minimum price you’re willing to accept. This can prevent buying at inflated prices due to front running.

Transaction batching: some services offer transaction batching, where multiple transactions are combined and executed together. This can obfuscate individual transaction details, making it harder for attackers to target specific trades.

Time of execution: executing transactions during less active hours can reduce the likelihood of being targeted, as there are fewer transactions in the mempool for attackers to monitor.

Flashbots: with Ethereum, using Flashbots (a system for miners and traders to directly negotiate transaction inclusion and ordering) via the wallet’s RPC settings can mitigate the risk of being front run.

DEX aggregators: using DEX aggregators such as CoW Swap can help, as they split your transaction across multiple DEXes, reducing the impact of your trade on any single liquidity pool and making it harder for attackers to profit from sandwich attacks.

Upgraded protocols: some DeFi protocols are implementing solutions to mitigate these risks, such as using different transaction processing mechanisms that are less susceptible to front running.

Constant vigilance: ultimately, staying informed about the latest security practices and being aware of the risks inherent in DeFi trading is crucial.

It’s important to remember that while these strategies can reduce the risk of being front run or sandwich attacked, they can’t eliminate it entirely. Always exercise caution and stay updated on best practices in the rapidly evolving DeFi landscape.

* A blockchain’s mempool (short for “memory pool”) functions as a temporary storage area for pending transactions, facilitating transaction validation, preventing double-spending, and enabling nodes to choose transactions for inclusion in mined blocks based on fees, which contributes to blockchain integrity and efficiency.

Comments

All Comments

Recommended for you

  • Cointime's Evening Highlights for May 24th

    1. CryptoPunks Launches “Super Punk World” Digital Avatar Series

  • An address mistakenly transferred about $7,000 in BTC to Satoshi Nakamoto’s wallet

    According to Arkham monitoring, someone accidentally sent 90% of their BTC assets to Satoshi Nakamoto's wallet address last night. They were trying to swap Ordinal for PupsToken, but ended up sending almost their entire wallet balance - about $7,000 worth of BTC.

  • USDC circulation increased by 200 million in the past 7 days

    According to official data, within the 7 days ending on May 16th, Circle issued 1.8 billion USDC, redeemed 1.6 billion USDC, and the circulation increased by 200 million. The total circulation of USDC is 33.2 billion US dollars, and the reserve is 33.4 billion US dollars, of which 3.8 billion US dollars are in cash, and Circle Reserve Fund holds 29.6 billion US dollars.

  • Bitcoin mining company Phoenix Group released its Q1 financial report: net profit of US$66.2 million, a year-on-year increase of 166%

    Phoenix Group, a listed mining company and blockchain technology provider for Bitcoin, released its Q1 financial report, with the following main points:

  • Pudgy Penguins and Lotte strategically cooperate to expand into the Korean market, and the floor price rose by 3.1% on the 7th

    The NFT series "Pudgy Penguins" has recently announced a strategic partnership with South Korean retail and entertainment giant Lotte Group on the X platform to expand its market in South Korea and surrounding areas. More information will be announced in the future. According to CoinGecko data, the floor price of Pudgy Penguins is currently 11.8 ETH, with a 7-day increase of 3.1%.

  • CryptoPunks Launches “Super Punk World” Digital Avatar Series

    Blue-chip NFT project CryptoPunks announced the launch of "Super Punk World" on X platform, which is the project's first release of 500 digital avatars inspired by the iconic CryptoPunks features and combined with Super Cool World attributes. It is reported that the series may launch auctions in the future, and more details about the collection and auction of this series will be announced soon.

  • Core Foundation launches $5 million innovation fund

    CoreDAO announced in a post on X platform that the Core Foundation has launched a $5 million innovation fund. The fund is currently mainly targeting the Indian market and has established strategic partnerships with the Indian Institute of Technology Bombay and some top venture capital companies to support the development of innovative blockchain projects in the country. At present, the fund has opened project funding applications.

  • Drift Foundation: The governance mechanism is gradually being improved, and DRIFT is one of the components

    The Drift Foundation stated on the X platform that the DRIFT token is a component of governance and a key element in empowering the community to shape the future. The governance mechanism is gradually improving, and more information will be announced soon.

  • U.S. Department of Justice: Two Chinese nationals arrested for allegedly defrauding at least $73 million through cryptocurrency investments

    According to the official website of the United States Department of Justice, a complaint from the central region of California was made public yesterday, accusing two Chinese nationals of playing a major role in a money laundering scheme involving cryptocurrency investment fraud.Daren Li, 41 years old, is a dual citizen of China and St. Kitts and Nevis, and is also a resident of China, Cambodia, and the United Arab Emirates. He was arrested on April 12th at Hartsfield-Jackson Atlanta International Airport and later transferred to the central region of California. Yicheng Zhang, 38 years old, is a Chinese national currently residing in Temple City, California. He was arrested yesterday in Los Angeles. Today, they are accused of leading a money laundering scheme related to an international cryptocurrency investment scam, involving at least $73 million. These arrests were made possible thanks to the assistance of our international and US partners, demonstrating the Department of Justice's commitment to continuing to combat the entire cybercrime ecosystem and prevent fraud in various financial markets.

  • Hong Kong expands digital yuan pilot to allow e-CNY wallets for cross-border payments

    The Hong Kong Monetary Authority and the People's Bank of China have expanded their cross-border digital yuan pilot to allow Hong Kong residents to use e-CNY wallets for cross-boundary payments. The digital yuan is China's central bank digital currency, which has been piloted for several years and is among the most advanced of its kind globally. Users can set up wallets using just a phone number and top them up in real-time through 17 Hong Kong retail banks. The HKMA plans to work with the Digital Currency Institute to explore enhancing interoperability in payments and corporate use cases, such as cross-border trade settlement.