Securing a Cross-Chain Bridge

DeFi Security Summit 2022 · 27 Aug 2022 · 19:05

Chris Whinfrey, co-founder of Hop Protocol and a former auditor, explains why bridges keep getting hacked, citing nearly two billion dollars stolen across 13 incidents in two years. He lays out the main risks, from smart contract bugs and compromised keys to malicious RPC endpoints and short challenge windows, and argues for avoiding trusted third parties and using a 24-hour window. He describes Hop's hub-and-spoke design that settles through Ethereum so one failing chain cannot drain liquidity providers elsewhere, and stresses fast incident response using Nomad and Poly Network as cases.

Speakers

Topics

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

Transcript

so firstly we have Chris from Hop protocol he'll be talking about how to actually secure a bridge and how protocol touch board is luckily one of the uh bridges that are still going fine so what left and really love to hear how he actually manages that thank you so I'll get right into it we have a lot to cover today I'm going to be moving really fast through everything so um sorry if it's going a little too fast but really quickly my name is Chris Winfrey um I was an auditor from 2018 to 2020 our whole team was we got to work with some cool projects like the opens up on framework auger DUI DX trust token and Central end and I've also done some some

white hat stuff so I've reported vulnerabilities to exchanges and D5 protocols um with millions of dollars at risk I've gotten uh critical bounties from binance and Stargate Finance helped her cover some of the funds from the recent Nomad hack and then I'm also one of the founders at uh hop protocol I think we have a a nice trustless and and secure bridge design so I want to tell you uh kind of more about how we think about security and why I think trustless bridges are not just better because they're trustless but they're also way way way more secure so I hope by the end of this talk I've convinced you that's true and so why are we here today talking about bridges um nearly two billion

dollars has been stolen from Bridges so far over the past two years um across uh 13 separate incidences and so it's you know we hear a lot of big numbers in D5 it's hard to imagine just how much money that is so this is what a billion dollars looks like it's 10 full pallets this is hundred dollar bills stacked about yay high and that's just one billion dollars so imagine 20 pallets that's two billion dollars that's been that's what's been taken uh from Bridges so far and this is a chart by Chain analysis it shows that uh Bridge hacks are making up a larger and larger percentage of uh D5 hacks and this is a pretty alarming Trend but Bridges keep getting hacked

this keeps happening so we're going to look at why Bridges keep getting hacked and what you can do to analyze Bridges and prevent these types of attacks so really quick why are bridges getting hacked the technology is still new we're interacting with a lot of new chains we're interacting with scaling Solutions and then the bridge technology itself is new teams are trying out uh different things and so naturally things are going to break as as experimentation happens Bridge the attack surface area for bridge is very very large so there's a lot of different attacks that we'll get into and then Bridges secure a lot of money you need a lot of capital to be able to move money from one chain to the next and so naturally bridges are a big

honey pot a big Target for hackers and so these uh this first item is going to kind of solve for itself as time goes on we're going to get more and more secure the technology is going to get more proven we're going to figure out what design patterns are secure but these second two are just going to get worse and worse so the the surface area is going to grow as Bridges support more and more chains and we're going to need more and more money to facilitate cross chain functionality as ethereum's Layer Two grows as uh kind of the multi-chain ecosystem grows so these are probably just going to get worse but Bridges aren't going anywhere so we need to build secure Bridges and think about how we can scale bridges in a way that doesn't ever increase the security risk of their participants

and so a little background we're going to be talking about Native Bridges and general Bridges so native bridges are things like polygons Bridge like the roll-up Bridges you could think of Wormhole as a native bridge for Solana where it's bridging some assets from a base layer to another chain and then users of a native Bridge have a risk exposure to that bridge not only when they're Crossing it but anytime they're holding those wrapped assets and then General bridges are more like liquidity layers and so the user is just going from one chain to the next and they're only exposed to the bridge risk while they're Crossing it but the LPS of these bridges are exposed to constant risk and so an example of a general bridge is hot

and like the native bridges are for example roll-up Bridges so we're going to be talking about Bridge risk framework attack surface area threat mitigation and threat response so when you're thinking about your risk framework you first think about who your participants are so we have our our Bridge users uh we have a passive liquidity provider so these are people providing money uh so that the bridging can do um its functionality and then there's the message relayer so the message relayer might be a fully collateralized message relay like cop sponders uh where they're taking on all of the risk and and facilitating this cross-chain message or it might be a trusted party like a multi-sig where they're actually

pushing the the bridge risk and this this cross-chain messaging risk over to the LPS and so then you want to think about uh what types of risks do each type of participant face what uh trust assumptions are introduced and then how can we minimize these trust assumptions and risks to maximize our security so what are the risks that Bridges face uh there's a lot of risks so unfortunately most uh Bridge hacks have been because of smart contract vulnerabilities this is no different than any other smart contract system on ethereum these you know if you follow your best practices get your Audits and and Bug bounties these are going to be as preventable as any other system in uh you know across defy

