New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Quantstamp 🛠️ Web3 Security: The Epic Battle Against Evil - Richard Ma

ETHGlobalMon, Oct 9, 2023, 12:00 AM

Join Richard Ma from Quantstamp for a workshop titled "Web3 Security: The Epic Battle Against Evil". Thank you to everyone who joined our first in-person appearance in 2023! We are incredibly grateful for the support and contributions of all the hackers, tech mentors, judges, partners, and volunteers who made the ETHGlobal Tokyo event such a huge success. Without your dedication and expertise, this event would not have been possible. We would also like to extend a special thank you to the attendees who traveled from over 59 countries to participate in the event. Your presence and involvement made it a truly international weekend, and we are thrilled to have had such a diverse group of participants. With over 1070 hackers it was a pleasure walking into Toranomon Hills and seeing such a talented pool of individuals. With over 22 workshops, 9 talks, and over $375,000 USD in prizes we hope you enjoyed the weekend full of hacking, meeting all our incredible partners and learning from enthusiasts of the space. We are proud to have welcomed over 35% of attendees who were new to Web3. We hope this event sparked your interest in the world of blockchain and provided you with valuable insights and knowledge. We cannot express enough gratitude to everyone who contributed to the success of ETHGlobal Tokyo. We are already looking forward to the next event and hope to see you all there! 🎉🚀 ----------------- Follow us: https://twitter.com/ETHGlobal​ Check us out: https://ethglobal.co​m Email us at: hello@ethglobal.com

Transcript

