DSS

DSS 2026 / Day 1 / Amber Hall

Symbolic Execution of Math-Heavy Code in the Age of AI

Neville Grech

20:02 · Recording

Watch on YouTube ↗Open recording viewerOriginal programme entry
Download plain textDownload timestamped JSON

Source: YouTube automatic caption track · Exported 2026-11-16. Timestamps link to the source video. Cue end times were not supplied.

Transcript

0:01All right, thank you for the intro. I'm

0:04Neville from DDUB. Just a little bit

0:06about our organization. So, we're a

0:08security company. We do audits. We're

0:11very well known in the static analysis

0:13and decompilation space. Uh we've built

0:15a lot of products that use some of these

0:17techniques. And as you'll see today,

0:19we're also into symbolic execution,

0:21which is a technique that underpins a

0:24lot of the formal verification tools

0:26that uh we use as a community.

0:30All right. So,

0:33okay. So, what is symbolic execution?

0:38All right. So, I'm going to use this

0:40example as a running example. So, it's a

0:42basically a transfer function. I made

0:45this up. So, you will not see code as

0:47bad in the wild as this. But effectively

0:50in symbolic execution, you don't execute

0:52the code using real inputs. Instead, you

0:56execute the code using symbols. And

0:58these symbols can represent all the

1:00possible values uh of every variable

1:03input that you have. Okay. So because of

1:07this you end up um when you reach a

1:10branch you end up forking meaning that

1:14um you have a branch like an if

1:18statement you got to execute the program

1:20under both one side and the other side

1:22concurrently.

1:24All right. So, uh, what this means is

1:26that he will go down a lot of different

1:28paths. Um, and I'm going to do a dry run

1:32of a few of these paths.

1:40Okay. So, we start the program. All

1:43right. So, we reach a condition. Reach a

1:46condition. An if statement. This if

1:49statement here checks, you know, that

1:50the amount in this transfer is not over

1:53a certain amount. Okay, at this point we

1:56fork. So let's fork and go down one uh

1:59branch. Okay, under this branch we're

2:02going to assume that the condition is

2:05false, meaning that the amount is less

2:08than a th00and. Okay,

2:15if we assume that we add that amount to

2:18the so-called path condition. The path

2:20condition is a set of conditions under

2:23which the current under the current

2:25execution that you must assume to be

2:27true. Then you reach another condition.

2:38Okay, we reach another condition. This

2:40is a condition about the uh the current

2:43fee. In this case, we add also another

2:46path condition. Then at the end, we need

2:49to send these path conditions over to an

2:50SMT solver. And the SMT solver will

2:53check whether these conditions are

2:56consistent with each other and it will

2:57give us either a satisfiable assignment

2:59SAT or unsatisfiable. Okay, a lot of

3:03people use Z3 which is an external

3:05solver but you can also write your own

3:08solver. It's just difficult.

3:11So in this case turns out that this is

3:13ansat. Okay. So we terminate the

3:16execution here. We need to repeat the

3:19same process to all possible paths. In

3:21this case the program only contains

3:23three valid paths. But as you can

3:26imagine, real programs are going to have

3:28a lot more paths because if you have

3:31let's say 45 branches

3:34and each branch has a branching factor

3:36of like 1.5 meaning that you know one

3:39side succeeds the other side has a 50%

3:42of continuing you will have 84 million

3:46paths. Okay, which is which is a lot of

3:49paths and you know a single query with

3:52an SMT solver it can take minutes

3:55potentially

3:57and actually analyzing D5 protocols is

4:00harder. Why is it harder?

4:08It's harder because you find a lot of

4:10code in math libraries which uh which

4:14combines different kinds of algebbras

4:17meaning that it uses both for instance

4:19addition, multiplication and subtraction

4:22which you need certain techniques to

4:24reason about and also it uses you know

4:27shifts uh and or or bitwise operations

4:31which require different techniques. And

4:34so if you go down and use one kind of

4:37techniques, you need to convert one kind

4:40of math into another kind and that's

4:43creates a lot of complexity. This is an

4:46example from unis swap v3. In this case

4:49it does 512 bit multiplication

