The State of DeFi Security 2023

DeFi Security Summit 2023 · 15 Jul 2023 · 19:54

Peter Kacherginsky, a blockchain threat researcher at Coinbase and editor of the Blockchain Threat Intelligence newsletter, surveys the state of DeFi security in 2023. He compares the economics of traditional security with blockchain security, where about 300 incidents the previous year accounted for almost four billion dollars stolen. A generic DeFi threat model frames the rest of the talk, ranking the attack vectors seen so far that year across smart contracts, administrator key compromises and users, and then turning to code security and incident response practices.

Speakers

Topics

From DeFi Security Summit 2023, hosted by DeFi Security Summit.

Transcript

foreign welcome to the state of defy security in case we have not met my name is Peter and my full-time job is I'm a blockchain threat researcher at coinbase and I'm also an editor of a Weekly Newsletter called blockchain thread intelligence where every week I look at all the major compromises who gets hacked what is the root cause what is the research latest research that we can learn from the tools that we can make our practices safer so we have a lot to cover today so we have we're going to talk about the economics of traditional security versus blockchain security we have the threat model exercise that we're going to go through and we will talk through code

security as well as the incident response practices that we currently use in the industry okay let's let's first talk about the economics of traditional security versus D5 security why is it that the Bad actors are so interested in our field that more and more of them are coming to attack us well if you look at the traditional security and what are the bad guys are really trying to do is for the most part they're trying to steal data they're stealing data so there were about thousand incidents last year and the most they could steal was around 400 like half a billion dollars with about two million dollars per incidence that they could profit and the reason like those profits are really coming from ransomware attacks because when you steal all those emails and Social Security you still have to monetize them

you have to go on secondary markets and try to sell it that is not the case with the blockchain security where we have about 300 incidents last year but almost four billion dollars of actual assets were stolen so that's six times as much profitability for attackers relative to traditional security fields so that means nation states uh Financial actors they understand this mathematics and they understand that if they want to make profit cryptocurrency ecosystem is the way to go that is why more and more of them are targeting us um raise of hand so many of you are doing threat model exercises when you're building a protocol or evaluating protocol there are a few few hands all

of you should be doing this like you should really before you build a protocol you should create this diagram and I'll show you what it is in a second thinking about like all the different ways that someone can Target you so do a very basic exercise like what a generic D5 threat model looks like and then we'll see how the bad guys actually exploiting it so we have to start with users so basically you and I we're interacting with protocols for the most part we are talking to dapps so these are traditional web 2 applications so your thread model there is we're dealing with web 2 infrastructure with routing protocols which are attacked Every Which Way and then we have wallet software once again we've been we have Atomic wallet 100 million stolen so you have to think about those threads as well and

then we have of course the underlying blockchain technology and the focus of the stock will be on Smart contracts that are running on top of blockchains and administrators that are managing them so here's how attackers are actually targeting this so the last so so far this year so this is up to this week the majority of compromises involved smart contracts so we have 400 million dollars that were stolen in the smart contracts space and then another 140 million based on just administrative issues so basically someone's stealing private keys what we are seeing though and unfortunately we don't have time to talk about our older issues on the user side so we have 100 million dollars stolen from users and this is all involving like crazy drainer attacks and phishing

and transaction zero transfer issues and the wallet software leaking your demonic phrases so for some reason this is becoming more and more of an issue we can't really dive into this for now but uh this is becoming a concern but let's talk more about the right side of this threat model so the way you should think about security is prevention so code security is prevention followed by detection and then when all else fails responding to it so we'll start with preventing things let's look at the code security so this I would take a picture of this this is a list of attack vectors that I've observed so far this year prioritized by risk so these are the methods used to break things risk is a function of not only the value that was

stolen but also the chance the likelihood the occurrence of those issues so the concerning part here is that the price Oracle manipulation and reward manipulation consistently stay in the top left corner year after year quarter after quarter we're seeing those are the main ways that attackers compromise us examples of price Oracle manipulation how many of you are familiar with that okay so everyone is on top of it so someone you're relying on a price data if your protocol has that you have to be extremely careful about how you extract that data and see if it's not manipulated reward manipulation is more tricky so think of Euler compromise where someone was able to trick the protocol to give up a larger liquidation

