How we can front run crypto exploits before they even happen by Alexander Seleznev (@pessimistic_io)

ETHDubai 2023 · 16 Mar 2023 · 22:31

Alexander Seleznev compares proactive alerting approaches for detecting crypto exploits in real time. He discusses their strengths, limitations and possible combinations for protocols.

Speakers

Topics

From ETHDubai 2023, hosted by DeFi Dubai.

Transcript

hey everyone I think I could change the name of the talk to how we could front run earlier exploit before it happened okay so let me start with a couple of words about myself uh my name is Alex I work in web 3 security since 2017. even I started before the term work 3 came to life and since then I built two security teams and if site from hundreds of security audits that we performed we developed several open source security tools one of them

being very popular at the time and also I am host of basic block radio and I think that those of you who speak Russian might be already know my invoice yes and a couple of words about pessimistic [Music] I think I need to use this slide yeah it's not the shield a bit and to say thanks to my team because most of this presentation wouldn't be possible wouldn't be possible without their research work so pessimistic performance Audits and we performed it for the top or three companies we perform a lot of security researches and if you're a developer you should

check out our blog regarding proper Integrations with Ave compound bouncer Etc and we also develop a lot of security tooling including proprietary detectors that we are going to open source soon we'd also develop our our own static code analyzer code Swatch Smart check and the latest development is our predictive monitoring tool called spotter I will talk more about it later yeah I'll start with the problem that we are trying to solve here so crypto hacks are still huge problem and almost 4 billion dollars were either lost or

stolen in last year and the number of hacks has been growing along with the industry very fast the most common way to deal with those risks is performing one or two or three security audits but security audits cannot neither guarantee the absence of hack in your code nor scale with the same speed as an industry does and this is both because the lack of technical Talent on the market and the the natural manual nature of the Security reviews so with all that being said it's pretty obvious that our tree

industry needs a scalable Security Solutions because if we take a look at web 2 in web 2 the security the application security is highly automated so we have a lot of abbreviations and all these systems are automated There is almost no manual work involved there so what automated tools we have in web3 I will split all the approaches in to to purchase so first is before deployment and the second is after deployment so before the deployment developers can enhance the security of their system by having extensive specification large

test tube using static analysis tools fuzzing and formal verification and from these five items only third fourth and fifth are considered scalable and after the deployment uh developers can set up bug Bounty they can set up incident response Playbook key management and decentralization they can set up insurance and monitoring and on the insurance and monitoring are scalable approaches and since this talk is about monitoring let's talk more about this so monitoring tools are already widely

used and I will list several of them the first is widely known it's Defender it's it can be used to monitor events at State changes and even to send your own transactions June a great tool for monitoring business metrics tenderly it's no code forta is fantastic decentralized Universal tool for any kind of monitoring but mostly focused on security and another time for Shilling I will introduce a spotter that is instant and proactive threat alerting system so what

is proactive monitoring uh the idea of predictive proactive monitoring was born in late 2022 so it was born independently in several teams and become some great men think alike of course and the simple idea that stands behind predictive monitoring is that the biggest the bigger part of all hacks are performed is performed in several steps and these steps include funding that include that means that hacker gets money from tornado cash or from some

shady some shady addresses involved in some illegal activity then preparation for the hack which usually involves deployment of a specific malicious smart contract then the hack itself which which involves a call into a method of that smart contract and then the money laundering that means that hacker will try to launder the money he got by this illegal way so if we detect the early stages of the hack like funding and preparation we can respond to it before the third step I

mean before the actual loss of funds happened so let's imagine how we could prevent the earlier hack so let's Okay first step funding the hacker took his money from a mixer from tornado cache Second Step preparation hacker deployed the malicious smart contract with the flash loan and the third step was the hack but let's imagine that we what what would happen if on the third step we detected this transaction actually we really detected this transaction and here is the screenshot from our internal telegram chat okay so what could we do to

prevent the hack first if the protocol has the pause function we could automatically trigger the spouse function to you know to stop the attack and then try to figure out how we can deal with it next we could automatically trigger emergency funds withdrawal with users with users wallets next we could notify AML officers and law enforcement about the upcoming hacks so they can take measures to to interfere with money laundering and we could even notify the hacker himself

about that we know what we'll be doing what he will be doing now and we already take measures to interfere with them and the last we could even ask node operators to delay this transaction yes it's censorship sorry and what analysis techniques can we use to actually find out first that this particular in this particular transaction is a preparation for the hack and second what can we do to find out who is the victim first we could use static analysis using static analysis we can extract high