and then the the number one vulnerability against bridges in terms of dollars loss is compromise keys so this is where you have a trusted Bridge um and they lose their keys to some hackers you know possibly a state level actor such as uh North Korea's uh Lazarus group and this has resulted in over a billion dollars uh being lost uh to hacks and then you want to be thinking about reorgs when you're securing a bridge uh you know you have a message that's initiated on the source chain and then you're completing it at the destination you need to make sure that your Source chain has reached finality so for ethereum and other uh you know proof of work or proof of stake chains this is pretty standardized but things like Roll-Ups it's a little trickier so on a

roll-up uh you your user is making a transaction submitted to the sequencer the sequencer is putting that on a layer one block and so that block is the one you're actually waiting for finality for before you can kind of complete that message at the destination knowing that it's not going to be reversed um on the source chain uh and then your advice here has done some great research on uh you know another type of kind of reorg with rollups and and this is when um a malicious fraud proof can be inserted and and uh it allows an attacker to actually roll back the roll up even if the L1 block has reached finality uh but there would have to be some serious vulnerability in the roll-up so I'll let you talked about that a bit later

malicious RPC endpoints or node vulnerabilities so if you are a bridge your your RPC source is just as much of a custodian of the funds as the actual private keys so if you're not um you know whatever your message relay isn't running their own nodes and they're using a RPC provider that RPC provider gets hacked they can launch false events and cause your bridge to get drained so in a trustless system where your bonders are are kind of facilitating the cross chain messaging they're fully collateralizing everything they're taking on uh risk just for themselves so if they want to Outsource their RPC source to some third party then they're only risking their own funds but if you're using a trusted

Bridge like a multi-sig bridge then and they Outsource their RPC provider you're not only trusting that this multi-sig bridge you know one they're going to be good people that's a pretty reasonable assumption two that they have world-class security that's going to stand up to state level actors and three if they Outsource anything like RPC providers or any other node infrastructure that those entities also have world-class security that's going to stand up to state level actors and then challenge windows are something we see a lot in the bridge space you know some bridges will call them optimistic I don't think everything with the challenge window is necessarily optimistic but the length of your challenge window is very very important so optimistic rollups use a full seven day challenge window they need a very

high level of security and capital efficiency isn't super important for their exits at Hop we use a 24-hour challenge window and then you know we often see competitors we'll use you know half an hour challenge window to to a few hour challenge window which we think is very dangerous and so you want to use a sufficiently large challenge window so that you can have a human level response if something were to go down because we see infrastructure break all the time for example maker Dow had black Thursday their kind of assumptions from the automated systems were broken when gas prices went really high and then we saw a bunch of liquidations happen at a loss to the protocol same thing can happen with any bridge where where there's a challenge window if infrastructure goes

down and attacker is able to take advantage of a chaotic situation within a 30 minute time window that's you know that time window is not really going to be helpful because you're going to need people to actually respond to it and then lastly chain malfunctions or an exploit of the Native token or message Bridge so this is kind of like what happens if there's a catastrophic situation on one of the chains the bridge supports is that going to completely drain the entire Bridge or are you able to kind of isolate this risk to just the participants on that chain and I think that's very very important to Bridges to be able to kind of scale horizontally from a security perspective without ever increasing the amount of risk they're subjecting uh their participants to

so now we'll talk about threat mitigation so how do we prevent some of these risks so first of all just follow all the best practices and and try to prevent uh smart contract bugs so keep it simple get audits use bug bounties uh we won't spend too much time here avoid trusted third parties like I said if you're you know if you're using a multi-sig page or a trusted Bridge you're not just trusting that these are good people you're trusting that they have world-class security that's and this is not just like a standard multi-sig Bridge or a multi-sig that you see in D5 where where a group of people are holding ledgers these are hot keys that are running on servers that are both receiving information sending information uh they're you know upgrading things so any kind of like

supply chain attack or or anything like that could could compromise the bridge and you know that's that all that risk is pushed on to you as an LP in this bridge and then lastly we want to prevent contamination so that our Bridge can scale horizontally uh without kind of ever increasing the risk that we subject users to because that's inevitably going to fail as you support more and more networks that have a lesser and lesser security model so to kind of illustrate how we handle that at Hop um so first here's kind of like your standard multi-sig Bridge we you can see we have four networks here that are connected they're all connected directly to each other and then say we add a new network dose chain and then

unfortunately does chain gets hacked it blows up the attacker controls infinite funds on Doge chain and then they empty them through the bridges as an exit path and now the entire bridge is blown up all the LPS on all these other chains where they thought they were secure they were actually subjected to this this lesser security model and and have lost all their funds and so with hop we have kind of pioneered this Hub and spoke model where everything that settles through ethereum and so uh bonders can choose any given networks that they want to bridge between and they're only subjected to risk for um kind of those networks that they're on and then the settlement process prevents uh a kind of a catastrophic situation on one chain from affecting