reward than was expected stolen private Keys is more of a process issue so I think developers think a lot about code security they go through multiple Audits and they feel safe at that point but you still have to think about operational security so where do you still store your private keys while large is your multi-sex so we we've just seen from the uh from recent hacks three out of four multi-sig is not sufficient and you know keeping your keys in a metamask on your computer which can be targeted by malware is also not sufficient so you have to think about not only what code you write but how you will manage that code as well other things like insufficient function access control is an embarrassing issue to have in your protocol that means your Auditors or even you did not go through that threat modeling exercise you do not

know how exactly your protocol can be targeted and what exactly needs to be protected so you have to be just really mindful of at least the top five here the place where I really want to see all of these issues going is the bottom right corner where re-entracy attacks are they still happen this is still a concerned issue that should be mindful of but luckily at least so far this year they were I guess total nine issues combined between those two and that's what we want to see versus 40 something in price Oracle it seems like every single week when I observe a hack price Oracle manipulation it's a it's a it's not something we want to be so what is the issue so is are we do we not have enough Auditors our Auditors

not experienced to find those issues there are quite a few companies out there if we talked about a year ago there were maybe a dozen folks out there that you know you cannot book an appointment with them they were booked a year ahead now it feels like they're more and more entities which are coming online they make their services available and then even more available as single Auditors who are performing those Services as well we have plenty of bug Bounty programs we have competitive Bounty programs like code for arena tool sectora and Foundry it feels like the industry is getting more and more mature trading is interesting because I think this is more of an indicator of what's

what's what is breaking here is that the trading is very much focused on offense so we we got really good at teaching our Auditors how to break things but what about teaching developers on how to write really secure resistant code and I think there are a few exceptions I think if you looked at Patrick Collins YouTube channel like he's very focused on writing unit tests like how to write defensible code but for the most part we're overly focused on offense so just some takeaways for the uh for code security one I feel that developers are they do not have tools they don't have sufficiently mature secure development

process and tooling available to them we have to provide standards provide guidance on how to build code securely um defensive training is lacking I think if you're if you're thinking of a class and you want to build something let's let's focus Less on Auditors and more on developers so they start building code from this get-go uh operational security let's let's teach our developers on how to be safe how to not use multi-sig which is too small or is stored in securely and at last when we grow the next generation of Auditors that list that I gave you we really should be updating it the list of primary attack vectors let's

let's make sure that they're aware of it let's make sure that they understand what are the ways that protocols get attacked and not just simply run automated tools with that as Eugene mentioned it's not enough just to do safe code audits we also have to think of what what happens when everything goes wrong and that's where incident response process goes so first how many are you familiar with the kill chain concept okay so not as many folks so this is as a as an incident responder the same way that you're building a threat model for what can go wrong with your protocol this is the model that you use to build what attackers can do and what stages to Target your protocol

so this is an example um kill chain for majority of D5 protocols out there the way that it starts it is with the reconnaissance stage so this is usually when attackers deploy test transactions so we see with Nomad compromise they were like messing with live on chain that's rare but it happens public discussion of vulnerability so mango mango markets attacker like he was actively talking about it in one of the Discord chats resource development that's usually when the initial funding of the attack is happening when you may be getting some flash loans just to set up the infrastructure for your attack preparation usually involves helper contracts where they either deploy it they configure them to Target your

protocol and of course the active exploitation stage things don't end there there's also the laundering part that that's what happens after the protocol is attacked the way that this is useful is that if you can disrupt the attacker at any one of those stages you win even if you cannot stop the attacker at the very beginning in the preparation or resource development stages but you catch them in the middle of the exploitation you get at least minimize how much money was stolen from your protocol let's see a sample attack that happened and how it applies to this threat model so Euler attacker there's a lot happening to this and more and more revealed it feels like every week on the reconnaissance stage we don't know what

they did it sounds like they probably set up Foundry and they were doing everything offline so there's no way you can catch them if they were emulating the attack locally on their machines on resource development we saw the funding so as usual it seems from tornado cash full by exploit deployment so that's your preparation stage and then the attack itself the attack itself lasted for what is it 15 minutes and then at last they were starting to swap assets from usdc to other things and the reason the reason why they do that is because assets like usdc and tether they can be frozen so most most attackers they attempt to quickly swap them so they're not frozen on them

stages Euler could have come in and stopped the attack and notice those stages lasted for minutes so you really had to be fast like if you want to learn more about like what to do Post exploitation I invite you to actually look at the talk by my colleague Heidi Wilder tomorrow called Rec build but we will focus on just the beginning stages so let's let's look at the timing here so we we can start with the compromise stage this is when the attack actually occurred detection that's when someone usually someone else notices that there is an attack in progress finally the end of the triage process that's when the uh the protocol usually determines okay this is an incident we need to respond to it and the way that I determine the triage time point is when they usually