foreign [Music] thanks for coming and it's my artificial and thanks for having me I'm Andy I'm an engineer from constant and at constant we're like the security company so today we'll be talking about like how we at constant helps secure like the past present and future and just share some stories interesting stories we had um from from our experience so who are we um we are security company we try to secure the future of Webster Street and as a security company we are very lucky we can get involved with different kind of clients a lot of them are Pub projects in within this industry and we're also a global team so we work remotely like all of our co-works are from different places around the world I think it's probably the same for a lot of like blockchain companies uh unless we're probably one of the earlier smart contract auditing firms and we're also trying to continuously improving ourselves and that's what we're trying to share today so as always I'm said the best defense is a good offense uh as a as a product developer or as a product or as a protocol company like you want to the way you want to get your user is you must make sure your user can trust your product or your protocols so you need to make sure your security is of the highest gender so like user will be able to you know if comfortable interacting with your protocol or your product and to do that that's what we're trying to serve we provide audit Services that's our core service so we usually do audit for smart contracts um it includes like for instance like nft d5s and the loud scenes and today's ethereum conference so a lot of them will be in solidity uh aside for a cyber smart contract we also help um like other things since like um like the layer one blockchain itself for instance these are some of the audio we did for the East Point Zero clients and also we also have like wallets or like Key Management things as well aside from that we not only do audit for like serving we also help like Solana like we did like the their system contract audit and also a lot of their one alert tools like we also help mobile to do their optimistic Rob um audit as well and we also usually treat our client as a friend as a friend we help so we try to increase our impact not just from auditing there are times like client would come to us that they are not sure what's the best way to implement scenes and that's how we come to help us we we're able to look at other protocols or how other people do so we can for instance help them figure out like what's the best algorithm to do so there's a there's a my personal experience although one day we have a client the controls they're trying to write a staking smart contract so as people probably know what's taking usually is like you will put you provide your liquidity and then whenever there's a reward like you get further reward and on your portions of liquidity and at that time the client when the call come to us we're immediately like oh this looks a bit weird because the way they're sharing the reward was like they run a for Loop they just run through all the stakers that's registered and they give them the reward so it's a it's like immediately we're like oh this would have some gas issue and that's the time we're helping them we're trying to help them like oh so we see a lot of other defies how they use this like if people was developing D5 they know it's usually they're using like reward pressure algorithm and that's why we share with them we tell them like hey actually there's a vlog selling how you do this algorithm and there's even sample codes um and if the client eventually update their algorithm and then we were able to finish our audit another interesting story is from like we have a Optimist world of clients so not sure if you're familiar with layer 2 or not but whenever you're bridging things from there I want to learn to alert to the layer one um you have like different kind of messages that have to be relayed from either from their one to their tool or vice versa however usually the protocol team would help to do that but it is super expensive as you can imagine like all the transactions I mean they're there too but sometimes if they want to bridge things back to layer one those messages or those transactions they're they're helping you to relate back to layer one and that's the how to panic SV for that so we are discussing like how we can solve this and we also try to provide some solution potential Solutions because I think currently there is no perfect answer for this yet uh yeah so that's another interesting stories we had from we are helping out or like friends and clients so as a security firm we're very lucky we have able to like look at so many different kinds of things and we're able to you know get enough and also we have to keep our sort of alerted with different kind of um hack or exploit During the period and so we are able to learn a lot of things from the past so one of the one of the really like epic things we had we participated before was the makerdale black Thursday not sure if anyone here was was in that was still in this industry in that time it was a few years ago it was like I think three years ago 2020 March um so what happened at that day was like there was there was a time like is there I think it was a bear Market but it started to get up and then all of a sudden it started in the day like dropped around like 40 percent in the price and that itself it doesn't break things yet but then the problem was like I think nowadays all the guys are super super expensive if you are interacting with like ethereum right now but during that past years the Gatsby was actually pretty cheap like 5gway was like the no more and 10 UA is already like oh that's expensive I think nowadays if you're interacting it's like oh 10 that's freaking this freaking cheap um so it was the opposite situation compared to now so what happened that there was the price drop so fast on the market so everybody is trying to either like run away from exchange or they're trying to do whatever things they think it's better for them to hatch the risk so there's a lot of transactions happening on the ethereum at that single day so what happens like the gas price suddenly goes up from a very low level and then when the price goes up it start to break since that off chain which was like people wasn't imagining so the first thing that started to have an issue was the oracles and Oracle was kind of like the like the backbone or the infrastructure of D5 if people would know so because you need the Oracle to provide the price on chain otherwise the smart contract launching wouldn't know how to get those things so what happened at that time was like the the gas price goes so far the Oracle wasn't able to to send your transactions to the chain to update the price so the price keep saying like the old level and then all of a sudden when the price when the Oracle transactions eventually get in the price drops so fast it started to break all the healthy threshold for the maker dial they give a lot of collaterals and they use collaterals to mend their die and so when when it dropped their healthy stress out those collaterals would be sent into an auction for sale skills like you're lacking money you need you need more money to cover your your die and so that's so that's how it started because Oracle price couldn't get in and then when they got in boom like a lot of things just started break and once those options go into there there's another thing start to break the same way because of the gas price uh so record did provide some software for the users to run and then so they can automatically beat those auctions for to to buy those collaterals or a little liquidated well the problem is like low software also have the gas gas price issue like let's set a let's set a gas limit that's not high enough for them to get through this kind of situations so those bid in transaction wouldn't pass through as well during auctions and until one attacker realized this and so the only thing he did is he just encouraged his his gas price and he do a very like weird fit it's just like his spine is with zero die and it started went through and a few attackers also realized this and then all of them start to attack in this way because all the other people who's using the original McDonald software they just couldn't went through their bit so only low speed there's spying with zero that I went through and all the ethereum from from the McDonald called tart collatorio it's just been kind of stolen but although they're just following the protocol um so that was what happened during the maker down black Thursday and it was around like I think 8 million of last Pro for the protocol itself it wasn't it doesn't look that bad compared to a lot of current hacks but it was a very huge one during that period of time specifically like it was before a device armor or just around the device armor um so to self list uh eventually there's a community group called The die backstop Syndicate they're trying to sort of you know come here and try to resolve this problem um so so they come up with a solution which is they mint more maker tokens look their governance token so they mean their governance token and to do option for their governance token to try to compensate those collaterals however just in case if that doesn't work because they said a very huge limit I think it was like 50k unless you're buying 50k of those tokens then you can't really participate so in case those wouldn't work out for into import like the retail users to participate in this this kind of options there's a group called Syndicate and then it provides a Syndicate contract and so during that time what constant help was like they had this we joined this this group of community people and then they have this contract and we immediately audited it so I think the fact was happening on the 24th if I remember correctly and then this contract was audited just one week in within a week so it was a very fast reaction I mean the things still still happened the hack is still like the loudest loss but I think all the other process especially this is from a community it went through like pretty fast compare yeah so that was the first one well to talk about and the second one one of the another historical event we we used to help was like the the voltage Finance so we didn't really help directly on the Vault head Finance hack um so this hack it was a it was a compound related hack um so I think if you're having you have ever been developing solidity contract you would be know about re-entrancy issues so this is a hack due to re-entrancy but the problem and how they did is like this is a voltage Finance it's a fork of the compound but it was fine in compound because the compound never interact with I would say like weird erc20 tokens because there are some kind of ERC I mean they're not really erc20 they are following ERC probably another protocol but then uh they they have a hook pack functions so whenever they're receiving the tokens or they're sending the tokens so this allows those kind of vocals allows the tokens to be re-entrant during to other protocols but in the in the compound they have a government is processed so they do a due diligence for all the integrated tokens to put on your pools where you know a lot of fork wouldn't do the same they would probably Fork the code and then they just put it and then just start to run it uh so that was the main issue here so this team like they Fork the they forged the compound code but they didn't follow or they might not know like they actually have other security operational process to help me to get some of their risk um so without knowing that they come up with this kind of hack because they allows integration with those kind of more on standard tokens and so in this case what we thought was like we we had a lot of our clients that's working on compound Fork as well so we when we realize this we immediately I think but during that period there are more than this I think there are another few hacks with the same issue so we immediately alerted like the people or the teams where we know they're using the compound Fork as well and we we help like at least two of them to avoid this problem from happening on your protocol although another another probably 13 was fine yeah so that was how we sort of help out on our past clients and how some of the you know paths exploit and we try to learn from them however we're we're living in the prison world and we have to as a security firm we have to continuously improve ourselves to be able to catch up with the newest things and to catch up with like news hackers they always come up with new ways to you know to attack so to do this within our company we're doing a monthly hack hack Roundup so we have Engineers every month we actually will try to try to look at what happened during the past month how many like how many dollars were lost and we try to understand and learn like little things how how those hack happens and how can we prevent it from happening again also one very interesting one that's like DeForest uh it is again re-entrancy attack but this time the little different is a view re-entrancy attack so a typical re-entracy attack you have a state change and before you have you finish in other transactions you go back to the function again that's that's how you start the attraction but in here The View re-entrancy attack you know usually a view function isolated you won't be able to mutate the state so what it does is it's actually calling another function that will change the the view the result of the view function and then when you're integrating with this protocol if you're calling the view function you will have you'll get a wrong value and that's how they attack it and usually it happens for like um for those functions that's providing the price for liquidity poor tokens so for instance if you are integrating with curve and you want to know like how the curve LP tokens price would be you might call their one of their functions to get the price of LP token but these functions could be gained in their re-entrancy way because as you can imagine how you calculate the LP price it will be like you have a pool with two tokens so you'll be like how many tokens of token a is in the pool and how many tokens of token fees in the pool and times their market price divided by the the total balance or total supply of your LP tokens that's how you will calculate like how each LV token would would have its own value or for the price it is a journal reentrancy for instance if you are let's say withdrawing a liquidity then when you're restoring liquidity first you will burn the lp token because you are sending the lp token back to trying to get your original token from the pool so you will burn the lp token this part is probably fine it's probably hard to re-entrance but then whenever they're sending back the the original tokens then this part could potentially trigger the reagency when they send back they can trigger a reentrancy then in this part you have three variables one is like the token a token B and an LP token token B is still not changed yet so you will have a wrong formula in here if it's re-entraced and you can re-entrance the integrated protocol where it would get the Run value so you will be calculating the round value of your LP token then then everything could be wrong depending on how you integrated with it um so that's one very interesting attack that we've seen although like this this specific vulnerability has probably been announced like an Iranian year on other on curve and but depending on the protocol they might not be aware of it uh another very interesting takeaway we get from this kind of monthly hack run up is uh we realize sometimes the hacker or the detector might not have an exit plane so they are very smart they come up with a plan to attack you but they didn't come up with a plan how do they withdraw those money out to real life so I think like one one time we see a hack and the hacker apps are actually using their own ens that's probably linked to their Twitter accounts so so I think after two or three days like the guy was arrested after that just because it goes like it didn't really it didn't really do too much effort on that part and also like a lot of tokens like a version like usdt like they can immediately Blacklist your your address if you didn't try to you know mix it up for to another address fast enough so that's another interesting takeaway we get from our monthly hack run up uh besides of that we also have a survey trade which in Japanese we kind of call it like shugil so we try to log ourselves for a week and probably you know I mean in real life it's been Hotel it wouldn't really be in the temple but we got a lot of travel in the hotel and for that way we're just discussing about like what are some for instance like awesome potential hacks for some kind of new ecosystems or for new kinds of architectures for some of the weakness and this or or sometimes we just discuss like what are some new tools so for instance I think for the next one we'll probably be discussing about how we can use jgbt to do our audit potentially uh so we get a lot of it generates a lot of our talks or our papers from this and so for instance like we had like like last years for last two years we discussed about like what kind of potential hacks could be happening on Bridges because actually a lot of bridges nowadays are still pretty centralized not sure if people are aware of this and and even even not centralized like they're still like how Bridge handles we are usually they didn't really handle it very well so we realized this after we do the research another thing last year we did was like we we're reviewing all the raw systems and usually people when they come to Raw they're single it's a layer two it should be very decentralized but then because of their sequencer are usually still nowadays I think it's improving but it's still centralized sequencer and they don't have a very decentralized way for them to ex exit from the layer two if they're indeed have some issue for the sequencer so that was another server another research we're trying to do and then we had also have a short paper for that as well so these are the things we do try to keep off itself up to date aside from that we also tried usually when people come to us you feel like we are third party we are a bit farther a distance away from you guys but there are times we try to actually be more you know like integrated to your your protocols for instance like in Clinton which is a blockchain uh itself not sure if people know that uh it's thing is from Korea so it's probably more popular earlier and we actually tried to stick and try to join your governance so we try to be part of them and we also run our own validation notes for them uh to secure the network and this helped us as well so we learn more knowledge and that's how we can get more deals and get more deals we learn more mods and we can use it as a good cycle to improve ourselves so as our missions is to secure the future of web 3. so we not only try to do those things we also helped train new talents because in the future it will be a new generation that's working on the blocking space or even the AI with blockchain space perhaps uh so we have engineering helping this for instance like we before we work with like the D5 talent I think it's a it's a program that's trying to train like new Engineers working on D5 platforms so we try to we have like a bi-weekly call with them trying to share of some of our knowledge and try to share like some of potential career paths with them we also have an engineer currently teaching in like a university in Taiwan so he have a he have a I'm not sure it's a blocking or D5 course but he have a course there it's a full semester course and I look at their agenda it's pretty deep I think it's from like from 101 block blockchain 101 to all the way to like very very complex D5 contracts yeah so that's how we're trying to help in this industry and so so far our product has or our service has been helping to secure before launch that's why we do audit so we help to ensure your quality before you're deploying your contract or although like a lot of clients deploy their contract and then after a while they come to us that's another story but usually our security we usually help before you deploy but we are also trying to see how can we actually continuously helping our people to help it to help secure them further on because it's an ongoing game it's not things that you finish after a deployment so we have a subsidiary called Trend proof and they're trying to provide sort of like a guarantee like a book here so whenever you have an audit and we're happy with your quality then we can potentially give you this kind of guarantee which in the future if some exploit does happen and we didn't catch it during our audit then we will be able to refund you into a certain degree and also we will provide a continuous monitoring service that's where we will be able to alert them like hey I think this is weird you probably want to take action to pause your contract or to do certain actions Within probably like an hour uh to try to try to Medicaid the the loss of your of your exploit so yeah so that's what we are trying to do in the future and continuously in improving this um so that's pretty much it thank you everyone any questions oh uh it was called D5 talents but I think it was a bit weird like a bit years ago yeah we hadn't other colors but that's on like the university inside the universe so it's probably not online I think not yet it will provide I try like it will provide certain insight but all it's still a lot first like it has a lot of false positive and it sometimes doesn't really fully understand it as well so I wouldn't say yes right now but given the current status I think yeah probably after years it will and we need to figure out how we're gonna survive what in your mind is the most ingenious hack you've seen ah that's a good question the most ingenious one well so the one the run one of the reason why it's not really ingenious I think it's not like they use certain things that's super brilliant but um one hack I used to see like they just find one line of thought I mean a lot of hack is like that actually so I found that that's very interesting because they have to spend so many effort on actually looking at their contracts and they don't know they don't even know which one would have issues right so uh I've already don't want to name the exploit itself but then I I use the C1 and then it's really just one issue that's because of the mapping so when you're mapping then usually you wouldn't map like a zero key right you wouldn't have like a dictionary zero equals blah blah blah but somehow like during the deployment during your previous deployment they they accidentally deployed the value to that mapping slot although in in the later deployment I never use that so people forgot about it but then the hacker realized that and then used that as a hack to to get a fee yeah so that one was very interesting and then even even worse was like the everybody can copy the hack so that and let them like there's a transaction there and then people just copy past their transaction probably change their their address and I just and the next hack happened and so it's a originally it was one a doctor and then it becomes a public attack on the world yeah cool I guess if no more questions and that's it thanks everyone

Automatic transcript — names and jargon may be misspelled.