Practical security vs theoretical security
ETHCC 6 · July 2023 · 25:46
Mudit Gupta examines the gap between generic security guidance and the requirements of a specific environment. The speaker argues for practical defenses based on context rather than applying theoretical rules mechanically.
Speakers
Topics
From ETHCC 6, hosted by Ethereum France.
Transcript
[Music] foreign [Music] officer at polygon I manage security and smart contracts there and today I'm gonna talk about a very nice neat topic theoretical security versus practical security because especially relevant to this space I've seen in this space a lot of people aim for like the idealistic scenario but they forget the basics like
you make a super hard you know like super secure super nice decentralized system but nobody can use it like then what's the point like your grand the mnemonic is a good example of that but I'll come up come back to all of that later get started some quick context about my slides so my dog ate my homework so my slides are very patchy I just made new ones today this morning so they are not perfect but they are gonna get the job done so practical security versus theoretical like this is a good example like a perfect gate like someone spent maybe hours building this although it doesn't look in perfect like uh situation right now but uh that's the whole point like
you can build something perfectly secure at one stage and then forget about the others and people will bypass so security is all about covering all of your bases the thing about security is that as a Defender you have to cover every single point if you leave any hole someone will get in as an attractor it's easier you just ignore the secure system you find a way around you just have to find one way to break in and that's it so you have to be like it's it's much easier to be an attacker honestly than to be a Defender and this is why like I love to be an attacker but someone has to riff it so here we are the first thing I'm going to talk about is not your keys not your coins everyone
has probably heard this phrase everyone keeps bringing this up in crypto if you don't own your keys uh then they are not your coin like someone else can take your coins I'm gonna talk about the opposite of this it's very interesting because the opposite is you lost your keys you lost your coins and this is actually practically a bigger problem then not your keys not your coins uh problem so there have been at least a couple billion dollars lost to Lost Keys already and I'm sure there are more that we aren't uh tracking and there are billions of dollars uh in wallets of users that are improv that are incorrectly secured because the thing is
keeping a mnemonic safe is super super hard it it is much harder than keeping a password safe because you can change your password if you forget it you can change a password if it gets leaked uh and everything but a mnemonic is just a one-time thing you have it once and if it if you ever make a mistake if it ever gets leaked you are done so keeping a mnemonic or private key safe is a much much harder problem and in crypto space us crypto Engineers decided to just uh make this thing and say oh it's 100 secure nobody can know your mnemonic and we told our grandmas to use mnemonics and then they have no idea how to use it so the problem here is that clear
example of theoretical versus practical security theoretically a private key is 100 secure like if nobody knows your private key nobody can access your funds but practically there are many many many many problems uh starting by like uh what if like you die for some reason how can your loved ones access your funds so that's a tough problem to solve then there is key rotation problem what if for whatever reason your key is compromise what if we realized there's a bug in Ledger uh the bug it hasn't led to an exploit yet it was a zero day let's say but now you have to move to a different device that's fine but you
can't like you're stuck you can't change your mnemonic you have to move everything from an old mnemonic to a new mnemonic and now imagine it's D5 you're doing things like wasting you can't change the vested address you're gonna get funds on this address for sure uh in few years and this key is already compromised what do you do yes just stuck it was not the best solution to of a mnemonic and then us Geniuses come with came up with a solution to this which we call multi-six so let's just use multi-six and then we can rotate keys in multisex software multi-6 that's actually a good solution again theoretically practically one like if someone doesn't know how to secure a mnemonic key they're not gonna know how
to use a multi-sig if you have used used it now I've seen the ux now it just sucks and the other thing is like half of the apps in this space don't support it either so we are like in theoretical security we are running so fast in practical sense we are so far behind so we need to really really really catch up there moving on okay so another example would be like to not plug in your laptop in unknown ports wherever you go because that that's a nobody really thinks about but it's actually a very practical attack scenario especially it's in like conferences like this where there are many notorious people around and that up have access to these wires so yeah avoid
plug in your laptop in I promise this is a laptop I borrowed this morning it's not mine so I'm fine but yeah that that's one thing you should not do okay some more examples uh so I've seen a lot of people not install antiviruses on their computers because they're like oh no the antivirus can rug me yes that's a very good very valid theoretical attack Vector you should know about the risk but practically the chances of you getting a virus if you go raw dog is much higher just always use protection just install an antivirus up there and I promise you if you are using a trusted company a trusted brand then the risk of them getting compromised and
Wrecking you is lower than you mistakingly clicking a phishing link and going there this is like phishing is again something I'm like I see very often people ignore phishing attack vectors completely because they're like oh fishing needs me to make a mistake I'm not gonna make a mistake ever but bro you are like tell me what you do I'll tell you 100 ways I can face you you're a VC I'll just send you a malicious uh doc a malicious deck uh you will open the deck and then right you are a software developer I'll compromise your friend I'll uh push malicious code to the repo you work together and you get into get pull and then you're right really like it doesn't matter how serious you are with security even if you are a very serious
cryptographer security researcher whatever do you really verify or audit code that your friend is pushing no and do you trust your friend to not make mistakes that you're making if you are then that's your fault but you shouldn't so just be safe just install it like it's not gonna keep you 100 safe but it's gonna stop 99 of the attacks um so don't fight it just just you don't need to take the risk why take additional risk then oracles this is another interesting topic people keep blaming like chain link is centralized they have a multi-sect they have this they have that and so on but and then like what's the alternative let's use decentralized oracles like let's use Steve Ops uh the thing is like
devops are theoretically secure but practically super insecure I give a whole talk about this um at DSS uh last year and this year in Korea I can speak about this like for half an hour why they are insecure but the bottom line and you can see from the track record number of times chain link multisig has been compromised to push bad Oracle prices so far is zero and number of times devops have been used properly is also zero the number of time t-bops have been compromised is more than 10 I can just keep counting and the best of the best are failing at this is just a very hard problem I'm not saying t-bops inherently are insecure they're theoretically the securest thing but again practically they are one of the weakest links out there and people don't
realize this okay so multi-six let's get that out of here so obviously there are two main choices here either you get a multi-sig and you make your contracts upgradable or you say oh I'm the best developer my contract can never have a bug it's gonna be immutable contract since launch uh you can choose both parts theoretically the uh a non-upgradable contract is safe because nobody can drag it or whatever practically speaking the chances of you having a bug in there mistakenly is much much much higher than a known multisig with known participants uh reputable participants trying to get uh just because of one reputational risk regulatory risk legal risks and
everything so you just have to manage the risk there if it's a very simple small contract then yes hundred percent the multi-cigarettes doesn't make sense go with a non-upgradable contract and even if you are going with an upgradable contract don't just upgrade it to add useless small tiny features or else you will get wrecked many projects in the past have gotten wrecked because they upgraded the contracts to add a feature which they didn't really need so yeah have multi have upgradable or possible contracts be smart about them you can have time locks and things like that but that's a good way to stop uh to prevent being getting wrecked really oh Legend I have so much to talk about uh
uh later as another French company so right uh on topic but if anyone has been breathing in this space they probably remember all of the fat that went around Ledger like Ledger is insecure stop using Ledger Ledger added a back door and whatnot but the thing is like people again forgot like theoretically yes like if they had um another API to get your private keys that can be exploited but practically it made zero impact the reason is ledger always had that API it is not something new you just learned about it now you didn't knew about it before if you have seen the uh like if you're seeing the architecture the way ledger works is the apps can always get access to the key and that's why that's how the apps do the signing the secure module doesn't it can't sign things of the future like if
there's a signing scheme uh or that is created in the future like the secure module is not gonna know how to handle it so the way it was built is it it is upgradable uh so Ledger can push out uh upgrades firmware upgrades to it and it can theoretically take your keys but again it's a theoretical attack vector and it is applicable to all other wallets you talk about um and yeah this is another funny thing I uh many people on the space were like oh Ledger is insecure let's move to grid plus it's the same attack Vector there they can upgrade your firmware they can take your keys and it's not public Source either like so you can't even verify if it's secure right now so those are all very theoretical scenarios that are most likely not gonna happen you
know there are some more practical scenarios that people don't care about for example supply chain compromise like if your vendor Hardware vendor is just using a company from China to uh get all of their Hardware like what's the guarantee the Chinese government won't uh add a backdoor at the hardware level at that point you can't do anything from the software level and like this is something practical because very recently if you know about multichain like they just took the multi-chain Creator and like just he just vanished with his keys then funds starting moving over so the founder sister stepped into white hack kind of and then the government took the sister and now nobody knows where they are so if you think like the Chinese government not
being malicious is not a real Attack Vector then maybe think about it again um that in my opinion is a little more likely than a ledger being malicious and this thing with Ledger being malicious it's it's easier to detect if it's a software level malice it's easier to detect than a hardware level malice so it it would be stupid for them to do it uh something intentionally and that's the like practical side of security if you go with another Hardware vendor uh ask them like about their supply chain and so on like they're gonna be 100 secure theoretically but practical security is a tough choice uh at the
same time to be honest for all practical sense most of the major Hardware wallets like uh Ledger treasure grid plus they are all perfectly fine uh you're fine with any one of those if you are using uh your uh crypto wallets like just get a hardware wallet it's much better than a software wallet like metamask you will be much more secure and just use them doesn't matter which one you get like just get one that's the practical sense nobody practically speaking is gonna come after your crypto if it's in Hardware wallet and you are not compromising your mnemonics there are much easier ways to attack your crypto and as I said like for an attacker they just need to find one hole if I am an attacker I would not attack Ledger the
like big gate of security when I can just walk around and fish you um and things like that so in practical sense any hardware wallet Works don't look at the fact that like talks about Ledger and so on one thing although I'll add here is the new feature from Ledger about backup that's all all those stupid like I won't recommend anyone to really use that that is actual risk of uh that if you opt into that feature then it sends your key to other centralized servers that can be compromised so unless you don't know at all how to manage your key which if you are using a hardware wallet you should if you don't know how to manage your keys don't use Hardware wallet just use coinbase just use a custodial solution uh only get to Hardware wallets when you have learned a
little bit of Key Management and you have done that then don't opt for that kind of backup Services those are much riskier practically and humans are obviously the weakest link in security because human behavior is something you can't secure you can't add test cases and test continuously if this human is compromised or not like there are so many attack vectors here that it's just super super super super super hard to make sure humans are safe uh fishing is one of the biggest ones that I just talked about you tell me like any person anything they do and I'll tell you 100 attack vectors they can be compromised for nobody if anyone thinks they can't be fished then they are just wrong but at the same time we
should at least make people aware of the basic fishing scenarios so they don't fall for the basic things um and as I said security is all about like layers so fishing is just one of those layers you have to be secure on all fronts if you are using a ledger you have one gate covered if you are aware about fishing you have a second gate cover then the attacker would instead of trying Advanced Techniques to fish you they'll try to find a third Vector which might be more vulnerable so you just have to get all of these levels up as possible and also it depends on your risk profile if you are just a random person playing with nfts thousand dollars maybe in your wallet then uh deficient attacks that are going to be
targeted towards you are gonna be Mass phishing attacks nothing very targeted because it's not the risk reward ratio doesn't make sense for the attacker but if you are a crypto founder let's say you are measuring you are managing a treasury um you are on bunch of multi-6 then your 100 need to be more secure more Vigilant because then there can be targeted attack vectors on you and we have seen in this space like great crypto Founders have been wrecked by phishing um and long cons as well like we have seen attack vectors where um someone befriended a crypto founder they talk to them for months and months and then finally executed the attack once they add their confidence so you make a new friend at this conference it's 100 possible they might argue two
months down the line so you just have to be very uh conscious about that fact and the other thing about humans fishing and everything is that our attackers are experts at this um so the people we are really fight there are two types of attackers in this space one are like the seasoned professional people doing it and that may be state sponsored or not and the other is just college kids doing some scripting the college kids that do some scripting usually go for smart contract attacks and usually they are caught so you have seen like funds being returned from bunch of protocols because the kid didn't do proper object so those are relatively easy to catch but then you have professionals doing it and there it's much harder to do anything or
you have dprk like attacking us and they are experts at fishing they're not gonna like leave do basic attacks and if you're if they are going for you they'll they'll just go and we have to fight against them so we have to make sure like our fishing awareness training is up and ready because it's gonna be much much harder to stop those guys than it's to than it is to stop some kiddo like you just even if you write a complex smart contract uh then it it's safer than um like a compromise scheme so in general like if there is a bug in a smart contract and there is a bug in your key management practices it is 100 more likely that the key Vector will be compromised because just there are more
people targeting that attack than people that are targeting the smart contract um it doesn't mean you don't need secure smart contracts but it just like I want to put attention on things that you need to secure don't forget about the traditional security so another good example of this would be uh like people make 100 secure contracts deployed on the Chain they can't be upgraded and so on and then use a dollar one domain restaurant to register their domain and serve the contracts UI through there uh the contracts are immutable unhackable nothing happens to them but then the DNS gets hijacked and boom they're gone um it has happened to many many reputable projects uh like curve finance that comes to mind they have like one of the best security
hygiene and risk management practices uh but guess what they were using another city registrar because they wanted privacy and that bite them uh bit them in the ass so avoid all of these cheap restaurants I personally use a cloudflare a lot and cloudflare has a toggle that allows you to revoke access from cloudflare support to your domains so usually all of these restaurants have support in case you lost access you lost password or something that they can restore your access but they can also rug you so cloudflare has a neat function which uh allows you to click that button and then nobody from cloud Fair support can help you it becomes your like your login access your domain if you can log in you can manage if you
lost access you'll lose it so if you know how to do it it 100 makes sense to do it uh another attack Vector people talk about like inferior Can drug you know infuri is by consensus you're using metamaster like if they wanted to argue they'll probably do it at the wallet level you won't they'll show you what you are signing they'll show you something innocent you're signing and then make you sign something else so all of these attack vectors are gen genuine but the thing is like inferior let's talk about a malicious RPC a malicious RPC can't really create malicious transactions on behalf of you it can only give you false data or it can give you uh or it can censor you if it's censoring you you will obviously know your transactions are not going through
you will change the RPC provider if it's giving you false data you will likely still know and you won't act on that false data so that's one thing like infuro most likely is not gonna argue be aware of the wallets you use they are more likely to have bugs uh some other attack vectors like don't go to cartel cities everyone like that's a practical attack Vector if all of the multi-6 are there at one conference may not be good don't invest in Shiba Inu minu mooncoin even if you are using Ledger then MPC obviously is the last thing I want to touch on most of the MPC in the space are basically like this so make sure that if you trust an MPC you know
what you're doing it can be hard a good example of this would be like recent multi-chain hack where the founder had access to all of the keys and then the Founder's sister had access to all of the keys and then the Chinese government has access to all of the keys and now your funds are gone so yeah like if you are trusting an MPC based solution think about it again do proper risk management and the final thing uh alright is like yeah not just multitude Harmony Ronin this was I guess perfect example for harmony it was a two by three multisig and everyone was just the same uh but yeah just be secure and the final thing is like manage your risk nothing is 100 secure uh you have to manage your risks accordingly according to your risk habitat and what you're doing they're
gonna be some theoretical attack vectors you you are gonna have to accept they're gonna be some practical attack vectors you're gonna have to accept there are gonna be some attack vectors you can mitigate so you will mitigate but yeah like don't spend like 100 hours to secure a one like one dollar toffee or something you have to like balance the balance everything properly and I tried to translate questions in French but apparently it's also a question so I added a date just in front like to make it French and I'll open it up to questions now anyone [Applause] whoa great talk
um I'm curious to know what your thoughts are uh on the state of like auditing generally like individual Auditors all the competition audits uh the auditing firms what your thoughts there are versus like on the value they provide and what the optimal process is there and then also what polygon does yeah for sure so auditing is super super important you should definitely get as many people as you can to get to look at your code because you can obviously it doesn't matter how smart you are you are always going to make silly mistakes like things you know like it's not that I don't know that that's this is gonna lead to an exploit it's just that I will miss it I will assume it's doing something else if I'm writing the code and for those mistakes it's good to have more people look at your code and as far
as options are compared so audit contest I looked them as like a mix between bug Bounty and audit engagements traditional audit engagements I think they have their space and you should definitely go for them but you should additionally get traditional audits because traditional audits give you some uh like peace of mind at least that people are actually looking at your code audit contests are very can be unreliable in the sense like if there is a bigger audit contest going on at the same time then people are maybe pay attention to that and not pay attention to yours um so it's risky but it's a good addition so my recommendation would be to do both and at polygon we have internal audits we do an external audits we have continuous engagements with Auditors we don't do just like at the
end hey is it secure we work with them over the time and we discuss the architecture hey should we do it this way should we do it that way and then from start we have security at mine then we are looking at audit contest that would be uh like we might have one coming up on code Arena very soon that's going to be fun and so on hi um quick question so do you think that the 2fa using 2fa for uh on-chain transactions uh could increase the security or do you think that having a hard wallet for individuals would be enough so Hardware wallet um already have to have in some sense if you are using a ledger you have to enter your PIN to do it and you can set your
ledger to such that it requires PIN for every transaction so there is a 2fa inbuilt there uh you can add on additional 2fa to that but I would say that would increase the theoretical security but not practical security there are very very very few attack vectors uh that would be valid on a ledger um that like it will lead to malicious signing more easy would be to fake a transaction like on Ledger nobody really verifies what they are signing so a more easier attack Vector practical would be to send malicious data to Ledger and then you just look at Ledger's tiny screen you see some numbers and you sign and then you are right so that's a more practical concern than slapping another 2fa on Ledger
thank you thank you okay thanks everyone [Applause] polygon fans we don't have much swag here but the seats look purple if you want to grab one feel free [Music] foreign [Music]