# Defeating front-runners with Submarine Sends by Lorenz Breidenbach & Tyler Kell (Devcon4)

- Channel: [Devcon](https://streameth.org/devcon)
- Date: 2019-10-09
- Duration: 06:09
- Topics: blockchain, smart contracts, distributed ledger, Science & Technology
- Watch: https://streameth.org/watch/yt-JxAgNeFg6QM
- YouTube: https://www.youtube.com/watch?v=JxAgNeFg6QM

## Description

Visit the https://archive.devcon.org/ to gain access to the entire library of Devcon talks with the ease of filtering, playlists, personalized suggestions, decentralized access on IPFS and more.
https://archive.devcon.org/archive/watch/4/defeating-front-runners-with-submarine-sends

Front-running is a fundamental problem in blockchain-based markets in which miners reorder, censor, and/or insert their own (or the highest gas bidder's) transactions to directly profit from markets running on blockchain economic mechanisms. Submarine Sends (first introduced here: http://hackingdistributed.com/2017/08/28/submarine-sends/) are a powerful general-purpose mechanism to prevent front-running on Ethereum by hiding the very existence of a transaction until it is no longer front-runnable. Unfortunately, so far no practical (in terms of gas) Submarine Send constructions were known.
In this talk, I will introduce: a freshly discovered, practical Submarine Send construction that works on the Ethereum  mainnet today.LibSubmarine, an open source project implementing it.

Speaker(s): Lorenz Breidenbach, Tyler Kell
Skill level: Intermediate
Track: Security
Keywords: front-running, miners, mining, open-source

Follow us: https://twitter.com/efdevcon, https://twitter.com/ethereum
Learn more about devcon: https://www.devcon.org/
Learn more about ethereum: https://ethereum.org/ 

Devcon is the Ethereum conference for developers, researchers, thinkers, and makers. 
Devcon 4 was held in Prague, Czech Republic on Oct 30 - Nov 2, 2018.
Devcon is organized and presented by the Ethereum Foundation, with the support of our sponsors. To find out more, please visit https://ethereum.foundation/

## Transcript

so my name is Lawrence Breidenbach I'm from ETH Zurich and ic3 the initiative for cryptocurrencies and contracts and this right here is my buddy hi I'm Tyler I'm with Cornell University I'm also with ic3 and today we're going to be talking to you about lip Submarine a new smart contract library that you can use to temporarily hide transactions on aetherium and hopefully defeat frontrunners if you saw those talk yesterday so a little bit about the background alright here we go yeah so this is based on research we did at ic3 with my colleagues yeah it's working phil diane florian trauma and re jules so if you're curious about the intricacies you can check out that stuff but today I'm not going to bore you with that we're gonna dive right into sort of the motivation and then Tyler is gonna tell you a little bit about how this works so why would you want to temporarily hide transactions on etherion well basically you want to hide transactions whenever you worry about somebody else seeing the transaction and doing something evil with the knowledge that that transaction will be included later so the typical use case would be to prevent front-running but it's also useful for things like sealed bid auctions and things like that on chain voting is another case where you might want to hide the fact that you're participating in a vote clear token offerings challenge protocols and maybe soon your DAP so let me motivate this a little bit with an example in case that you want to know more about how this front-running attack would look like and I'm gonna be specifically talking about an example where we have a text contract similar to say Bank or or a uni swab that is acting as a sort of automated market-maker and so what happens here is that we have our user who wants to buy some tokens say and so she broadcasts a buy transaction to the etherium network and now that now that transaction gets propagated on the network sits in the men pole for some time and it's finally included in a block at which point it sort of reaches our decks smart contract now what a malicious user or a front-runner can do is that he can use this window of time this gap between the when the transaction is broadcast and when it is included in the block knowing that the transaction will be included in a future block but quickly sneakin in front of the transaction and sort of at our users expense so the way that the front-runner might be able to do this is in the simplest case by simply sandwiching this transaction so the front-runner would place a buy order in front of our users buy order this buy order would drive up the price then our users buy order would arrive buying at a higher price than a twitch would have bought if it hadn't been for the front runner and then the front runner can immediately sell again basically pocketing the spread and benefiting at our poor users expense here and this attack is far from theoretical so there's actually a blog post out there where somebody kind of computed that they could make like I don't know I think tens of thousands hundreds of thousands maybe even millions of dollars a year just running this against Bangor and with a proliferation of more and more Texas this becomes more and more of a problem so at this point I'm gonna hand over to Tyler and he's gonna tell you about how we can prevent this with Lipstadt myrin thanks Lawrence so if you notice the key problem that we have here is that there is a period of time in-between a time when a user wants to broadcast a transaction to the network and when it's actually hardened into a block and like canonically in the chain so in that period of time a attacker can see this and then futz with the order so we were thinking about how do we solve this well what's the key insight well we can hide this transaction maybe and prevent users from attackers from seeing this transaction and then they don't know that the transaction exists so then they can't front run it so how do we do this well we use a technique called a commit reveal scheme but a normal commit real scheme can't flow or hide the flow of money right because the flow of money and cerium has to be public so how do we deal with this well we we do some cryptographic magic and we make this marina dress and so then what we do is we send this money to the submarine address in the form of a commit and then it just looks like a simple scent of ether to any address on the network which is actually some like small percentage like something like 2% of all transactions on the network are actually simple sends so this is actually a lot of transactions that you can hide in and then later we can reveal the existence of this commit and sort of an attacker can see this reveal but by the time that they see this reveal the commit already happened and so they can't insert their own commit head of that committee so we can enforce an ordering of transactions for commits and then later the smart contract can go get the money and unlock the money from the account and and and get the money and so by doing this we sort of prevent the ability to front run transactions thanks for that explanation Tyler yeah and so this was just a short sneak peek unfortunately it's a little too much stuff to pack into five minutes but if you're curious I encourage you to check out loop submarineroid org we're very part of the web design at least I am although he thinks it's tacky but yeah look at the details there we have links to the papers to the blog post and all of our code is open source no token required check it out on github and yeah don't forget to Like and subscribe message us on Twitter whatever other forms of outreach people usually encourage and finally there will be a talk by our two colleagues that we mentioned before Triana scanned Ari and Stefan gasoline at the next session I think the privacy session for something yeah go check it out they will talk about how easy it is to actually take your existing contract and upgrade it using lip Submarine to proof it against front-running you