publish something so they say okay we have we have an issue okay so on Euler side it took about nine minutes for an external party nine minutes for Peck Shield to put a tweet out there that we have we have a problem and then another two hours for them to respond to say okay we are investigating this this is a concern other protocols like multi-chain took an hour for someone else to find it in another four hours for them to respond Bonk similar seven minutes to hour and a half year notice it's negative 17 minutes someone was actually able to catch that there's a an exploit contract that was deployed before it was used in the attack that's that's where we want

to be but it still took him another hour and a half to respond so the money was lost and the abysmal response by poly Network six hours to detection and then five hours to respond notice in every single one of those cases these are the top five largest hacks so far this year in every single case someone else had to go and knock on their door and say Hey you have an issue not a single point that the protocol itself had sufficient monitoring to say like we have a problem and we're going to respond what is an issue do we not have enough Monitoring Solutions it feels like more and more companies are spinning up out there the issue is that we're dealing with a lot of noise the signal to noise ratio is not good we can go back and find like yes we know there's an exploit and yes our protocol did catch it but

can you tell that to me 17 minutes before the exploit actually happened that's what we need to push for forensics teams are too focused on traditional tracking of assets as opposed to doing the full analysis that were used in traditional security reversing the smart contracts analyzing how the exploit works and then the incident response is once again we're relying on volunteers we have people like Sam basically called in into war rooms who are you going to call to really help you with the protocol I feel like there's a gap there so takeaway here is incident response detection by Twitter is not going to work that's a problem lacking incident response process if you don't know exactly what you're going to do every single minute you're wasting that time and every minute wasted is the time that

you lose Millions we need to move not only because of how quickly those attacks are happening we need to move from detection to automatic intrusion prevention you don't have time to review all those things you need to pull pull the plug early on automatically so at this point you might say I can't trust my smart contracts I can't trust my wallets I can't trust anything definitely not myself not to lose everything let's go back to trading shells and to that I want to tell you don't worry this is the issue here is that we're trying to compress the time that it took decades for traditional security to build up the expertise and tools and we're trying to compress this time in just a few years and it's painful so the what I would suggests is that really rely on the community we have an amazing Community every single one of

you here is amazing at sharing knowledge we have captured the flag competitions where you can learn we have conferences such as the one we have here we did not have conferences for a couple years back there was nothing and of course we have newsletters Shameless plug subscribe to block thread wrecked and others to just keep up on what are the latest events and when it gets hard I just want to make you just remind you why are we doing this why are we doing our jobs why are we waking up every morning we're trying to build trust in the ecosystem and that's a critical step to adoption a critical step to letting all these people to use our protocol safely freely without anyone telling them no you cannot use this so every single one of you in this room has the power to increase trust in the ecosystem and in that affect millions and billions of

lives and with that any questions [Applause] there's been a lot of talk about account abstraction and I'm just curious how heavily does account subtraction feature more specifically in the role of Stone in private Keys is it a continuous discussion it's a side discussion is it something that the security industry is really taking notice of or incorporating I think it's amazing I mean we're we're dealing like if you remember the threat model 200 million dollars lost

can we use this new tech to make things better can we introduce additional checks and balances maybe some kind of recovery mechanisms I think there's an opportunity to to make things safer but it's too early to tell I feel like we're still at the standardization stage and adoption stage we'll see how it plays out I I'm optimistic that it will be useful for many other reasons too uh one more question given that the state of malware has a bunch of techniques for say like self-increa or self-decrypting binaries to avoid AV detection like prevention seems somewhat infeasible until like cryptographic keys or cryptographic information is sent to the

contract so to what extent do you think prevention is actually feasible versus like attackers will just Implement well-known countermeasures to bypass your prevention well it's lucky we're not at that stage yet I feel like we're still the attackers did not it's like a you know the frog and the poison snake analogy where both need to constantly compete and get stronger and stronger it's so easy to exploit the smart contracts right now attackers don't really need to obfuscate their smart contracts just yet please don't listen to this talk they they don't need to evolve just yet we'll get there but for now we can still simulate transactions and we can catch like basic things like oh your your pool just got completely empty or your your your governance somehow is changing so we can we can do

really basic things today that will catch an attack in progress and when we need to evolve we'll evolve but I wouldn't say like okay we have to just give up I guess once once they evolve we'll need to do that as well but at least we need to catch the bare minimum today which we don't maybe your last question okay cool I think um so it's time for the break