Transparent Dishonesty: frontrunning attacks on Blockchain

ETHCC 3 · March 2020 · 20:16

Sergii Kravchenko examines front-running attacks on blockchains.

Speakers

Topics

From ETHCC 3, hosted by Ethereum France.

Transcript

do you want to keep some time for questions it said yeah he won't tell you it's like in five minutes before the end tell me five minutes okay cool hello everybody so this should be a talk of Shia and Eskander II my colleague but he unfortunately couldn't show up in Paris so I'm just gonna do his slice for him yeah so my name is sergey krutsenko I'm working at consensus diligences security

auditor along with Shayan so he and his in his colleagues he's like doing the page PhD in in Concordia University Canada and they made a awesome awesome paper last year they's like did the principles of systematization of knowledge they systemized some knowledge about front-running to make some classifications of different types of it and make it more structured so let's start with like few stories of what actually happened in history of front-running is in a serum to show

different types of it so story number one i see everybody heard about Isao zero super popular at at some point the typical i 0 looked like that so they had a website with white paper with any kind of description of what they're doing and lots of promises just to go to the moon so usually they mint it here's a 22 tier see 22 against which were tradable they had limited time for IC o---- and like it some software hard cap like sergey millions for something which is still hot but but yet so what can what could with this was a really good place for

any investors because if they are registered at ICAO it's a limited in certain limited things so maybe it requires some kyc or all the registration or anything so not everybody could do it that's why you could just put one it in it you could receive for example 1,000 token and at the same time you could go to crypto Marcos you could sell these tokens for more money because more people would want to do it not everybody can go to 2 ICO so price would be most likely higher and this was just a free money people would earn it pick them the problem about it if at some whale with lots and lots of ease

could just go there buy a lot of a lot of tokens in one transactions and earn a lot of money on crypto markets so basically could just train the di 0 for for one person and this was not the intention of the creator's so what status I said what status date when it is they are CEO so they wanted to make it more fair again and so one of the things that they did is they limited the gas price because the first person the first month the previous pictures well could just be in front of everybody by hitting the highest bidding the highest because gas price because if you're doing it for a lot of money you can pay

a lot of money for one transaction so basically every transaction that has 50 gray or more gas price we just fail and that would make it more fair so people was just lots of people could just have this gas price and they also had like dynamic cap or Cillian so it was growing over time and no one could do it by oh ho I see a limit for foreign transactions so if for example if somebody puts south and east and age there is a cap and this person returns almost all of his back and some of some amount of tokens so it was happening in June 2017 and theory is 300,000 eason in

six hours even though idea was to hesitate for like a month or something but to Alec refunded like more than 100k attempts of total even more than they actually raised so people wanted to buy more and more that seems kind of sketchy and the guys did the research in that paper so they define successful and failed transactions successful transaction is something that resulted in any token purchase failed transaction is a neutral transaction that could not do any token purchase no matter for what reason so they did the they did research about mining pools that were back then

the most popular ones and that was like distribution of failed and succeeds successful transactions across the mining poles so that was think that they expected to see but if you can see f2 pool this is something that they actually see which is kind of strange because miners shouldn't really look into the details of transactions and especially since they have like delegated money they do not do anything that they shoot into but apparently f2 pool was not like every other and that's a good example of how mining pool was looking into the

transactions and just censored yeah so they censored all the people's transactions and they only included transactions that did see status ICO so basically they just what they just balls as much as they could and didn't let other people do it yeah yeah just censorship so that was the first story of how miners can manipulate transactions and do the front-running kind of thing and other stories for mostly these are anybody who knows this project or maybe even participated in it I see some did you buy the ticket

yeah so that's kind of a gambling game I guess there's some yeah so the rule of this games like it's a smart contract it has a countdown timer if you want to participate you buy the ticket it will Chris's time abide by 30 seconds and if your ticket will be the last when timer hits zero then you William the whole pot and then goes again again in different rounds so everybody just wants to be the last one but anybody can can enter by the tick attempt and be the last one after so it's like never ending game it had a lot of east eventually in in name in its pool so how it looks like from

like from from technical perspective so imagine this is a serum and foremost with the contract working knowledge imagines are some actor called Walter let's call him Walter he deploys a bunch of sophisticated some contracts that just consumes a lot of gas in some sophisticated way well explain later why sophisticated so Walter buys the ticket and you see like the timer right now at some point like two minutes before before the timer ends some other people would also want to buy the tickets and what Walter does at that point he just tries to send lots of transactions to his contracts who is huge gas price to

just stuff the block and what we see here is that every block after that we only see his transactions and nobody else can actually participate in it so basically he just takes all the of the healthy cast limit from for the for the transactions that theorem craze and he does it again and again and this is the last block so right now timer is already zero and somebody if you can see this this chart somebody notice his behavior and did even higher clock ten times higher gas price to to win this game but it too late and he just spent a lot of a

lot of gas for for saying that Walter brings all the money which is unfortunate and it's too late but the ID is pretty interesting just to stuff the the stuff fee every block and basically blocks you see room for some time and yeah Walter wins all the money so Story number three three Jack says so Texas is a centralized exchange it's a what it usually consists of is unchanged smart contracts and of chain order books why is that is that because of chain order books should be a much faster and much

