All about Smart Contract & DApp Auditing
All about Smart Contract & DApp Auditing · 17 May 2023 · 1:08:40
Oliver Murray, an auditor of smart contracts, walks an Ethereum Engineering Group Meetup through the audit process from start to finish, to help builders choose a service provider and prepare. He compares automated tools such as Slither, top-down bug checklists, formal verification and manual code review, which he calls the best approach, then covers preparation through modular design, documentation and varied test cases, plus post-audit monitoring and bug bounties. In the Q&A, a participant who works in formal verification disputes his view of its limits, and Murray says audits typically come without guarantees.
Speakers
Topics
From All about Smart Contract & DApp Auditing, hosted by Ethereum Engineering Group.
Transcript
hello and welcome everyone my name is Peter Robinson and this is the ethereum Engineering Group Meetup today we've got Oliver from zelik and he's going to talk about blockchain auditing so Oliver um please introduce yourself hey guys how's it going um so yeah um my name is Oliver um I am an ex-financial engineer so I used to build programs that price derivatives stimulated markets and aggregated portfolios for modeling collateral exchanges uh very well suited background for D5 at zelik I used to audit cool projects like algorithmically stable coins on move and Solana lending
platforms and financial MTS on ethereum and a bunch of infrastructure type contracts now most of my time is spent on the sales side where I'm talking to Founders and Developers so with that maybe I'll get into the the talk start off with the agenda So today we're going to discuss the audit process from start to finish the goal is to help Builders select service providers and help them prepare for the audit process we'll discuss different types of audit processes the business models and work environments that support them getting ready for an audit and what happens after not it at a high level smart contract auditing
can effectively be grouped into the following main categories automated automated approaches top-down approaches formal verification and manual code review and economically oriented audits so these approaches are not mutually exclusive but I'll just use this as a frame that's useful for separating key points between them starting off with automated approaches Slither is really the main tool that we see here used on the evm side basically we can code up a bug signature in memory and run an algorithm to search for it on solidity files
so this is really the most limited form of an audit that we see out there and Bug searches are typically confined to simple coding mistakes and single function scopes um the hit rate for finding bugs in these algorithms is also fairly limited so even if a bug is there it can be missed and in the past this has resulted in scenarios where our teams have run these tools and they think they're safe and unfortunately it turns out that that's not always the case another type of auditing approach sort of the next one up is the um our top-down approaches they require more skill than automated approaches and basically how they work is Auditors have
a list of known exploits they are concerned about and they need to be trained in identifying them in the different ways that they might appear across protocols so like the automated tooling approach suffers from a major drawback which is that they are primarily reactive in the sense that the bug types need to be known beforehand formal verification is another form of smart contract auditing and there are benefits to formal verification that no other approach can really match so we can isolate the specific behavior of a smart contract um isolate a specific behavior that is um and these are typically called
invariance and demonstrate that under no circumstance or the specific circumstance under which this Behavior will be violated so as an example of an invariant in a recent blog post uh by zelik we showed that there is only one possible scenario in which the accounting balances of weft 9 could be broken and this was actually a pretty neat discovery that nobody was aware of at the time so I'm happy to share that blog post at the end of the talk here um but there are some strong limitations to the form of verification approach so it takes a lot of resources we basically need to replicate the business logic of the protocol in another language which kind of raises an
interesting question uh which is sort of a cool audits the auditor's formal verification program and another challenge is that it can really only be applied um maybe not so much in theory but at least in practice for what I've seen to um quite simple in variance that is behaviors the best form of smart contract auditing is uh in my opinion anyways is the uh is the manual code review and this is a combination of bottom up and top-down approaches so on the top down side you want highly experienced Auditors who regularly review bug libraries and look for a wide range of
known bugs and code not just a select handful on the bottom up side it's about approaching the protocol with a fresh set of eyes um a beginner's mindset if you will to sort of borrow a term that's commonly used in yoga so everything needs to be passed through the filter of the critical thought process um and evenly seemingly safe looking code or familiar code cannot be taken for granted but you know like all approaches nothing is foolproof um and it's never possible to find 100 of all the bugs at zelik our process for
um the bottom of approach works like this so we start off with low level functions and move up to high level functions and the key concerns are we need to know what are the parameters States inputs that need to be valid validated for a function call these are called the preconditions um we also need to ask what are the outputs and the state changes made after function call they successfully made these are called post conditions this process of examining preconditions and post conditions follows an iterative flow from low level to high level functions and ultimately encompasses protocol-wide business logic after we've sort of done that first
iteration or that first pass-through we iterate we'd like like to take that understanding that we've Now sort of obtained from the protocol at a holistic level and then go back to the very beginning and start off with low level functions we're going to have a better understanding of the overall state of the contract and the implications of function calls that are made for the rest of the protocol so one of the things we focus on in high order functions is called Branch coverage so depending on the values of the parameters passed in or the state of the contract when a function is called the flow of a program control and high order functions can take different routes so what I mean by different routes is
basically you can have those lower order functions or internal functions be called by the high order functions depending on parameters and contract state comprehensively capturing this is called Branch coverage and it's something we spend a lot of time focusing on we have a very standardized process to help our Auditors work through and document this process the key objectives in this more standardized process is to eliminate bugs at the function level and build a model for attacking bugs at the protocol level at the end of applying this standard operating procedure for brand coverage we should know the main functioning of the protocol Key State variables and how the user interactions can influence
state and then we can start at the more creative process of searching for sets of user interactions that can can exploit State and can lead to things like loss of funds or denial so if there's any questions sort of after that initial section I'd be happy to hear them um and then I'll sort of like continue on with like this next section um Oliver sure what um that you mentioned formal verification what verification tools are you using so formal verification like we use like smt Checker to like set up the equations yep
um primarily primarily that I'm not actually an expert when it comes to formal verification my experience is more on the manual code manual code side yeah okay cool thanks uh a question for me what do you have you used any AI tools you know check GPT or others um and you know what are your findings on using them to try and audit code yeah so Stephen our CEO and founder actually did a blog post investigating chat GPT for searching for bugs and I definitely think sort of in some cases
you can use it to find sort of um similar to how you would use something like Slither to find sort of like bugs isolated to a single function um and maybe sort of more well-known coding mistakes but I definitely see there being quite a few limitations on caption any bugs that would sort of present themselves more at the protocol level so any sort of more of like the cooler economic or business logic based exploits that we often see um but happy to hear other people's views on that yeah I'm doing a talk on the topic in about two weeks time so just interested to hear what you've got to say I can see
Frank's got his hand up so Frank over to you for a question yeah so I've got a question related to um repeatability and maintainability so you do your manual auditing process and so on and then change the code a tiny bit do you have to redo the analysis from scratch or can you perform some incremental checks so how do we handle that situation as a firm yeah how do you handle I mean you've got a you've done some auditing right manual auditing then we change part of the code how do you deal with that
well typically it's pretty straightforward if it's something that we've audited in the past um if we've audited the complete code base then we're going to have Auditors familiar with the Core Business logic when there's changes made um they're reflected in commits on GitHub so it's pretty easy to track down the differences between the code state that we audited and the code state after the changes and then it's just sort of a matter of scoping an audit that targets those differences if those differences can sort of be easily modularized and separated from the core logic then that's a lot easier from like an engagement standpoint but if they have sort of like protocol-wide implications that might alter some of the business
logic or the economics of the protocol um and that's definitely something we want to spend over time on stand good so thank you for that so I think you can let's go skip back to the talk now okay great so I think there's probably kind of fair to say that there are um sort of shops no this isn't as the term that like we came up with that might be referred to as like volume shops um these are shops that sort of offer more of like the top-down approaches or automated tooling based approaches to
auditing um sometimes they can get a bit of a bad rap um but they definitely serve a key niche in the market and that they allow projects to get to Market fast when where they can potentially earn Revenue demonstrate Market fit and get more advanced security audits later but it is important to highlight a few concerns with top-down approaches used by some volume shops they sort of have a built-in sort of hack D risk option if you will so what I mean by that is if a protocol does get hacked as long as the bug type does not fall into their search category or oftentimes these audit reports they start with a list of the
types of bug classes they're looking for then it can be claimed like that hack was out of scope and in some way this can have you know negative implications for the market for audits given that many Protocols are not necessarily well educated on the pros and the cons of different auditing processes so they may not be getting the signal about the potential shortcomings in the fundamental processes applied by these firms because the firm's name isn't necessarily tied to a hack which can sort of be um you know one of the key indicators that protocols can sort of use to navigate between the quality of the
services offered by different firms furthermore sometimes the list of bugs in top down approaches is not necessarily well aligned with the project being audited so it is important for Auditors following a top-down approach to work closely with projects to determine the appropriate classes of bugs to search for so outside of those two there's also like the formal verification audit shops and I think it's important to mention here that in our view or in my view um formal verification shops are not really holistic bug Hunters
um they are more so identifiers of key protocol behaviors that are capable of being covered through the process of formal verification so what they end up providing is an extremely high level of assurance of a specific functionality but it's important to emphasize that this process is not necessarily Well Suited at least from what I've seen um it's more complicated or novel business logic but it is extremely well suited for certain things that are very hard to manually audit and these I'm definitely hoping for some more examples in the chat but these can be things like math libraries or date and time libraries or sort of very specific
functionalities like some of the um like the accounting balances example I gave for West 9. so relying on a formal verification alone would result in large security blind spots and it's really best suited for larger protocols who have already had audits done and are looking to iron out the edges of their security profile that being said it's an area of extremely fast development um that I'm very excited about and I definitely think some of like the best people in the space work in this area so the manual review shops these are your more traditional hacker shops they do
really well when Auditors have sort of a combination of things in place so rigorous procedures that have been thoughtfully put together by the other by the Auditors at zelik we have around 20 Engineers or so when we put together when we were putting together sop we had everybody contribute to it so we would sort of all benefit from their unique perspectives um you know when coming to the creative hacking dimension of the audit um so Sops need to have sort of multiple components to them um the portion of the SOP that covers known exploits this is sort of falling
more into the top-down approach um we find this works best when it's supported by a firm wise practice of recording new novel bugs in internal bug libraries and also ensuring that knowledge is spread throughout the firm so when our Auditors come across new bugs um they share them with the rest of the team we're very active in our internal communication channels uh very excited to learn from what other people are doing so that's definitely sort of like I think that's sort of like one of the fun things about working at any audit shop but I haven't worked at other auto shops so I can't speak to how they do things there um the bottom-up portion of the SOP like I mentioned earlier this should definitely include sections on on Branch
coverage um and sort of you know within that steps to ensure that Auditors are building up you know that really comprehensive model of the protocol that's really going to be useful when we start to get into those uh protocol level exploits so I think outside of sort of those core sop operational considerations all of this needs to be supported by the culture of the audit firms so sometimes uh the questions we need to ask in order to find novel bugs are really silly uh so we need to have teammates that are invested in the process and non-judgmental um really sort of that that sort of seems best supported when you have a
track record of success where you're working with people you know who have done good Audits and you know that's part of that process so um it's easy to sort of take the time away from what you're doing and sort of entertain some cool ideas we also need to work with good projects who understand that takingly seemingly contrary or weird perspectives on a protocol is key to finding its breaking points uh we also see the best outcomes when you know I think this applies to any industry is when we're highly motivated um so I think sort of the way we think about our culture here is kind of like high performance Gamers uh we're trying to find as many uh and as most important bugs as we can um but that sort of fits with the backgrounds of the majority of the
engineer share the firm which is sort of like from the competitive hacking circuit so we just sort of like to sort of like carry that that lineage of competitive hacking uh but of course now we're all on um we're all on sort of one big team working together so uh it's definitely a cool Dynamic um also you know with any audit there's a lot of mechanical aspects that need to be considered so you know writing reports um standard procedures you know communication with clients um more sort of Engagement related things it's good to have those things sort of modularized across different um supporting supporting groups within the team okay so if there's any questions about
that last section I'd be happy to hear them yeah all right video Frank for a question yeah so I've got a question related to um the idea of finding bugs or let's say um behaviors that are not intended it should be defining the the uh the specification of the system should guide you to Define what are the intended behaviors and what are the unintended behaviors so when you you're looking for how do you define a bug actually what how do
you define it when you look for something in the code how do you end up saying oh that's a burger what are the the reasons you would say oh that's that's the with respect to what what what specification does it violate so that's the question I have so there's probably a couple ways of answering this um I think the most obvious answer would be um there are certain types of behaviors that any protocol developer is not going to want to have um such as trading funds from an account or being able to perform a denial of service attack outside of that and this is sort of
something we'll get into um in terms of preparing for an audit um is having a good documentation from the protocol in terms of what that expected behavior um other protocol is supposed to be but I think one of the things that that we do here we sort of take pride in is um taking a close look on what that intended implementation is supposed to be in reconciling with the code um and sometimes even within that intended implementation um it can have implementation implications that may not have been foreseen by the designers it can be potentially manipulated in certain ways and create behaviors that might be undesirable to them
um so one of the things that we do which really helps with this process is having that that daily communication with our clients so when we come across things that might result in behaviors that might be we might be concerned about we just immediately open up that line of communication and start the dialogue with the client and sometimes that can result in um sort of modifications to a design that ultimately gets translated to changes in the code so hopefully that answers your question but if it doesn't let me know so I I don't think he dances the question if you find an unintended Behavior or something weird you would have to explain why uh this is an
intended and again which specification it violates the other thing that I'm a bit worried about is uh you find the bug and you say oh yeah we're going to propose a fix and modify the code how do you know that it doesn't introduce a new bug that would violate another specification yeah so I guess I need to be clear in my first response so um if we do find something that does violate their specification then we would communicate that to them as a concern uh the last thing we want is the code implemented to DVA from what people on the business side are expecting does that make sense
to the second question which was oh yes so anytime you're giving um effects you cannot do it in isolation you have to do it with regards to its implications for the rest of the protocol so we don't look at fixing one problem in isolation we look at what the impact of that fix is going to be forever the rest of the protocol um and that just sort of falls into the time I spent earlier on the manual coding review stuff where we're trying to build up that holistic picture of how the whole protocol Works um so that's why it's super important to
have that sop to have that Branch coverage and have um sort of the manual code review process where you're really focusing on building up that mental model or that parallel computational model of how the protocol works so that when you see differences from the intended implementation or where you see bugs and you're going to suggest fixes for them um you sort of like readily position to consider and have that discussion around what are the implications of what those fixes are going to be because in our eyes if you are suggesting effects that creates another problem that's not a fix so yeah so thank you Oliver um Mark I can see your hands up
uh yeah thanks um I was most of your comments have been about looking at smart contract audits specifically I was just curious if you get much interest in um or have any thoughts on doing audit of of kind of off-chain security architecture or cross-chain protocols yeah I would say cross chain protocols is one of our bread and butter um we've done a ton of audits for Leo zero um Wormhole that happened after the incident that they experienced uh which is actually something I'll touch on tangentially uh later in the slide um off-chain stuff that's definitely not
in any of my special uh expertise but um we've done a lot of sort of um you know our background is is competitive hacking so we were the global number one ranked team in the CTF circuit for 2020 and 2021 so um and we also did a lot of bug Bounty programs so hacking Fortune 500 companies um hacking operating systems hacking Android phones and iPhones so that's all stuff that's sort of like within our range of capabilities but in terms of how we operate the business uh we tend to focus more on the smart contract side and if required we can also offer additional support for for other stuff is have you seen any kind of good tooling for for off-chain or cross chain um analysis
good tooling what do you mean by good tooling Slither like it's just for a Bismarck contract but uh any other automation personally I haven't um but somebody on the team might have I I actually haven't done any of the uh cross chain audits so yeah okay thanks dedicated team to that I can see rude you've got your hand up yeah I had a question about um when producing what are some of the best practices that you've seen in terms of how a protocol would be able to provide a clear specification um so that an audit can go more smoothly
are there any uh best practices or standards industry-wide um that say you know they should have these properties and these properties and these types of functions to be clearly laid out or anything like that what have you seen and um what would you say are like best practices around that so so the best practices around presenting documentation and I guess around the the knowledge transfer for if I if if someone is producing a a protocol and they want to be able to make sure that the Auditors have all the
tools that they need what would be what would be the things that you're looking for that if you you know if if this if that information was laid out uh to you guys you'd be able to uh have clear guidelines or clear guidance in terms of where you should be looking in and how things should work yeah that's a good question um we have not seen sort of like any group come together to establish like best practices for that um it's definitely something that is you know as an audited firm sort of challenging to we don't really want to take the position of trying to enforce that upon anyone because doing it to
what I would think would be um let's say the outcome of a meeting of Mines to kind of determine the best practices would be quite an onerous procedure um and a lot of these Protocols are looking to to launch quickly um their startups limited resources so there's always sort of the cost benefit considerations that protocols need to make in terms of how much time to put into creating these documentation for us to review um that being said I think you kind of touched on it in the formulation of the question in terms of what we would most like to see there um you know I really can just sort of take documentation to its extreme and that would be you know for every
function um we'd like to see a description of what that function is expected to do uh with the just descriptions of the parameters basically what their impacts on the function are going to be the different state states of the contract what functions are going to be interacting with them um so sometimes we see stuff that approaches that we've definitely worked with a lot of really high quality protocols that you know have good a combination of good inline code descriptions as well as good sort of supporting documentation um oftentimes in the form of you know white papers is a start but that's really kind of a bit um high level
um stuff that's sort of like more more technical in nature like coding diagrams is also very useful so hopefully that helps yeah it does thank you I think that's enough questions for now so back over here we'll have um thank you so I think this is going to be the second last section we touched on and this is really sort of um some Preparatory measures to take um what your project is uproad at um so some of the questions that came up like the most recent one are going to be um I guess sort of reiterated here but um
at a high level um you know what can you do to ensure you get the best security outcomes um and also sort of also like cut down on costs for the audit um and just sort of like create the best experience for everyone involved so um at a high level there are some key steps so following good design principles um looking for service level bugs on your own time um that's sort of running automated tooling and doing top-down approaches um using Pierre code reviews putting in time and effort into documentation testing is also huge we have found many bugs uh just by adding uh simple test cases so that's something that really
helps a lot and also you know as an audit shop we like to use um periodic questionnaires to sort of start building that relationship with the client start getting that discussion and that dialogue going and also kick off calls as well so really the most important preparation for a smooth and successful audit is going to happen long before the audit begins so it really comes down to following good design principles these include reviewing existing protocols that share similar features and mechanics of your protocol pulling the core ideas and taking the time to find harmonious ways to combine
them prioritizing modularity is extremely key it really helps sort of like separate the different components of the audit and really someone who did development for a long time um I think this is probably one of the most beautiful aspects of coding um it's really sort of finding ways to separate your ideas and your Concepts um writing them down into different you know salinity files or contracts um and I just find like funny like in a basically like an efficient way to sort of um mentally represent an extremely complicated process it really really seems to require leveraging modularity um and that of course circles back into doing an effect about it
um so inheritance is also good it's definitely a useful concept but it's important to use inheritance uh really only in the right amounts um one of the things that can be a challenge for audits is you know coming across extremely deep inheritance hierarchies or structures and then having let's say um combining that with complicated branches um so you're looking through a given contract control can get past to different internal functions and those can like lie at different places in The Inheritance tree and I can create um sort of like indicated in the lower left there
um some some complexities to deal with in terms of tracking the control flow so um taking limits to to limit that that Branch branches in control flow and you know cyclomatic complexity um is extremely important so I guess why this is important I kind of touched on that um you know when we go through the audit we're looking at the whole structure um so we're going to really do our best effort to search through all of those branches and all that coverage um and if it's extremely complicated sort of and this might be something that comes up as a question is is from a pricing standpoint so um when we're looking at an audit to do pricing um complexity is a huge Factor because
when you start to think about all these broad branches they basically open up sets of possibilities or extremely sort of like complex possibility trees that our Auditors are getting and we're going to need to work through um and that's just going to contribute to the amount of computations and calculations that they need to do um and so that's going to eat up engineer time and add to the to the length of the engagement but I think sort of quarter of this is you know taking the time to design a protocol well is going to avoid situations where bugs are found that are essentially impossible to fix without completely reworking the design and this ties into a question
um earlier about you know what happens if you're going to suggest a fix that's going to introduce another problem so when we see you know serious oversights in the design of protocol that's where we really run into situations where it's like oh you might see one fix um that's going to sort of work in isolation but because the protocol has sort of fundamental design issues um it's sort of impossible to make that fix within like the scope of a single function and that's where you start to get into um recommendations for fixes that require broader architectural changes um and that sort of Getty shifting more from almost like serving as a security auditor to sort of serving more as like
um like a development advisor so those are definitely situations um that everybody should try to avoid so I guess one of the big complications there is if the fixes are too complicated to fix within sort of like a reasonable amount of time um then one of the challenges there is that you know projects can have to come up for audit which um is going to of course extend their timeline for launch or um and create sort of other challenges for them so I guess it's super important also to get you know the really easy stuff out of the way um so like I said you know we highly encourage uh projects and we see this a
lot actually we work with some really great customers as they run a lot of the automated tools on their own um this is gonna really sort of like tie into what they should be doing which is getting the easy stuff out of the way um and that's just going to allow us more time to focus on the harder stuff um and of course we can sort of take that into consideration when scoping out the the length of the engagement given that it can take some some of the illness off of our plate um sort of getting back into the culture stuff I mentioned about the culture on the auditing side there's also really important considerations to make about the culture on the engineering side so Auditors should be I mean certain Engineers should work in pairs uh we encourage them to be asking questions about the security Integrity of other
people's works um and really sort of like adopting the mindset of you know protecting the protocol over your ego I think one of the challenges that can come up in sort of any sort of like highly intellectual space is uh sort of getting attached to um building things that sort of I don't want to say make you look smart but you really sort of like show the complexity of your thought process um and we find that sort of like across the board in our experience really focusing on keeping things super simple as possible is going to result in sort of functions uh protocols rather that are sort of easy to extend and build upon in the future but of course easy to audit as well
so I'm just touching back on the points on documentation like I mentioned we found a ton of cool bugs just by taking the time to reconcile what's in a design spec with an implementation like what's in the actual code base and also coming across scenarios where people on the business side are expecting the protocol to do one thing um and in fact it's going to do another so you know that has obviously serious implications for um you know let's say they're expecting to change a certain parameter and expecting it to change the behavior of a protocol in a certain way and it's not in fact going to do that or they're expecting user interactions to go one way and they impact to another um well it might not necessarily result
in a loss of funds or let's say a denial of service or something um it's certainly a horrible surprise in there and so we try our best to to avoid that situation um but I think sort of beyond that having documentation really just gives Auditors another representation of what a code base does and this just helps us better understand um the implementation so we're really trying to trying to get as many viewpoints and perspectives and discussion points on the code base that we're looking at as possible and that's just going to help us get up to speed as fast as we can so um yeah like I said some of the docs that we like to get white papers white papers code diagrams readme files I mean we always read readme files they are
great great things to include um any sort of like let's say requests for for changes um that have occurred sort of within the development process can also be very useful as well sometimes being able to sort of dig back and see the lineage of the protocol on the development side um can help us sort of understand it and point to interesting things so foreign get into test cases yeah so like I said many times a single test case reach uh function um sometimes we see protocols being referenced as having complete coverage but we only see one test for each function uh we like to see sort of at least three categories of
test cases uh and often numerous tests within each category so these include positive cases like does the function actually work when it's supposed to negative cases these should sort of address cases where the function should fail and also test cases covering a range of parameter values and contract States so an important thing here is to just sort of think back to the stuff on Branch coverage um having so you can imagine if you have a high order function calling various internal functions depending on the parameters that are passed into it or the state of the contract um ideally you're going to want to see test cases that sort of cover all those possibilities of course sometimes there's some sort there's some
modularity to this so you can also sort of make considerations about you know modularity and functional functions as you can with sort of like the modularity of the test cases corresponding with those functions so um yeah I'm trying to take that into consideration as well so I think sort of like the last slide here is going to be about um prepping for the audit so just some some sort of basic questions that we like to have a lot of this stuff is sometimes available um in documentation um but in cases where we don't get good documentation it's especially useful at the at the start of every engagement to get good summaries of the protocol so we
want to know its purpose it's inspiration and Innovation so let's say which protocols it's drawing from which ideas it's drawn from and how it's innovating or modifying those ideas especially sort of the key functionalities here we also want to know um what are the projects bugs of major concern where is the key business logic within the protocol like where should our attention and focus be and which contracts and how are those contracts interacting um also you know specifically like super important is to know which functions control the funds and service availability um but I think one of the things we really like to do here is sort of just get an idea of you know what's going to keep the users developers and investors up at night but we want to make sure
that that's stuff that we investigate and also oftentimes it's really appreciated when we include that in the report so everybody kind of knows that their concerns have been addressed during the process so in terms of uh post audit outcomes okay this is going to be the final section of the talk so maybe before I get into it maybe just one last chance to get questions in on that last section and then we'll move on uh rude you've got a question over to you yeah I had a question about uh the architecture of uh of the contracts how often does the uh like for example how often have you audited a system and
looked at the overall architecture of how the protocol is implemented and found that to be a key uh source of vulnerability as a whole and what are the you know are there any best practices around uh good architecture um in order to you know ensure that one the the contracts themselves are easy to test um and uh clear in terms of how they work and function yeah so I think to maybe to decompose that a little bit um we're always looking at architectural Integrity across all the protocols that
we audit in terms of sort of like the frequency of scene protocols that have architectural challenges um we work with really high quality clients so um it's not that common in terms of best practices I think the the the points that I mentioned earlier around modularity um limiting inheritance um but also sort of just I think I think the best approach is is in in most cases you know um Innovation typically takes the form of an increment on something that already exists um and in most cases you can sort of find an example of something out there that has already been audited has
already sort of been battle tested and um you sort of like want to kind of Leverage um that past experience of that protocol and find a way to sort of um I guess sort of elegantly include your modifications or extensions to it um yeah let me know if that helps yeah yeah that makes a lot of sense thank you and I think that's the only question we have around the pre-order so let's move to the next section okay great so yeah post audit outcomes there are activities and then there are outcomes so on the activity side you have a
suspicious transaction monitoring you have Auto drift and you have bug Bounty programs on the outcome side you have successful protocols and you have um protocols which unfortunately can can be exploited so on the suspicious transaction monitoring side um I'm sure everyone's heard this a million times you know once a contract is deployed it's out in the wild so it's therefore really important to uh consider monitoring position for suspicious behavior um you know like the most sort of like easiest to understand example is like monitoring for uh large movements of funds um another key consideration here are contract upgrades
um and auditrift basically so audit just happens when a code is on chain um it's modified through an upgrade um and therefore does not match the code that was audited so that's an indication of a change in the behavior of the code um it could potentially introduce a bug and or it could also be an indication of uh malicious behavior on the side of the protocol managers so I think there was a question there earlier about um centralization risk um so how do you define centralization risk um maybe I'll sort of leave that to the end but this would sort of be an example
of um you know one centralization risk that kind of that could occur and it wouldn't necessarily constitute like a high or a critical vulnerability because you see it all the time um you know protocol managers need to be able to make changes to the state of the contract they need to be able to upgrade it they need to be able to make let's say parameter changes and some protocol designs uh call for more frequent interaction um so sort of like from the reporting standpoint uh we feel our duty is really to sort of like communicate what the implications of those sort of more um manager controlled functions can be to the dev team itself so that everyone there is aware of it um they can sort of therefore ensure
that those functions are properly safeguarded through uh multisigs or different measures um but also for people on the user side to know as well um just important for them to have a good understanding of the trust that they're putting into the the dev team uh when it comes to managing that contract so um another thing that that program should look out for and something we definitely like to dig into from the centralization risk standpoint is um you know understanding critical protocol parameters that can be changed by protocol managers um let's say protocol management have the ability to modify collateralization thresholds
um and a lot of lending Pro protocols if you were to able to change those thresholds on the Fly um that could result in the potential for Mass liquidation across the The Lending protocol um so that's definitely stuff that users should be aware of so okay so get into bad audit outcomes um definitely sometimes protocols get hacked and sometimes the funds are gone and you're out of luck um so you know I think one of the biggest examples out there was the Ronin hack and that was related to to private Keys If I recall collect correctly um but other times you can get lucky and reverse hacking as possible so this is sort of touching back on the
um reference to Wormhole earlier um so they lost about a little over 300 million and I think I'm not sure on the proportion of these funds that were deposited in no no waste multi-sig but it was definitely a considerable amount and um some white hack hackers were able to collaborate and they basically reverse exploited a previously unknown weakness in the design of the admin process around this multi-sig and we're able to retrieve some of the funds so pretty sort of cool and exciting aspect of the whole sort of hacking dynamic in web3 there um but we are seeing sort of like more frequently like in the case of Euler
where um you know Protocols are recognizing that it's important to be able to negotiate with hackers and provide them bug bounties but I think sort of like a key a key element of smart contract security and web3 are having good bug Bounty programs um these really help in avoiding those high profile exploits and those cases where you're negotiating with hackers on chain um avoiding negotiating with hackers on chain obviously avoids Market Panic with users and protocol owners it just removes that fear moment when fun suddenly disappear it also incentivizes white hack hackers um sorry sorry
so but a critical component of this is to like it properly incentivize white eye hackers to not go the route of um you know doing a hack whether they're going like full black hat and they're not going to turn any of the funds or they're wanting to sort of take a power position and sort of negotiate with the protocol um it's super important for bug Bounty programs to be streamlined and fair so you know you can just imagine yourself you're a hacker you are in a position where you could um take 10 million dollars and instead somebody's offering you 10K um it's definitely I could definitely see how some hackers might not feel that they're getting properly compensated for the value they would be added to the protocol if they
were to report that 10 million vulnerability through a bug Bounty program um also there's been sort of like known challenges with doing bug bounties um cases where someone has reported a bug and the team says it's not a real bug or that they were just about to patch it so um these are the type of things that could cause you know really talented people in the space to go Rogue and that's really the last thing we want to see so having grantee programs uh they definitely play a key role in keeping the best uh hiking Talent on the right side of things and add to the overall safety of the industry so yeah um this is going to be the last slide just want to thank everyone for listening to my talk
um I hope it gave some insight into um audit Services you might be getting now or in the future and um yeah thanks for your time guys okay so thank you um so I know we've had a few um questions um so one of the questions was around if you were you know new to auditing or interested in becoming an auditor how would you what process do you think people should follow to try and you know become some auditor person yeah I know there's a really easy answer for that so Stephen [Music] um as I mentioned our CEO and co-founder
wrote an article called the auditor grind set um that article is available to read on our website and that pretty much outlines the steps that we think um anybody could follow if they want to get into the security space so I can post that in a chat in a second uh but sort of really at a high level having [Music] um having like a good background in software development is super key um and sort of being able to to transition that into um smart contract language is sort of sort of obvious so um getting familiar with sort of the
solidity manual um being a good solidity Dev building simple things insolidity um doing sort of like a bunch of hacking challenges like we have a damn vulnerable Defy is a great one out there really touches on some cool economic exploits but I think sort of like um I think there's sort of like two key things which are super important to being a good auditor one of them is being it's it's it's a bit of like a mindset difference from being a builder like when you're a builder and you're a developer you really want to focus on building something new and you have to focus on delivering that thing so if you're the type of person who thinks
about all the possible ways that that can go wrong um as a builder you might sort of be stifled and suffer from parallels like what is it called paralysis from analysis um but those types of people actually make really good Auditors so um so people who are sort of how that desire to think about all the possible ways that can go wrong but are also people who are really aware of their blind spots and weaknesses so like one of the things that can happen especially when you're when you're learning to audit um the thing you want to sort of like develop is it's kind of like your spidey sense but really it's just like an awareness of what you have not spent sufficient time thinking through
something so we're sort of learning through the process You're Gonna Go you might have like a like um like a hacking challenge maybe you don't solve it and maybe you sort of like final the answer maybe you look at the answer and sort of like gives you some insight into like okay what did I miss there like you know did some level did at some level I have an intuition that this is the thing that was wrong and then it's like if you're going to be an auditor like typically you will have had that intuition and you'll be okay I kind of knew that at some level that's the thing I was missing then you're gonna go to the next hack and then it's like you want to make sure that when you have that intuition um you just dig into it and so it's sort
of like really sort of like building up on processed and being as exhaustive as you can so um yeah hopefully that helps a little complicated answer that's okay um so there's another question in chat but I've got a question of my own that I thought of before Frank had his question there so I'm going to ask my question next and that is all right so I've got V say three of a protocol and say um zelikov uh reviewed V3 yeah to produce say V 3.1 or V4 of the protocol what are the advantages and disadvantages of having say a different company reviewer versus zelec review it
for you know that upgrade okay so so I'm just going to repeat the question to make sure I understand it so zelected to be three uh V3 audit total audit of the complete code base and then the question is somebody's going to be doing an upgrade to let's say a V4 and should they be going with us for that audit or somebody else yeah yeah is it yeah what what are the advantages or you know like because I mean naively I think you know a different set of eyes maybe they'll find different things but then there's familiarity with the code base so maybe that makes the audit cheaper but are there other things beyond the naive View
um yeah I'm trying to think like that's sort of like those are sort of like the main driving factors there um like in most cases we see where protocols have had unaudited do a V2 and they're looking to get a V3 if they had a really good experience with that auditor and they're convinced that that auditor has a good understanding of their code base and they like working with them um typically we'll see them go with the V3 um just because you're able to sort of Leverage that past experience with it you have good communication with them the devs and the Auditors have typically already build rapport so there's a lot
of sort of like other synergies there that are going to contribute to a successful view of the V3 and then of course you have those you know sort of like reduce time and the extent of the engagement because you already have that built-in familiarity um so typically on our side we see people come back with us um but that being said you know it's super important within the process of auditing to have multiple pairs of eyes different audit shops look at your code base um so yeah I don't think there's any sort of black and white black or white but yeah yeah thank you for that and um so before
I go and talk about the merch store Frank's got one other question here which is what is a good auditor you know is there a way to measure how good an auditor someone or some company is yeah that's a really good question um I guess they're sort of like yeah so like the simplest way of looking at this is like the Practical standpoint and like I think oftentimes in life when you're dealing with practicalities like you're dealing with relative performance um because you're making a decision between the options you have available to you not the options that exist in an Ideal World
so um a great way to look at it or a great way to measure the quality of an auditor is you know are they able to find bugs that other Auditors have missed and are those bugs critical to the functioning and security and safety of the protocol um that's sort of like um a pretty strong metric I think another metric would be has this auditor or these auditing firms are they consistently hacked and are they consistently miss things that's definitely not going to um that's not going to bode well because they're just not going to have a good track record and that's going to point to sort of flaws in the in the process
so that's sort of like more about um measuring and auditor based on outcomes of course with outcomes in anything especially with auditing processes there are other factors that need to be considered like you know what was the quality of the protocol going in um and sort of what measures in place that they have in process to make sure that they weren't working with something that was sort of like you know absolutely doomed for failure and did they did they give the Auditors on their team appropriate time to do the audit so there's like even on the outcome side where somebody might get hacked you could also have considerations where you know really skilled Auditors were put in a time
crunch we've definitely seen cases where you know there's plenty of super talented people out there um that I've had bad outcomes and there are other factors that need to consider them going into that so um I think really what makes a good auditor is sort of stuff that I touched upon by having um on the processes standpoint which is being holistic looking at things sort of like from the ground up from that beginner's mindset not taking things for Advantage um but at the same time you know being well educated and well versed in the types of known hacks that are out there um so that they can identify those but then of course also buy themselves more time during the audit engagement to
focus on sort of more novel uh zero day type things if you will yeah and would you ever reject you know like the would you you ever have a company come to you saying hey we'd like an audit you look at the company and you say this is too much of a train wreck of a protocol the probability of this eventually being hacked is just too high it's too big a risk no we're not going to audit you do do you ever do that sort of thing I think those cases may happen sort of implicitly for example if we were to get a code base that looked extremely shoddy and
we were to sort of come up with the amount of time it would take us to do that audit in a reliable way it could just be that the amount of time that we would need to feel comfortable auditing that protocol would just you know be out of line with whatever that client was expecting from a price standpoint yeah okay I could say Frank you've got one La one question I think we'll have your question as the last one for the talk okay yeah I just went through a pranks profile and so that uh I haven't seen it before Keen to give it a try not a question it's a statement sorry I didn't hear that
uh the evm Daphne project I saw that in your profile this is something that you can use for formal verifications on Smart contracts I'm a formal verification and former methods person if it's not if if it was not obvious that's how it works so but my question is not about formal verification is actually about the audits so there was a question Peter you said or someone asked um would you reject the node it's saying that it's too risky and so on I think the problem and correct me if I'm wrong is that the result of a note in the in the result of the audit or the report you don't provide any guarantees the report is a list of bugs that you
found but you're unable to provide any guarantees that there's no for instance division by zero in the code or anything like that right so this is a question about if we started an engagement with the protocol the question is what guarantees do you provide so a concrete one is all right I give you a code base to uh to analyze yeah I will ask you at the end of the day I would like to know whether there's a possible division by zero in the code can you provide some guarantees and sign off on it
that there's no division by zero in the code no possibility of a division by zero in the code so I think this touches on something I mentioned in the slide which was sort of like the benefits that form of verification offers over the other audit approaches so if you were to identify a specific component of the code base and then perform sort of set up an invariant and then perform form of verification on that then you would be able to make claims like that my question is right we are not talking about formal verification because you're doing manual verification so my question we also do formal verification so that can be an example of making a
strong statement like that so what kind of uh so so then my question is can you provide formal or can you provide guarantees in your report when you analyze the code is there a line saying we guarantee that there's no division by zero in the code I think typically we do not make guarantees yeah okay so you find some bugs and it's a non-deterministic process because it depends on the Auditors so depending on the different editors they can find or not find bugs they could even find bugs that they would discuss together and think one is a bug and the other one would say no it's not a bug so that seems to me um
a good approach where you can start auditing but for instance the statement and the assertion saying that manual auditing is is more reliable than formal verification I think it's uh I should probably I would disagree with it and say don't yeah I mean you may have misheard you may have misheard what I said there so I said that the way manual [Music] code review works is different than the way formal verification works because a lot of the things that you can check and explore in the context of manual code review um you can't explore in the context of formal verification because you can't formally verify the complete business
logic of a code base you can't formally verify well I disagree with that of course you can okay well now we're going to have a discussion between practicalities and theory about practicalities I think it's a well we've we're over time but I think that's a wrong statement and it should be corrected you can provide formal guarantees about the business logic using formal verification there's some simple requirements like must be usable right for example and you can test that in a lab you can either you know you can test the time it takes for users on average to find quicker shopping cart button or whatever
right so you can do a usability review and you can get a definitive outcome statistical but you can't do a formal verification of is this website usable okay but I agree they complement each other that's a big misunderstanding I think it's not what formal verification is about so maybe that's a for another so I'm saying it's different things right they complement each other because it might be fun to have no divide by zeros but might not meet a business that you would like to verify so I think it's uh and there are lots of projects using formal verification the move link well I think they said they do do it it's just not you're not an expert right in in this presenter is not an expert on that but
there are other people and also I think I think one sort of sort of really way to think about this from a practical standpoint is let's say you want to formally verify everything in the protocol well in order to formally verify everything in a protocol you need to basically do a complete manual code review in order to figure out actually I'm sorry can I finish okay but I'm just going to finish my point and then you can make yours you would need to basically review the entire behavior of the protocol to consider across all the possible ways it can go wrong and then in addition to that you need to set up all the invariants in order to test that so one of the things I mentioned earlier in my
slide is um sort of like you know how long is that going to take for the engagement and what's going to be the cost of that engagement so that's sort of looking at it giving a lot of favor to what's possible in the formal verification space that being said I feel when it comes to sort of more complicated business logic um that there are limitations there and and that's something that um sort of I've learned from talking with some of the leaders in the formal verification space so uh but I'll leave it at leave it at that yeah look and I I think it's yeah it's all about the definition as much as anything else of what's practical um
yeah and what people are prepared to pay for maybe that's uh that's it well look um so thank you Oliver that was a great talk and um I think we maxed out at 34 people online which is um a obviously very well attended talk so people have asked many questions as well so that's also a very good sign so thank you very much for your time and effort of putting that talk together and um yeah thank you wonderful yeah thanks so much for having me I appreciate the great questions guys have a great week yeah all right thank you everyone um talk to everyone later bye-bye
Related talks
- MakerDAO Smart Contract Safety: When Billions are at Stake
- Training for Constraining: How to Prevent Circuit-Level Bugs
- Off-Chain But Not Off Radar - DeFi Security Summit 2025
- Designing DeFi Resilience: Inside Aave V4’s Security Blueprint
- Building a Mental Model of a Smart Contract | Uri Kirstein - Certora
- Demystifying Smart Contract Security: Facts & Fallacies
- DeFi Security 101 2023: Full Day, 14 July
- A Playbook of Secure Smart Contract Development by Palina Tolmach | Devcon SEA
- Demystifying Smart Contract Security: Facts & Fallacies