4:53followed by division.

4:55All right. And then on top of that you

4:59also get complexity.

5:01Let me show you an example.

5:08So you get additional complexity. This

5:10is another example. This is also from

5:12unis swap. But in this case, it's a

5:14function that helps you compute the

5:16price of an asset based on the liquidity

5:18in a in a particular tick. In this case,

5:21you get like 20 possible if statements.

5:24And you know, all branches are mostly

5:26feasible. And so you get once you enter

5:29this function, you multiply the number

5:31of pads by around 1 million 2 to the 20.

5:35Okay. And the correctness of these D5

5:37protocols really relies on code like

5:40this. A lot of tools will not support

5:43code like this. A lot of provers will

5:45will choke. So what do we do?

5:48So we've devised a series of techniques.

5:52Okay, some of these techniques are

5:53original, some of them are appropriated.

5:56Okay. So the first thing we do, okay, uh

6:00we are known in the decompiler space.

6:02We've written a lot of techniques to try

6:04to lift code at a level of

6:06representation higher than the bite

6:09code. Okay, that's in the DOB

6:11decompiler. We've used some of those

6:13same techniques to lift low-level code

6:17also to a higher level presentation. The

6:20screenshot uh shows a simple program

6:23which has been compiled and it doesn't

6:25do anything special. It just copies a

6:27strct around call data storage and that

6:31sort of thing and does some arithmetic.

6:34So for instance the uh code in green is

6:38you know like check arithmetic.

6:40It really translates to like three or

6:43four mathematical operation. So this is

6:46the sort of thing we do. There's a lot

6:48of techniques which go into uh doing

6:50this convert lifting to a higher level

6:53representation. Second thing we do is we

6:57undo the optimizations.

6:59Now this is easier said than done and

7:02also you might question why would you

7:03want to undo the optimizations? I mean

7:06they're there for a reason. Well, the

7:08problem with optimizations is that the

7:11uh library auditor authors, they have

7:14exploited the fact that they're using a

7:16a machine, you know, with with bits and

7:19that sort of thing. And by exploiting

7:21this, they can get better performance

7:23and in some cases they can get also

7:25better um better accuracy, you know, can

7:29they can utilize uh the bits better.

7:34Um but unfortunately these also

7:36introduced these mixed algebra um

7:39expressions.

7:41So we do one of two things when we see

7:44an expression which is problematic. We

7:46have devised algorithms to either

7:48convert these to idealized mathematical

7:51representations such as in the first

7:53example that's the min function. Second

7:56function is the average function. It's

7:59simpler to reason about than the one on

8:02the left hand side. Or another technique

8:05is to convert for instance a bits

8:08operation into an operation that

8:11operates on data structures. So the

8:14operation on the right hand side is a

8:16slice of bits and you want to be careful

8:19you know the algorithms need to be

8:20careful to distinguish between the two.

8:23Okay, by the way, a lot of optimizations

8:26you can read about them in this book,

8:28but this was written for C. It's a good

8:30book.

8:35All right. So, another technique, it's

8:37to write your own SMT solver. Now, this

8:41is uh not as simple as I'm saying. Um,

8:45so you don't need to write your own SMT

8:47solver. Zedri does a very good job, but

8:49it is designed to give you either a

8:51satisfiable assignment or unsatisfiable.

8:54And to get a satisfiable assignment that

8:58um it requires more computation than you

9:01might need. Instead, during symbolic

9:04execution, often times you're more

9:06interested to know whether a uh path

9:09condition is completely unsatisfiable or

9:13whether it could possibly be unsat

9:15possibly be satisfiable. And so writing

9:18a solver like that is simpler and also

9:22the algorithms that you can pick and

9:24choose into the solver. You can make the

9:27solver be linear time and you can

9:29utilize techniques from computer aided

9:33algebra systems which are faster and I

9:36don't know some of the these techniques

9:37are also used in Z3 but you know linear

9:40time versus double exponential but

9:44there's a caveat at the end of the day

9:46you still need to use Z3 in some cases.

9:50All right.

9:54Another technique this is actually

9:57appropriated. A lot of uh symbolic

