Front Running and Sandwich Attack Explained | QuillAudits

Table of Content:

How are transactions added to the blockchain?

Front Running:

Let’s understand Front Running using a practical example:

  1. Alice knows the answer to the given question but Bob doesn’t know it.
  2. Alice submitted the correct answer paying 15 gwei as fees.
  3. Meanwhile, Bob monitors the mempool for Alice’s answer. After finding Alice’s transaction with the answer, Bob submits the same but with higher gas fees (50 gwei).
  4. Now, what will happen is Miner will order Bob’s transaction before Alice as Bob paid higher fees. As a result, Alice loses the game and Bob wins the game gaining $100 despite not knowing the answer.

Sandwich Attack:

Let’s understand Sandwich Attack using a practical example:

  1. First, the attacker will front-run Alice’s transaction with the same swap (swapping ETH for MATIC) and thus increasing the price of MATIC.
  2. Now, after the price is increased Alice’s transaction is executed and she ends up paying more ETH for MATIC with higher price slippage.
  3. Once the victim’s transaction is executed, the attacker will swap his MATIC back to ETH and make a profit.

How to prevent these Attacks?

Web3 security- Need of the hour

Want more Such Security Blogs & Reports?

Partner with QuillAudits :

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store