the LPS on other chains so you can see here uh we add Doge chain in a similar situation here are kind of the stop gaps on the layer one ethereum contract to prevent the settlement from blowing up the rest of the participants on the other chains you can see our Doge chain blows up all the users on those chain lose their funds but the rest of the participants are still able to keep bridging keep providing liquidity and they haven't lost their funds so we think of this kind of like a ship so if you have kind of like just a regular ship and you get hit by a torpedo or you you know hit an iceberg or something then your whole ship sinks but modern ships have something called a bulkhead door so it looks kind of like this if you're familiar and the bulkhead

door compartmentalizes different pieces of the bridge so say you get hit by a torpedo and uh you know part of your ship gets filled with water the rest of your ship is safe and you can kind of keep going and and uh you know some of your Sailors will live and so uh lastly we'll talk about uh threat response and so the number one thing you can do is is have a fast response time that's going to make the biggest difference uh in terms of recovering users funds and I'll give a few examples as well as uh first-hand experiences here um so chain swap was one of the first Bridge hacks back in 2021 uh users reported losing uh some funds and the

team was able to shut down all the nodes and limit losses to 800k so they responded within 30 minutes um unfortunately later that week another vulnerability was discovered uh 4.4 million was lost but it goes to show that there was a lot more to lose had they not responded that fast and then on the other hand uh not all teams will respond fast or have the proper monitoring systems in place so for example Ronin Bridge the biggest defy hack ever lost 650 million dollars uh it wasn't even discovered for six days that the money was gone and then most recently uh Nomad this hack lasted for um you know for a few hours and and so lots of people were able to kind of come

in there and help out so white hats were able to scare 32.6 million dollars I was lucky uh to be one of the people that kind of saw this thing happen uh in one of the ethereum security groups um and so I started to investigate I took a call that was you know about 30 minutes after the call I simulated the transaction and saw that I could replace the address and and with my own address and and take the funds so I started firing off as many as I could and by that time I was getting chunks of say uh thirteen thousand or ten thousand dollars for each transaction that I fired off 15 minutes before that those chunks were two hundred thousand dollars so if if I had been 15 minutes faster I think I would have been able to rescue maybe a

million dollars and 15 minutes before that or or uh 25 minutes before that it would have been multiple millions of dollars so it goes to show that even like a half hour or 15 minute window in your in your response time can make a huge difference uh for funds recovered and so uh speak from synthetics has a great monitoring system for uh looking for kind of suspicious behavior and so he's reported suspicious Behavior to us at hot before and this is another example I have like how a fast response time could potentially save uh users a ton of money and so uh he reported the the uh issue we uh were luckily running the bonder ourselves at this time and so

by the between when the attacker initiated the transaction and the source chain reaching finality when the bonder would have completed it we shut the binder off we simulated the transaction to see if this would be a successful attack it was obviously uh being foreign maliciously uh but but hop worked as expected our protections worked as expected we turned the bonder back on and everything continued with very little Interruption had this been a successful attack and there was a vulnerability in the smart contracts the response time would have saved users you know potentially over 100 million dollars and so not everyone uh you know has this this same mentality and so I think it's really important to you know take the

mentality that that you will be hacked and that this can happen at any time and be thinking about how it's going to happen and how you're going to prevent it because a lot of people will gain too much confidence uh you know become a little bit arrogant and assume that you know because they haven't been hacked they won't be hacked and this is often when uh really bad things happen and then also you might Overlook an issue that that's reported uh directly to you so please don't be uh like some of these people if if someone comes to you and reports an issue um so you also want to have a good monitoring system so we have um so we have what we call our health Checker and that allows us to check any

of our security and variants and alert us in slack the second any of those are broken um so that really improves our response time and like I mentioned spreak also runs uh this this great um you know monitoring system that looks for any kind of suspicious activity and we'll let the team know um if he does see something uh you want to have clear reporting guidelines so if someone does have something to report or they lost funds uh it can get escalated to the team as fast as possible so it's really important that if a user does find something they can look at your site or your docs and see how they can report a security uh issue and then that's going to get escalated so that you know you know even 15 minutes faster you can respond

and then lastly let's say you you know you did your best you you tried not to write bugs you got your audits you got your bug bounties um you know you did everything you possibly could to to secure your Bridge you still got hacked you have eyes on attacker controlled funds it's still not over I you should reach out to every exchange that you can especially the big ones reach out to the stable coins get the address labeled on etherscan and attackers are often not perfect at laundering money they they don't uh they'll make mistakes um you know like we saw in the Nomad hack some of them you know aren't perfectly sophisticated and so for example in the poly Network hack 610 million was hacked the attacker swapped

some of that into tether and the tether team was able to freeze 33 million dollars and return that uh to the team and so we've also seen a lot of instances of exchange is also freezing funds and returning them to the team so make sure that that you know you're not throwing in the towel just because you've lost your funds thank you [Applause]