9:59execution engines they do summaries.

10:02Okay. We also do summaries in our

10:04symbolic execution engine. So summaries

10:07you are actually encoding instead of

10:09like um forcing the engine to execute a

10:13lot of difficult and complex code you

10:16either reimplement it in a simpler way

10:18using idealized mathematical operations

10:21or you just put in there you know the

10:24additional path conditions that you

10:26would need to add. Okay. So the way we

10:30uh wrote our summaries is we went

10:33through a lot of defi and math libraries

10:35and we asked AI to write summaries okay

10:39and our symbolic execution engines have

10:41has a lot of summaries in it now that

10:44matches to specific libraries and

10:47obviously we don't trust the AI so we uh

10:51we use fuzzing to you know ver validate

10:55these summaries against the actual code

10:57now you might be thinking why use

10:59fuzzing when you can use symbolic

11:01execution. Well, for small functions,

11:04small pure functions um that don't do

11:08much. Okay, so these are mathematical

11:10functions, fuzzers can actually do a

11:12good job at disproving you and so it's

11:15easier.

11:18And finally, if you accept the fact that

11:21your symbolic execution engine is going

11:24to be more scalable, but as a as a

11:26result, you might get a few more false

11:29positives.

11:30Well, you can have an a agent in the

11:33loop that verifies, you know, whether

11:35whether a finding is true positive or

11:37false positive. You want to be using

11:40frontier models, but frontier models are

11:42very expensive. But how can you get the

11:44cost down of to these frontier models? A

11:47lot of tools when they give you a

11:49finding they produce just gibberish or I

11:52mean an expert can interpret it but it's

11:54like really long okay and really long

11:57traces through bite code and through

12:00memory operations and that sort of thing

12:02and it's a waste of tokens to go through

12:04that. So a lot of you can you should

12:07dedicate a lot of engineering to try to

12:10decipher that and get a more highlevel

12:13output from your tool so that the AI

12:15agent does not need to spend a lot of

12:18tokens on this and it's going to perform

12:20better and then you can use a better

12:24frontier model.

12:26This is actual input output from from

12:28our tool. Okay. So everything maps back

12:31to source code operations. Okay. It's

12:34it's in a familiar format. That's also

12:36another thing that you know they uh tell

12:39you you know how to integrate with AI

12:41models. Well, you make the output

12:44familiar to them as well.

12:50Okay, let's look at some results.

12:54So, we've implemented this tool.

12:59It's symbolic execution engine and we

13:01compared it against HEVM and Halmos.

13:05Okay. So we picked 100 random smart

13:08contracts, smart contracts that have

13:10been used on chain recently and uh we're

13:13running these tools offline meaning that

13:15you know storage is symbolic and and

13:18that sort of thing.

13:20Now it turns out that a lot of tools

13:22they are not geared towards exploration

13:25meaning that they are geared towards you

13:27know like um checking a single property

13:31not at checking all the executions of of

13:33code bases. And so in the case of Halmos

13:36we wrote a custom harness and we needed

13:38to fiddle a lot with the settings to to

13:41make it run uh this experiment. All

13:44tools use Z3 120 second timeout which is

13:48like really low. Um and all the

13:51exploration parameters you know it takes

13:53a long time to configure these tools to

13:55make sure that they're level playing

13:58field that they're all exploring the

13:59same number of paths and whatnot. Okay.

14:03So in the case of our tool we managed to

14:06analyze 80% of the smart contracts all

14:10possible parts. Okay.

14:12um except loops

14:15in the case of HVM 31% and halmos only

14:1926%. Okay, a lot of these tools have

14:22partial results they actually most of

14:25the time what they do is they choke for

14:27instance when parsing call data or you

14:30know moving things to memory that sort

14:32of thing. So because of the loops.

14:37Okay. So uh we've uh deployed this tool

14:40internally. We're using it for uh

14:43auditing at DOB. Uh we also use it for

14:46bug hunting. And so it's designed as

14:48such. It's it's it's currently not

14:50designed to uh to be a replacement of a

14:54formal prover, but it could possibly

14:56become one in the future. And right now