cheaper because you you have like hundred times more orders usually than actual trades and on Shane you do the actual trading as you can see this the architecture and it's all exchange connects to a Syrian like that in order to be trustless transparent and anybody can access it so yeah orders are fast and low fees and feels and cancellations they they're costly and slow but a transparent trustless and stuff like that so let's imagine some some situation some Adam wants to buy 1000 useless Assyrian tokens from the

exchange he creates an order of chain in some back-end server then Adam looks at the price of this useless the serum token and he doesn't like this price anymore he wants to cancel this order but what's happening when he's canceling it miners see his transactions they put it into the plug order is getting removed from the from the exchange and orders cancelled which is fine but what actually happens your member Walter Walter also sees this cancelled transaction

and he knows that if somebody cancels a transaction it's a bad transaction for them that means it's a good transaction for Walter to fill from the opposite side it's a good good opportunity so basically every cancel transactions can be filled by anybody who want to front run em with a higher gas price and it would be a good deal so minor would do feel order before they cancel Walter gets the money Adam is pretty sad because he has 1,000 useless issued of chickens yeah and he tries to and she also tries to cancel order which is already filled and with some gas so the only cost for Walter would be gas price of feel order

so we have like three stories what do they have what is they have in common they have in common that people say that it's a front running but this is pretty different types of attacks even though it's all front running we should somehow differentiate them so what is let's just go back what is traditional front running weather is it German coming from it's coming from normal traditional trading it means like it's like benefits from early access to market information about any upcoming transactions and it's like typically because somebody's privileged to know is like procure and

it was service tourists in in the past we're like brokers got some information from their clients like I want to buy million dollars worth of some shares if you know this information you know the price will grow that's why broker can buy an his ailment name some amount of this shares and then this client makes a huge trade price grows broker can do this can sell his to his shares and just win money it's totally legal right now regulation does not require that and like lots of people are fighting against it but it's I guess sometimes it's still done so what about blockchain front-running

everyone in the network has access to privileged information because it's totally transparent and like mine are even more privileged because they are totally in control of order of the transactions and also miners can be kind of bribed by just anybody can try to to make you higher gas price and it will order transactions accordingly so front-running in involution world is much much easier and everybody can try to do it um so the guys in can come up with with some classifications in the paper like three three different types of of front ran attacks okay yeah let's

go faster so there are lots of talks about status ICO stories people say different things about it but if apparently have to prove just manipulated things and we eventually call it displacement attack so basically attacks it just it doesn't care about other attacks should be first about other orders it should be first and then doesn't matter just just bases the soldiers it's the second story is more tricky some some people say it's fair some people's like the it's like a tricky solution but still it was a campaign game so it was like pretty much a lot of money won so this is basically a suppression attack or block Stefan attack just having create a ninja late for a for cerium so yeah as you can see

displacement doesn't really for this placement does really matter what's happening for the original transaction after the attack for the insertion it matters if you want to do like traditional foreign training you need second order to also do the trade in order to take advantage of it and suppression obviously just have create a delay and do not people to not a lot of people to do anything during that delay also there are like different types of attacks like a symmetric when you call different functions then the original transactions at your front running I guess cancel and fill order is the good example or bulk when you just heaven a lot of a lot of transactions so in the papers are like lots of case studies I

just read the paper for lots and lots of cool details this cryptic eighties should be really fun to track have the breeding and how to front run this so how you can mitigate this first of all transaction sequencing right now miners control it and what can we potentially do is to removes miners ability to do to have this control first-in first-out is not a easy way to do it if its distribution network is almost impossible because you can do transactions in different places in the world and it's hard to say who was first so right now grow a serum prioritize transactions on gas price announced is

how it works right now and people take advantage of it so as I'm of chain ordering if you have some if you have it like inside the algorithm of your exchange but it's kind of centralized and not transparent all the time or for example pseudo-random sorting of transactions like for example sodium based on on the hash of of transactions which is still you can manipulate it but just need to do some resource for it yeah another thing is confidentiality so you can actually limit the visibility of transactions and these are like different places the different things that can be then you

can try to hide so for example there are some just block chains that try to preserve privacy that preserves like current state name of the function or parameters and like most popular stuff is easy to do in in many many different contracts is kamil and trivial scheme it just is usually either hides the function in the parameter or just parameter by hashing it for example and then revealing the actual value but it also leaks information because you send money usually and it just have some information in it or use some intermediary services which is a little bit more complicated but gives a little bit more confidentiality by hiding your

address um so just just consider different design practices so assume that is front running is happening and just make it non beneficial so for example by doing bashed exchanges yeah like remove importance of transactions or during or the like do the order book non time-sensitive also like one of the cool examples of contrarian that's it's using your C twenties it's like approve is not safe against front-running that's why you usually use increase approval Duke reciprocal and so yeah just to conclude it from training is a really

popular issue in in in a serum and it requires lots of research and hopefully we can solve it at some point yeah also cool Cooling's a is theo is a cool front rhyming front right actual made by by daniel Lucas from consensus diligence and misse-x is cool smart contracts tool that might help you to avoid from trying in your code you know yeah so get in touch with Cheyenne get in touch with consensus diligence if you have any question and you can get some questions now anyone having a question

you okay thank you thank you [Applause] you