Web3 Security: On the Front Lines of Protecting Digital Assets
Crypto Valley Conference 2022 · June 2022 · 41:21
Salick Cogan of Fireblocks gives a masterclass at Crypto Valley Conference 2022 on web3 security and the work of protecting digital assets. The session runs about forty minutes and is listed under security and key management.
Speakers
Topics
From Crypto Valley Conference 2022, hosted by Crypto Valley Association.
Transcript
um now we move on to web3 security uh with fire blocks uh sake uh would you like to join us um yes welcome into the stage thank you all for being here thanks mike hey everyone thank you uh my name is sally kogan i'm the head of the web 3 group in fireblocks to those who of you are not familiar with thank you with fireblocks firebox is a custody technology provider for businesses and institutions it basically lets businesses operate their entire digital asset operations management custody treasury compliance aml
and other areas in a very secure way we utilize mpc encryption and on top of this platform we are building a lot of different groups that are tackling different areas in the space one of the spaces and this is the group that i come from is the web 3 group and obviously web group web 3 has a very very strong footing today in d5 but on not only d5 we've heard about the nft that you just got and game 5 for new games that are being built on blockchain and other interesting areas so
what i want to do today is put ourselves in the shoes of actually the hackers the attackers the malicious and bad actors in this interesting world and try to see how they are looking at this space from their point of view what they are seeing what weaknesses are they looking for and also what are they actually doing with these conclusions so if we look at the amount of value stolen and we have the data until the end of this queue
we can see that we're at record pace right we got almost 1.3 billion dollars stolen in the first queue of 2022. we had a bit over 3 billion in last year and so i think we're gonna pass it yeah this year and if we look at the um the structure of the the funds that are being taken we can see that difa is starting to take a really big part of this of these funds so in 2020 most of the funds were stolen from
centralized exchanges and private wallets it obviously increased in 2021 and today we're almost 100 percent funds stolen in defy and there are two main reasons for this one is that the money is going into defy right this space is uh is exploding and tons of new funds are going there and the other reason is hackers are going after the money but they're also going after where it's a bit weaker sometimes and because this is a new emerging space there is still a lot to learn
so i want to start by trying to describe the ecosystem and looking at it from the point of view of the attackers so if we take the the web app flow which is the traditional web application flow which we now call web2 this is a very high level view of this you have a browser or a mobile device or even a developer calling some kind of api this browser issues some requests that reaches then the backend servers of some service usually it will be a
company service it will be a private server with which no one should have any access to this back-end receive the trend the request it does something it does some business logic maybe writes data to a database and returns the response to the client and if we think about it from attacking point of view we have two main vectors of attack here right so we have the left side which is before the request reaches the company server and we have the company servers themselves but we know that the web servers are
private now if we look at the web3 app flow in this new ecosystem it's a bit different right so first you have the web application that sends a transaction to to the blockchain to for example smart contract but as you probably know if you ever used a wallet of some kind whether it's metamask or world connect or any other wallet you know that you have to sign the transaction right so something pops up in your software you you approve it it basically gets cryptographically signed and then this transaction is
being sent to the blockchain where it's been processed now the difference here is as we all know blockchains are public right everyone can access it everyone can see what is being done there and the smart contracts that are running on the blockchains are also public for most of them you can even see the the actual source code that they are built upon you can see what they are doing and this makes from the perspective of the malicious actor makes our life in a way easier right
because i don't have to uh find my way into a private server i i just have all the information there and i just need to file it find a way in so there are two other interesting aspects in the blockchain world in this ecosystem that we need to understand in order to get the full point of view one is bridges does anybody know what the bridge is okay so today we have a lot of different blockchains right we have the bitcoin ethereum we have solana near and a lot of others and most of them are not connected by
design right and usually if you want to transfer funds from one blockchain to another you need somebody to bridge that gap hence the word bridges and there are basically two types of bridges one is the what we call a trusted bridge or a centralized one so this could be an exchange right you trust the third party that if you'll give him your i don't know bitcoin he will give you he will issue you the ethereum tokens on the ethereum blockchain and that requires some level of trust in the world of decentralization we also
have what we call trusted bridges and these bridges are basically built uh on smart contracts so the setup is that you have the very basic setup is that you have one smart contract in blockchain a you have another smart contract in blockchain b you send money to the smart contract in blockchain a something magical happens and the smart contract in blockchain b receives this information and gives you tokens on that blockchain the tokens that you transferred to the smart contract on blockchain a
are locked okay and so you basically now have assets on blockchain b which are collateralized by the assets that are locked by the smart contract on blockchain a and why am i telling you all of this because bridges hold a lot of money and since they owed a lot of money they are prone to a tax because if i can attack them i might be able to steal a lot of money and we'll see a few examples later another very important aspect in the ecosystem it's called oracles anybody know what an oracle is
yeah you all know everything so we have a problem with the blockchain the problem is that sometimes we need to access data that is not available in the blockchain right for example i need to know the price of the the fee the swap fee between bitcoin and ethereum or i don't know i need to know what's the weather right now anyway this data is not finite it's only true to the moment that i'm asking for it and because blockchains are supposed to be fully deterministic meaning that if i run all the transactions in the ledger i will
get to the same state every single time i'm unable to rely on external data sources that might change so what oracles do they basically solve this problem they bridge the gap between the blockchain and the outside world so they provide information as a data source to the smart contracts that are running on the blockchain and why is this a problem because maybe if i'm able to hack into the oracle or if i'm able to fool the oracle about the information he's looking at i might be able to control what is actually happening on the blockchain so this is another
interesting attack vectors so let's think about what type of type of attacks we have today so the first and foremost and the most common one that we have in the world today regardless of blockchain is fishing fishing is uh when basically somebody is masquerading to be someone else and is doing something that will cause you to give him your credential right so if i'm i can send an email masquerading as on facebook i can tell you that you need to do something you go you click the button a
site that looks very familiar to facebook shows up but the url maybe has 2-0 instead of two o's but you don't notice it you log in and boom as a hacker i now have your credentials to facebook and i can do whatever i want with it so in in the blockchain world this is done in a a bit different manner the attacker will want to fool you into signing and transaction that is not doing what you think is about to do right we saw it in earlier every transaction needs to be signed the other type of attack is what we call governance attack i'm sure you've all heard about dao's
decentralized autonomous organization basically for most protocols today there is some kind of governance that uh determines how the protocol will evolve so you can make an offer a suggestion a proposal and if you get a majority that was defined according to the governance rules it will pass okay so i can determine if i want a 51 majority or 70 majority it doesn't really matter i can uh add any other condition but basically it's a framework from which we can vote
on something and it will be accepted if it all the prerequisites are being met so think about that if i manage to get the majority i need to pass a proposal maybe i can pass a malicious proposal in the protocol and basically nothing can stop me from doing bad things another type of attack which is uh very coupled to the oracle entity that we talked about is price manipulation right we know it from the stock market it's not something new but if i can manipulate the price maybe i can uh
use this to gain uh a revenue or profit that i couldn't do otherwise so if i can fool an oracle and tell him that the actual swap rate between two tokens is different than what it actually is i can profit from that information the fourth type is what we called smart contract exploitation and if i compare it to the the web 2 world is what we'll call zero days so these are exploits or hacks that are being found uh which have no only the person who found them knows that they exist and he can manipulate
and use them to steal funds these are very sophisticated hacks usually and the fifth one which is the basic problem i think uh that we have that fireblock solves is that your private keys are being compromised right so if i somebody somehow hack into your computer and steal your private key i can do anything i want with this private key now so these are the five main types of attack and what i want to do now is try to go over some of the more interesting hacks that we've seen in the last six months uh we'll go from uh level of
kind of low sophistication to the more sophisticated ones and we'll see also how the amount of funds that are being stolen gets uh increasingly higher so the first hack i want to tell you about was happened actually three weeks ago i think it's we call it the go daddy attack i i i think most of you know what godaddy is but basically it's a hosting service it provides dns management services and what happened there is that there are two decentralized exchanges one called quick swap and the other called sweep spirit swap and they are
hosting their servers on godaddy so what the attacker did is they called godaddy and they human social engineer them to uh think that they are the people who own those companies and those servers and they got the credentials to the dns management system so what the attackers did right after is they went to this management system and they said okay if anybody goes to these domains he will be directed to my servers and these servers presented the same exact site like in the facebook phishing example i talked to you about
they showed the same exact site only there was a really small uh difference whenever somebody went and swapped to two tokens the call to the smart contract that was in charge of doing the swap uh sent the swap tokens to the attacker's wallet okay so anybody that went and swapped this token they were actually directly sent to the attacker's wallet so it took them by the way it it's the sophistication is low because it's a phishing attack and it's not really uh in itself but it requires some creativity right it's not probably not
easy to fool those go daddy representatives and so after about 18 minutes i read the postmortem by the teams they figured out that something was wrong they didn't really know what it took them another 30 minutes because they were looking at the side and it looks the same right they everything almost the same it took them another 30 minutes to understand that maybe there's a problem with the site and then they tried to reach godaddy they couldn't it took them a few hours to reach them and when they did reach them they weren't able to convince them that they are the actual owners of the site which is a bit ironic and
eventually after a day i think they managed to get their control back not a lot of money was stolen as we'll see in other attacks and they switch from go daddy so they no longer use them the next attack is something that happened on openc to those of you who don't know openc it's basically a marketplace for nfts uh one of the main ones today it runs on the polygon uh chain which is a side chain of ethereum and this was also a phishing attack but it was a bit more uh elaborate so
the way these mark marketplaces work usually is it's a marketplace for nft so you go you auction your nft you say i want to sell it for 100 or ethereum can make sense for some nfts and so you give the permission to the site to the openc contract to sell this for 100 ethereum and then as a buyer comes by and tells openca i'm willing to buy this nft for 100 ethereum they do a match they do the transfer they take the nft out of your account because you gave them access they take the 100 ethereum from the
buyer and they send it to the seller and we have a deal so basically when you go to openc and you auction something you are giving openc the smart quarter contract of openc the permission to take your nfts from your account for such and such tokens and what the the attackers did is they basically sent an email a mess email to a lot of open c users masquerading as openc telling them that they're doing some maintenance and they need to switch now to a different smart contract and so when they click the button the wallet show them a transaction they need to
sign and what this transaction said is basically hey i'm selling my nfts for zero okay and i'm selling it to this attacker to this specific address and then what the attacker did they went to openc and said hey i want to buy this nft for xero and they just sweep all of those nfts from the people that unfortunately approved its transaction they stole about 1 million 0.7 worth of nfts and this would have could have been easily mitigated if the they knew what they were signing and one
of the problems today that we have is the wallets most of you use that everyone use are not able to contextualize properly what is being done they in the most part you will see like a very long string of hex numbers extra decimal numbers most of us don't know what it do what it means and they just approve it and that's it the third one is also an interesting one it's a governance attack we talked about governance uh anyone familiar with the bin stock farms yay
so that was actually a stable coin basically an algorithmic uh packed stable coin which is a swear word now after terra i think it collateralize itself with credits and not with actual tokens doesn't really matter what happened there is that it's a protocol it has its governance methods and you can insert a proposal to the community and if you get a majority of 67 your proposal is approved and is applied to the protocol so what our attacker did is basically
he proposed two proposal one was the legit one it said hey let's donate this amount of money to uh ukraine to help with the war uh to help the people and the other one was the malicious one it said hey let's take this money and transfer it to me and nobody really noticed and what the attacker did next is he went and do you know what the flesh loan is so a flashlight flash loan is something really crazy and ingenious and it's only uh only able to happen on in the blockchain world basically you can take a loan
which is not collateralized i can take a one billion dollar loan which is what the attacker did without giving any funds as a collateral the only condition is that in in the same transaction i need to give back the loan with some uh fee so if i'm not able to uh give the fee and the loan back in the same transaction the loan is basically cancelled so it did it never really happened so what the attacker did is he went to i think ave he took a flash loan of one billion dollars he then did a transaction that took this one billion dollars and bought the coin that is used to govern this protocol and
then he approved this two proposals and then he just sent some money to ukraine and then took the rest to him and all of the money in the protocol basically got lost so i think he needed 67 majority he got like 80 majority well over what he needed um and this actually could have been mitigated first of all of course you can raise the bar of the majority but you can also put a time lock so you can say okay a proposal is approved but it will take a week until it is executed and maybe there's a way to review and approve proposals so you can undo it
there's all different kinds of mechanisms that i'm sure that after this attack will come into reality so we're getting higher with the with the amount of funds being stolen oh that's a nice anecdote if you go to the discord of this project like two months ago somebody has them the protocol developers hey isn't this susceptible to a flesh loan attack and they said no we we're not worried about it luckily we have this documentation okay
going bigger wormhole i made the news quite an attack wormhole is a bridge that connects ethereum blockchain and the solana blockchain you send ethereum it's you send it to the to the smart contract in ethereum it's locked you get uh wrapped ethereum on the solana blockchain vice versa what happened here is that there was a basically a bug in the smart contract and because the smart contract is public the attackers managed to find it and i won't go into the technical details but they were able to store to
steal quite a lot of money and there's two interesting things in this story so first of all right after the attack happened i think uh jump i forgot the name of the company that backs this uh initiative they immediately uh send the stolen funds back to the to the bridge so the the community doesn't leave the bridge so that was a a nice form of action and the second thing which is very interesting when the when the attack happened if you go to the github of the github is like where developers manage their code
and basically the fix to this problem was published to the code repository of this bridge but it was not released yet so there is uh there is a theory that maybe the attacker was scanning the commits the the changes in the code he saw that they fixed this vulnerability but it wasn't yet released so we went and basically used this vulnerability because it got he find out about it from the protocol itself very unfortunate as well the next one is also a huge a huge hack
it's happened in the poly network polynetwork is basically i would call it a meta blockchain it rules a few blockchain underneath and you can basically use the poly network to pass funds between different blockchains so this this protocol basically has a lot of different wallets in a lot of different blockchains with a lot of money in them and what the attackers did we don't know if it's a group or an individual he managed to find a bug that made him an owner of the one of the smart contracts in this
protocol and by making himself owner he managed to basically just transfer money out of the smart contract into his account and the there was obviously a big fuss about this hack and there's something really funny that is happening because you know in in your regular heist movie a robber usually takes the money and runs and now here we we can message with the attacker on the blockchain because it's anonymous so the attacker published this message as a transaction on ethereum saying that the team offered them a bounty to get the funds back but he
never actually never took the bounty but he did return all the money back i don't know what was his motive but he had 600 millions and he just sent them back and didn't take anything for it that's the only thing i think that that i know that some things like this happen so moving on to the latest or not latest but the biggest this is now being called the biggest defy hack of all times until we get the next one and running bridge is basically you know a axe infinity game it's a it's
a very popular game on top of blockchain they have their own network again a bridge the attackers manage to get a majority of validators in the blockchain that decide how the blockchain acts so they actually hacked into sky mevis which is the company that is building their game and they stole the private keys so they had access to the private keys and because there was another validator in the blockchain that from a misconfiguration had given his permission to the same
validators that were hacked they managed to get another private key so now they have they had five private keys and that's the majority you needed out of the nine total validators in the network and then the attackers could easily just drain all the money from the bridge they stole a lot of money this attack is attributed to the lazarus group which is a north korean hacking group apt you probably have heard about it and they didn't leave a message or give back the money unfortunately so i hope that my
from from one side that i won't have to add more slides but i kind of want to so to see if it can get bigger and there were plenty of other attacks i just chose a few there are tons of money we saw 1.3 billions only in the last three months and another interesting question is if you're in a heist movie right you get you see the plan you see how they recruit the people you see how they do the actual uh robbery and then they need to get away with the money but there's a problem here because although blockchain is anonymous right
if if i get the wallet address i don't really know who stands behind it i can still follow the tracks of this wallet right this wallet sends to this wallet and doesn't matter how uh how far or how um how deep these transfers go i can track them easily this is like a key property of the the blockchain so how do hackers steal the actual money and there are a few methods one of the main ones is called mixers so think about a mixer is like a washing machine
or a black box me and you we all go and we put in this box a one dollar bill right and then other people come and take one other one dollar bill from this box and if anybody is looking at the blockchain from a transaction level it can't really say that i who put the one dollar bill is this person who took the one dollar bill it's a way to launder basically the money right so there are a few uh solutions for mixers today tornado cash blender and so on you are the other methods of basically they are called private tokens
which are basically networks that enable you to obfuscate the the addresses of the participants inside the network so it it's based usually on zika roll-ups on zero knowledge proofs but basically what it lets you do is take the money send it to a wallet nobody knows what is this wallet and then you can take this money and convert it to something else and cash it to fiat if you want and so on some of the central exchanges today what they do is they start to block accounts that they see coming out of mixers so it's a way to prevent some of
this money laundering but it's they won't be able to they'll find other methods so i'll end with this which is more of a philosophical thought or maybe [Music] in a thought experiment so after a lot of these hacks happen especially when you do something like price manipulation there is the claim that i didn't do anything wrong from the perpetuator point of view i i looked at the smart contract there is a set of rules that this smart
contract follows i just managed to gain an advantage on all of you and make a deal right i didn't do anything wrong and we call it like code is law the the code of the smart contract is basically the law so i didn't break anything i just followed the code and i'm a genius so i managed to fool all of you the other obvious reaction to that in the world is code is not law law is the law and you can't manipulate prices you can't do those things actually price manipulation in the in the regulated world is something that is a criminal offence so you can't really do it and this
debate is keeps i mean if you spend time on the forums or on twitter it's a very hot debate not sure where it will end and i think that's it thank you we have we have a few minutes if there are any questions don't be shy yes yeah so the question nobody saw it yeah
yeah so the the comment was about the combat comp and the heck that didn't make it here um i tried to take only like the recent most hacks but that's true there are tons of interesting hacks there yeah looks like you didn't mention the biggest hack in history the 30 billion so the question was about the luna case um i'm gonna say no comment no but basically i think it's debatable today if it was a hack or it if it was a coincidence
or if it was a george soros kind of attack but i'm representing here not myself so maybe i'll stop at that but we can talk about it later yeah so
so the question is to those of you who didn't hear it is if i'm a small company i don't have a lot of resources how can i interact with companies with protocols with smart contracts where i don't have the capability to audit them so i think there are two sides to this question one is first of all as somebody who is issuing transaction take a provider which will secure your private keys that's the most basic approach there are plenty of different solutions for that but when you're interacting with the outside world with other smart contracts i think the best way to do it is go by
first popularity second see usually these protocols they publish it's their interest to publish the audits that other companies which is this is exactly what they do they audit smart contracts um which kind which other companies audited their smart contracts so don't go on someone who didn't make an audit definitely don't go with someone who didn't did one audit you need to have a few and still it only lowers your risk but it will never be zero by design so can you repeat the question
yeah yeah is so the question is uh is there i'll rephrase it is there an actual problem with solidity and what is the the way and best practices to write smart contracts maybe use open zeppelin so i think the answer to the first
question is um four years ago the we found out about something called the reentry bug to those of you who are developing smart contracts so it was kind of a zero day that from then people are aware by the way it still happens but most people are aware of it so i don't think it's a problem in solidity as in the programming but more of a design pattern that you need to be sure that you follow best practices and i think what you're saying about open zeppelin and definitely try to see what other people implemented use forks unislope has today 250 forks it's probably very secure if you're going to build
a swap dap so yeah definitely use something that is been has a track record and good community around it okay thank you very much [Applause]