14:59we're also doing explorations you know

15:01trying to see whether um you know

15:03certain EIPs will break contracts in the

15:06future once they are deployed and and

15:09that sort of stuff

15:11allchain analysis kind of like what we

15:14were doing with static analysis.

15:16Any questions?

15:24>> Okay. Yep.

15:28just light on how you kind of cutting

15:30the cost down of using agent workflows

15:33in symbolic execution.

15:35>> Yeah.

15:35>> Hi, I'm Manu from lip P2P. Amazing talk.

15:38Just wish to ask how you are kind of

15:41optimizing the cost of symbolic

15:44execution when you're building a swarm

15:45of agents and you're kind of using some

15:48of the things to verify and also have

15:49some of the agents to kind of do uh the

15:52uh like the final job over here. Yeah.

15:55Thanks.

15:55>> Yeah. All right. So, first of all, you

15:58got to optimize the um you know the

16:01interface of the tool, make it

16:02appropriate for command line um

16:05environment and that sort of thing. The

16:07output as I showed on one of the

16:10previous slides is very very dense and

16:13maps directly to the to the source

16:16level. It's like compared to some other

16:19tools out there. You know, other tools

16:21will generate pages and pages and pages

16:23of output. this one will generate you

16:26know the very succinct things. So this

16:30this is basically heavy compiler

16:32engineering right it's compiler

16:34engineering trying to map you know back

16:36to source you know get get all the

16:38debugging information through the

16:40compilation process it's that sort of

16:42work

17:02So my my question is what would you say

17:06is the greatest one of the major

17:09challenges in terms of adopting symbolic

17:12execution in the generic auditing

17:15ecosystem. Your form of verification you

17:17got fuzzing. you have so many different

17:19things is what what's the biggest

17:21challenge you would say? Well, the

17:24biggest challenge I thought, you know,

17:26when embarking on this project is that

17:28most tools don't work well enough to

17:30merit, you know, spending enough time um

17:34getting them up and running because most

17:36of the tools, you know, I I kind of like

17:38alluded to this. They're not designed to

17:40explore an entire contract. They're

17:42designed to look at a single function at

17:44a single property, you know, like a

17:46property on a single variable or

17:48something like that. So, that's very

17:49very time consuming.

17:52um you know tools get better and better

17:55and then instead of using the tool you

17:58ask your AI agent to use the tool that's

18:01going to be free for you right you ask

18:03load hey use this tool on this and if it

18:06works you're going to get good results.

18:15So basically when you reduce the the

18:19type to the integer that will be like

18:21more um more CV friendly type that could

18:24be quick make the solving time quicker

18:26basically like when you convert all

18:28these like type to be more solving

18:30friendly um for the SMT solver then

18:33what's the basically downside cost like

18:35when you face all this like BIP type and

18:38um potentially that could be like

18:39forcing the bit factor in the SMT lib

18:42language instead of forcing it to be

18:44integer that definitely faster but like

18:46what's the downside cost of all this

18:48address type all this dynamic factor

18:50type or dynamic array in the solidity

18:53because that must be some downside costs

18:55there yeah

18:56>> yeah there's there's lots of downsides I

18:58mean first of all for instance when when

19:00you treat a U in 256 as an idealized

19:03integer well it's not going to wrap

19:05around but if you know that you know

19:08that code which which it is in is an

19:10checked code all right then you can

19:14still treat it as an idealized integer

19:16and then you just add an additional

19:18check that it doesn't exceed 2 to the

19:22255

19:2326 minus one and it doesn't go below

19:26zero for instance. Okay, so you can use

19:28some of that type information and then

19:30it's just as sound as using bit vectors

19:34except that bit vectors which would be

19:37sound in this case uh if you try

19:39multiplication and division you're going

19:41to break the solvers because it's going

19:43to create circuits that are too big and

19:46there's a lot of tricks like that and

19:48frankly you do end up with some

19:50unsoundness if any of these algorithms

19:53are not perfect.

Source and accuracy details

Source export SHA256: 6bd7c14b04a83b68b010cb5397c5d8860cf6297cc696109b40c1304915e63cd8