level information about the contract from the byte code and we also can use machine learning to capture statistical differences in byte code and I forgot to tell that oh yeah I forgot to tell that static analysis is very fast method of analyzing uh seemingly malicious malicious smart contract but static analysis is less less precise of all the methods however it's really fast the second method is dynamic analysis we could simulate transactions and check cash flow however we cannot simulate all

transactions in the mempool block because it's there are just too many of them so we could just focus on the new newly deployed smart contracts to fast them and verify whether any any of method calls of this transaction of these new smart contracts lead to hazardous consequences and this is something that still takes a lot of time like seconds but it's a very precise method of analysis next is we can use all the available information about smart contracts and transaction using machine learning to produce a risk

score the downside of this approach is that up for for this moment we have a very small training pool of attacks so Precision is still very low but I think that in the future this method would be very powerful and another approach is we can risk score addresses on blockchain we could just simply Blacklist sanctioned addresses we could Blacklist Blacklist addresses related to any illegal activity and use API from any blockchain [Music] investigators

and we could also use machine machine learning based analysis of the transaction graph to build a risk scoring model for the addresses not for the transactions and I already know a couple of projects who work work down this way uh we still have many problems to solve to because it's up to now it looks too optimistic I need to insert some pessimistic takes so first is that most protocol at this moment cannot react to identified attack in time so okay we knew that earlier is

going to be hacked what what could they do even if we notified them at this very moment so most protocols do not have both function and even if they have it they would refuse to give this power to a third party that has some closed source code so this is something that we need to address in the future you know working with the protocols and you know educating developers and developing deeper Integrations uh the second problem is of course hackers are not dumb people and as soon as they understand that we are trying to

track them down they will try to First obfuscate what they are doing so we have less chances to know what is going on and second they will try to hide their transactions so they will try to use for example flashbots private nodes you know just for us to not to see their transactions of course we can collaborate with the private pools and with flashbots to not to make it happen and third item I'll already mentioned and yes the fourth item is the problem is false positives

because as far as false positive rate is higher than some threshold there will be too too many garbage inputs so there will be too too much noise that we'll be hiding the signals so I would just try to protect curve through pool I would okay I would open the their website and copy from their interface the address of the contract of the pool dropped it into our telegram bot and then after that I would imitate the

preparation for the hack using pre-prepared smart contract and then in a second after I deployed the malicious smart contract I would get a reaction from the telegram bot so it works you know within seconds and the whole Loop of user onboarding and reaction to the hack takes less than 60 seconds with my commentary sounds cool to me [Laughter] yeah as we are active blockchain

security company we are already on boarding our car customers to spotter so MVP is available for testing guys and if you are interesting let's talk thank you that's it [Applause] it's uh it's free you can visit our website here and sign up for a free test yes the basic scenario is to just post

the protocol and find out find out what's what's wrong what how the hacker could what hacker could do and how this could be prevented there are also techniques on how to properly unpose the protocol because if you just post protocol then unpause it and hacker will steal we still do what he intended to do but yes there are several approaches but most of the protocols cannot pause just immediately instantly pose their protocols uh it's for now but I think that in the future

mostly they will Implement a kill switch because of including because of The Regulators because the regulations they will I think they will require them to implement such feature we deployed machine learning to production last week so right now we are running

back tests so I'm not ready to answer this question yet yeah yeah because we are still still in a testing environment it's precede sorry we are we have several hypotheses on how to properly uh price uh the this tool and you know we have two hypotheses first is uh boring subscription it's you know it's a kind of kind of insurance

and then uh the second approach is Implement some kind of bug bouncy so if we save someone's assets we can ask for a small part of the saved assets right five percent I don't know sorry no information permission no no yeah of course of course to just monitor their smart contracts we do not need any information

because all it's it's blockchain everything is public but in order for them to react to this you know of course we need to integrate with them and pretty tightly okay of course it's the first thing everyone asks and it's it's interesting that it was it was not the first question uh we want to we want to integrate with flashbots also because I think they are not happy and that illegal activity go through them

yes I said this idea uh you know is a was born in the late 2022 in by several teams independently and it's interesting that several teams from around the world are working on this solution but however everyone is very early and as far as I know we are either first or one of the first teams who actually offer test drive to their customers yes we can we can

react we can at least notify the protocol that there is some attack that is preparing and that this protocol is going to be victim of this attack it provides depending on the hacker but usually it's like several minutes yes but we are not we are not focused on

transactions on these simple transactions we are focused mostly on a complex hacker transactions which uh if transactions involves the deployment of additional smart contract with very complex logic it's either complex Arbitrage or a hacker so the the problem is not to you know to differentiate the simple withdrawal from hacker transaction the problem is to differentiate a complex Arbitrage from hacker transaction I think I can say thank you