DSS 2026 — Symbolic Execution of Math-Heavy Code in the Age of AI Neville Grech Source video: https://www.youtube.com/watch?v=nZUPjFmtXxo Automatic captions — not human-reviewed. Complete spoken-audio coverage is unverified. Source language tag: en (English). Source export SHA256: 6bd7c14b04a83b68b010cb5397c5d8860cf6297cc696109b40c1304915e63cd8 [0:01] All right, thank you for the intro. I'm [0:04] Neville from DDUB. Just a little bit [0:06] about our organization. So, we're a [0:08] security company. We do audits. We're [0:11] very well known in the static analysis [0:13] and decompilation space. Uh we've built [0:15] a lot of products that use some of these [0:17] techniques. And as you'll see today, [0:19] we're also into symbolic execution, [0:21] which is a technique that underpins a [0:24] lot of the formal verification tools [0:26] that uh we use as a community. [0:30] All right. So, [0:33] okay. So, what is symbolic execution? [0:38] All right. So, I'm going to use this [0:40] example as a running example. So, it's a [0:42] basically a transfer function. I made [0:45] this up. So, you will not see code as [0:47] bad in the wild as this. But effectively [0:50] in symbolic execution, you don't execute [0:52] the code using real inputs. Instead, you [0:56] execute the code using symbols. And [0:58] these symbols can represent all the [1:00] possible values uh of every variable [1:03] input that you have. Okay. So because of [1:07] this you end up um when you reach a [1:10] branch you end up forking meaning that [1:14] um you have a branch like an if [1:18] statement you got to execute the program [1:20] under both one side and the other side [1:22] concurrently. [1:24] All right. So, uh, what this means is [1:26] that he will go down a lot of different [1:28] paths. Um, and I'm going to do a dry run [1:32] of a few of these paths. [1:40] Okay. So, we start the program. All [1:43] right. So, we reach a condition. Reach a [1:46] condition. An if statement. This if [1:49] statement here checks, you know, that [1:50] the amount in this transfer is not over [1:53] a certain amount. Okay, at this point we [1:56] fork. So let's fork and go down one uh [1:59] branch. Okay, under this branch we're [2:02] going to assume that the condition is [2:05] false, meaning that the amount is less [2:08] than a th00and. Okay, [2:15] if we assume that we add that amount to [2:18] the so-called path condition. The path [2:20] condition is a set of conditions under [2:23] which the current under the current [2:25] execution that you must assume to be [2:27] true. Then you reach another condition. [2:38] Okay, we reach another condition. This [2:40] is a condition about the uh the current [2:43] fee. In this case, we add also another [2:46] path condition. Then at the end, we need [2:49] to send these path conditions over to an [2:50] SMT solver. And the SMT solver will [2:53] check whether these conditions are [2:56] consistent with each other and it will [2:57] give us either a satisfiable assignment [2:59] SAT or unsatisfiable. Okay, a lot of [3:03] people use Z3 which is an external [3:05] solver but you can also write your own [3:08] solver. It's just difficult. [3:11] So in this case turns out that this is [3:13] ansat. Okay. So we terminate the [3:16] execution here. We need to repeat the [3:19] same process to all possible paths. In [3:21] this case the program only contains [3:23] three valid paths. But as you can [3:26] imagine, real programs are going to have [3:28] a lot more paths because if you have [3:31] let's say 45 branches [3:34] and each branch has a branching factor [3:36] of like 1.5 meaning that you know one [3:39] side succeeds the other side has a 50% [3:42] of continuing you will have 84 million [3:46] paths. Okay, which is which is a lot of [3:49] paths and you know a single query with [3:52] an SMT solver it can take minutes [3:55] potentially [3:57] and actually analyzing D5 protocols is [4:00] harder. Why is it harder? [4:08] It's harder because you find a lot of [4:10] code in math libraries which uh which [4:14] combines different kinds of algebbras [4:17] meaning that it uses both for instance [4:19] addition, multiplication and subtraction [4:22] which you need certain techniques to [4:24] reason about and also it uses you know [4:27] shifts uh and or or bitwise operations [4:31] which require different techniques. And [4:34] so if you go down and use one kind of [4:37] techniques, you need to convert one kind [4:40] of math into another kind and that's [4:43] creates a lot of complexity. This is an [4:46] example from unis swap v3. In this case [4:49] it does 512 bit multiplication [4:53] followed by division. [4:55] All right. And then on top of that you [4:59] also get complexity. [5:01] Let me show you an example. [5:08] So you get additional complexity. This [5:10] is another example. This is also from [5:12] unis swap. But in this case, it's a [5:14] function that helps you compute the [5:16] price of an asset based on the liquidity [5:18] in a in a particular tick. In this case, [5:21] you get like 20 possible if statements. [5:24] And you know, all branches are mostly [5:26] feasible. And so you get once you enter [5:29] this function, you multiply the number [5:31] of pads by around 1 million 2 to the 20. [5:35] Okay. And the correctness of these D5 [5:37] protocols really relies on code like [5:40] this. A lot of tools will not support [5:43] code like this. A lot of provers will [5:45] will choke. So what do we do? [5:48] So we've devised a series of techniques. [5:52] Okay, some of these techniques are [5:53] original, some of them are appropriated. [5:56] Okay. So the first thing we do, okay, uh [6:00] we are known in the decompiler space. [6:02] We've written a lot of techniques to try [6:04] to lift code at a level of [6:06] representation higher than the bite [6:09] code. Okay, that's in the DOB [6:11] decompiler. We've used some of those [6:13] same techniques to lift low-level code [6:17] also to a higher level presentation. The [6:20] screenshot uh shows a simple program [6:23] which has been compiled and it doesn't [6:25] do anything special. It just copies a [6:27] strct around call data storage and that [6:31] sort of thing and does some arithmetic. [6:34] So for instance the uh code in green is [6:38] you know like check arithmetic. [6:40] It really translates to like three or [6:43] four mathematical operation. So this is [6:46] the sort of thing we do. There's a lot [6:48] of techniques which go into uh doing [6:50] this convert lifting to a higher level [6:53] representation. Second thing we do is we [6:57] undo the optimizations. [6:59] Now this is easier said than done and [7:02] also you might question why would you [7:03] want to undo the optimizations? I mean [7:06] they're there for a reason. Well, the [7:08] problem with optimizations is that the [7:11] uh library auditor authors, they have [7:14] exploited the fact that they're using a [7:16] a machine, you know, with with bits and [7:19] that sort of thing. And by exploiting [7:21] this, they can get better performance [7:23] and in some cases they can get also [7:25] better um better accuracy, you know, can [7:29] they can utilize uh the bits better. [7:34] Um but unfortunately these also [7:36] introduced these mixed algebra um [7:39] expressions. [7:41] So we do one of two things when we see [7:44] an expression which is problematic. We [7:46] have devised algorithms to either [7:48] convert these to idealized mathematical [7:51] representations such as in the first [7:53] example that's the min function. Second [7:56] function is the average function. It's [7:59] simpler to reason about than the one on [8:02] the left hand side. Or another technique [8:05] is to convert for instance a bits [8:08] operation into an operation that [8:11] operates on data structures. So the [8:14] operation on the right hand side is a [8:16] slice of bits and you want to be careful [8:19] you know the algorithms need to be [8:20] careful to distinguish between the two. [8:23] Okay, by the way, a lot of optimizations [8:26] you can read about them in this book, [8:28] but this was written for C. It's a good [8:30] book. [8:35] All right. So, another technique, it's [8:37] to write your own SMT solver. Now, this [8:41] is uh not as simple as I'm saying. Um, [8:45] so you don't need to write your own SMT [8:47] solver. Zedri does a very good job, but [8:49] it is designed to give you either a [8:51] satisfiable assignment or unsatisfiable. [8:54] And to get a satisfiable assignment that [8:58] um it requires more computation than you [9:01] might need. Instead, during symbolic [9:04] execution, often times you're more [9:06] interested to know whether a uh path [9:09] condition is completely unsatisfiable or [9:13] whether it could possibly be unsat [9:15] possibly be satisfiable. And so writing [9:18] a solver like that is simpler and also [9:22] the algorithms that you can pick and [9:24] choose into the solver. You can make the [9:27] solver be linear time and you can [9:29] utilize techniques from computer aided [9:33] algebra systems which are faster and I [9:36] don't know some of the these techniques [9:37] are also used in Z3 but you know linear [9:40] time versus double exponential but [9:44] there's a caveat at the end of the day [9:46] you still need to use Z3 in some cases. [9:50] All right. [9:54] Another technique this is actually [9:57] appropriated. A lot of uh symbolic [9:59] execution engines they do summaries. [10:02] Okay. We also do summaries in our [10:04] symbolic execution engine. So summaries [10:07] you are actually encoding instead of [10:09] like um forcing the engine to execute a [10:13] lot of difficult and complex code you [10:16] either reimplement it in a simpler way [10:18] using idealized mathematical operations [10:21] or you just put in there you know the [10:24] additional path conditions that you [10:26] would need to add. Okay. So the way we [10:30] uh wrote our summaries is we went [10:33] through a lot of defi and math libraries [10:35] and we asked AI to write summaries okay [10:39] and our symbolic execution engines have [10:41] has a lot of summaries in it now that [10:44] matches to specific libraries and [10:47] obviously we don't trust the AI so we uh [10:51] we use fuzzing to you know ver validate [10:55] these summaries against the actual code [10:57] now you might be thinking why use [10:59] fuzzing when you can use symbolic [11:01] execution. Well, for small functions, [11:04] small pure functions um that don't do [11:08] much. Okay, so these are mathematical [11:10] functions, fuzzers can actually do a [11:12] good job at disproving you and so it's [11:15] easier. [11:18] And finally, if you accept the fact that [11:21] your symbolic execution engine is going [11:24] to be more scalable, but as a as a [11:26] result, you might get a few more false [11:29] positives. [11:30] Well, you can have an a agent in the [11:33] loop that verifies, you know, whether [11:35] whether a finding is true positive or [11:37] false positive. You want to be using [11:40] frontier models, but frontier models are [11:42] very expensive. But how can you get the [11:44] cost down of to these frontier models? A [11:47] lot of tools when they give you a [11:49] finding they produce just gibberish or I [11:52] mean an expert can interpret it but it's [11:54] like really long okay and really long [11:57] traces through bite code and through [12:00] memory operations and that sort of thing [12:02] and it's a waste of tokens to go through [12:04] that. So a lot of you can you should [12:07] dedicate a lot of engineering to try to [12:10] decipher that and get a more highlevel [12:13] output from your tool so that the AI [12:15] agent does not need to spend a lot of [12:18] tokens on this and it's going to perform [12:20] better and then you can use a better [12:24] frontier model. [12:26] This is actual input output from from [12:28] our tool. Okay. So everything maps back [12:31] to source code operations. Okay. It's [12:34] it's in a familiar format. That's also [12:36] another thing that you know they uh tell [12:39] you you know how to integrate with AI [12:41] models. Well, you make the output [12:44] familiar to them as well. [12:50] Okay, let's look at some results. [12:54] So, we've implemented this tool. [12:59] It's symbolic execution engine and we [13:01] compared it against HEVM and Halmos. [13:05] Okay. So we picked 100 random smart [13:08] contracts, smart contracts that have [13:10] been used on chain recently and uh we're [13:13] running these tools offline meaning that [13:15] you know storage is symbolic and and [13:18] that sort of thing. [13:20] Now it turns out that a lot of tools [13:22] they are not geared towards exploration [13:25] meaning that they are geared towards you [13:27] know like um checking a single property [13:31] not at checking all the executions of of [13:33] code bases. And so in the case of Halmos [13:36] we wrote a custom harness and we needed [13:38] to fiddle a lot with the settings to to [13:41] make it run uh this experiment. All [13:44] tools use Z3 120 second timeout which is [13:48] like really low. Um and all the [13:51] exploration parameters you know it takes [13:53] a long time to configure these tools to [13:55] make sure that they're level playing [13:58] field that they're all exploring the [13:59] same number of paths and whatnot. Okay. [14:03] So in the case of our tool we managed to [14:06] analyze 80% of the smart contracts all [14:10] possible parts. Okay. [14:12] um except loops [14:15] in the case of HVM 31% and halmos only [14:19] 26%. Okay, a lot of these tools have [14:22] partial results they actually most of [14:25] the time what they do is they choke for [14:27] instance when parsing call data or you [14:30] know moving things to memory that sort [14:32] of thing. So because of the loops. [14:37] Okay. So uh we've uh deployed this tool [14:40] internally. We're using it for uh [14:43] auditing at DOB. Uh we also use it for [14:46] bug hunting. And so it's designed as [14:48] such. It's it's it's currently not [14:50] designed to uh to be a replacement of a [14:54] formal prover, but it could possibly [14:56] become one in the future. And right now [14:59] we're also doing explorations you know [15:01] trying to see whether um you know [15:03] certain EIPs will break contracts in the [15:06] future once they are deployed and and [15:09] that sort of stuff [15:11] allchain analysis kind of like what we [15:14] were doing with static analysis. [15:16] Any questions? [15:24] >> Okay. Yep. [15:28] just light on how you kind of cutting [15:30] the cost down of using agent workflows [15:33] in symbolic execution. [15:35] >> Yeah. [15:35] >> Hi, I'm Manu from lip P2P. Amazing talk. [15:38] Just wish to ask how you are kind of [15:41] optimizing the cost of symbolic [15:44] execution when you're building a swarm [15:45] of agents and you're kind of using some [15:48] of the things to verify and also have [15:49] some of the agents to kind of do uh the [15:52] uh like the final job over here. Yeah. [15:55] Thanks. [15:55] >> Yeah. All right. So, first of all, you [15:58] got to optimize the um you know the [16:01] interface of the tool, make it [16:02] appropriate for command line um [16:05] environment and that sort of thing. The [16:07] output as I showed on one of the [16:10] previous slides is very very dense and [16:13] maps directly to the to the source [16:16] level. It's like compared to some other [16:19] tools out there. You know, other tools [16:21] will generate pages and pages and pages [16:23] of output. this one will generate you [16:26] know the very succinct things. So this [16:30] this is basically heavy compiler [16:32] engineering right it's compiler [16:34] engineering trying to map you know back [16:36] to source you know get get all the [16:38] debugging information through the [16:40] compilation process it's that sort of [16:42] work [17:02] So my my question is what would you say [17:06] is the greatest one of the major [17:09] challenges in terms of adopting symbolic [17:12] execution in the generic auditing [17:15] ecosystem. Your form of verification you [17:17] got fuzzing. you have so many different [17:19] things is what what's the biggest [17:21] challenge you would say? Well, the [17:24] biggest challenge I thought, you know, [17:26] when embarking on this project is that [17:28] most tools don't work well enough to [17:30] merit, you know, spending enough time um [17:34] getting them up and running because most [17:36] of the tools, you know, I I kind of like [17:38] alluded to this. They're not designed to [17:40] explore an entire contract. They're [17:42] designed to look at a single function at [17:44] a single property, you know, like a [17:46] property on a single variable or [17:48] something like that. So, that's very [17:49] very time consuming. [17:52] um you know tools get better and better [17:55] and then instead of using the tool you [17:58] ask your AI agent to use the tool that's [18:01] going to be free for you right you ask [18:03] load hey use this tool on this and if it [18:06] works you're going to get good results. [18:15] So basically when you reduce the the [18:19] type to the integer that will be like [18:21] more um more CV friendly type that could [18:24] be quick make the solving time quicker [18:26] basically like when you convert all [18:28] these like type to be more solving [18:30] friendly um for the SMT solver then [18:33] what's the basically downside cost like [18:35] when you face all this like BIP type and [18:38] um potentially that could be like [18:39] forcing the bit factor in the SMT lib [18:42] language instead of forcing it to be [18:44] integer that definitely faster but like [18:46] what's the downside cost of all this [18:48] address type all this dynamic factor [18:50] type or dynamic array in the solidity [18:53] because that must be some downside costs [18:55] there yeah [18:56] >> yeah there's there's lots of downsides I [18:58] mean first of all for instance when when [19:00] you treat a U in 256 as an idealized [19:03] integer well it's not going to wrap [19:05] around but if you know that you know [19:08] that code which which it is in is an [19:10] checked code all right then you can [19:14] still treat it as an idealized integer [19:16] and then you just add an additional [19:18] check that it doesn't exceed 2 to the [19:22] 255 [19:23] 26 minus one and it doesn't go below [19:26] zero for instance. Okay, so you can use [19:28] some of that type information and then [19:30] it's just as sound as using bit vectors [19:34] except that bit vectors which would be [19:37] sound in this case uh if you try [19:39] multiplication and division you're going [19:41] to break the solvers because it's going [19:43] to create circuits that are too big and [19:46] there's a lot of tricks like that and [19:48] frankly you do end up with some [19:50] unsoundness if any of these algorithms [19:53] are not perfect.