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

Loading player…

Intro to Security First Development – Gonçalo Sá

Ethereum DenverFri, Oct 9, 2020, 12:00 AM

This talk is from ETHDenver, the world’s largest Web3 BUIDLathon and Community Gathering. ETHDenver’s content is crypto and blockchain focused. Subscribe to our channel to learn more + connect on Twitter: https://twitter.com/EthereumDenver. Speaker: Gonçalo Sá of ConsenSys Diligence Abstract: An intro to Ethereum from a security first perspective. Ethereum is hard, you are building entirely new infrastructure and technology from the ground up, and securing it requires a holistic approach that does more than find bugs in code. In this talk we will discuss why computation is consensual throughout the network, asynchronicity, why security is important, programmable money and how security is achieved in our space. This talk was recorded Friday, February 14, 2020. ETHDenver 2020’s content themes included DeFi; DAOs and Token Engineering (TE); Gaming and Usability; Protocols and Interoperability; and Public Good and Social Impact. Industry experts also weighed in on topics like decentralization, privacy, identity, non-fungible tokens, scaling, governance, diversity, and arts and culture in blockchain technology. The 2020 event was February 14-16 in Denver, Colorado and hosted 2000+ blockchain enthusiasts, developers and community members from 50 countries and 50 U.S. states. 🔴 SUBSCRIBE ETHDenver’s YouTube https://www.youtube.com/channel/UCgz9NU06t_FkT0Py1Vadczw 💡 LEARN ETHDenver’s Official Website https://www.ethdenver.com/ 👋 CONNECT ETHDenver Twitter https://twitter.com/EthereumDenver 📖 READ ETHDenver News on Medium https://medium.com/ethdenver 🛍️ SHOP ETHDenver Official Merchandise bufficorn.com 💬 CHAT Telegram https://t.me/Ethdenver Discord https://discord.gg/jteMn5c 📱 FOLLOW LinkedIn https://www.linkedin.com/company/ethdenver Instagram https://www.instagram.com/ethdenver/ Facebook https://www.facebook.com/ETHDenver/

Transcript

I'm gonna talk about like an intro to Experian I realized that like probably everybody already knows about a theorem so we're gonna play a few like game meant to educate you on solidity security and I'm gonna distribute these beanies to everybody like that gets like right answer so yeah this is me Gonzalo and this is a presentation built by our bar colleague Marillion so thank you to him awesome game and let's play how familiar are we with solidity in the room do you guys write code have your written code before yes do you guys want to be me let's go so name that vulnerability round one [Music] wrong with this what no yeah that's that's kind of that's kind of it like the transfer the the problematic line is in transfer but what can go wrong here it fails silently okay well what exactly fits so let's if this means anything to you this is something that was problematic for king of the ether back then yeah exactly so the answer is like the the OS macGruber right so like what happens is that you provide and the highest bidder is an address that always reverts right if it's a smart contract that will have a fallback function that it always reverts you if successfully do s the game nobody else will be able to claim any beats higher than that so okay cool yeah one way to to mitigate this would be to use a we drop at pool patent instead of a push one so people can take the money out themselves instead of what you pushing money to someone else round two [Music] then you don't get to answer again someone else come on and bounded and unbounded Boyd yeah yeah exactly so the the problem is that like you can do s with the gasps Lehman right like if the array gets too long then the while loop gets too expensive and the contract will be broken forever until the Contra the the block gas limit is is increased by the miners for example right but all you know it's not doable one thing that you could do to mitigate this would be to use batches in a possible function like this right like you have an argument that you can provide to just like do it incrementally so that you don't hit the guests on it wrong three do it do it do it do it do it what is it okay but it rhymes with Nancy sir yeah exactly so the you're exactly right that there's a there's a call that forwards all the gas in the user balances are being updated afterwards right so yeah just like this is exactly an example that is very similar to the vowel yeah you're just like transferred execute like the the control flow to and to another smart contracting you can never know what's happening so you should use just the the check effects interactions patterns where you actually do all your stuff and use your external calls at the end so round four oh by the way sometimes they're like there's more than one right answer so I'll take care I'll take anything you guys can ship yeah exactly so there's a lot of problems here like this is this is bad yeah there's definitely an overflow there's an underflow haha yeah and the first one is another flow so the the first line please don't do that like like nobody does this this is only for illustration purposes like that line is terrible like that check is not is literally not doing anything that's a an unsigned integer I think bigger equal than zero like that's that's just bad that's just like no op and then the others below do have the problem that if you could under flow the vet that your balance right and just like own a huge amount of tokens because of that under flow yeah so the the mitigation for this would be to use proper requires check for check for the for for balance overflows before you actually update them or use safe method right which is the which is the around 5:00 again several problems aiming for what this is a little bit more convoluted but feel free to shoot anything that you think is okay yeah there's overflow problems with that multiplication not what we're looking for here that one is done more and more ideas this hint is terrible I'm sorry guys this is like this is this is not obvious so it has to do with the way transactions or they're right in the gas auction and the problem here is that let's pretend that this is a exactly like a token auction or something right like if if the owner sees a transaction a by transaction coming in he could front-run the buyer and actually increase the price right before he buys it right and he gets more money than he sure they were like the buyer gets no dope no tokens whatsoever so yeah that's it what are some safer approaches on in that specific example a possible solution would be permission key functions right so type of user can update the price or the buyer could specify the price or you could use a time lock right so it when the owner changes the price it actually only gets active activated in like two days or something right so that that way users are sure that like the prices do not get that the rug does not get pulled from under them right yeah next from oh really good really good nice nice one and there's also another problem but yeah that was the main one yeah but yeah that's that's you you got it exactly right but but there's also another thing right which is like randomness is hard like this is not random at all like people could gain this randomness there's absolutely no no nothing random about this and yeah and like you said blocks only know about the 256 latest blocks on chain right so two problems this is a hot topic now I guess but a solution would be to use the random there's vdf sand vr af-s to to have like as proper sources of randomness be at in general don't use like a low entropy to to create a randomness I guess you round seven I guess same same horrendous goat what yeah it's clearly bad right because we've looked at the code previously what could go wrong with this if I see what exactly that's it you cannot get all of them right yeah that's exactly it so there's no way to guarantee that the balance of the contract is is static right so you can forcibly send ether to a smart contract and today I guess you get another beanie those of you who are hacking you can check out our best practices those best practices it'll help you write better code safer code you can fight it on github if you can't find it you just come to me I'll point you to it please use reusable frameworks use open sapling that that makes your code safer too maybe that pub if you feel like hipster enough dual into your code please it it's it's effortless just lose your soul hint or something I don't know I don't care just do it lint it use me thanks you should be using the text me with X dot IO if you need we can give you a trial account if you pass by the booth downstairs you can talk to us and give you a few analysis for free to run I live here I'm sure and that's it yes now I'm really over thank you [Music] you

Automatic transcript — names and jargon may be misspelled.