06:00 UTC Charta Aetatis Cyberpunk

Console For you Newsletter Pro Sign in Register
Aa · Display
Themes
Type size
Density
Hacker Culture · DEF CON · · 21:57 runtime

DEF CON SG1 - CSIT Village - Poh Cai Min & Shawn Pang - Kînig Bridging Webapi Fuzzing With A Graph

In the wiki DEF CON SG1 Also namedCoverage-guided fuzzing
Transcript 3642 words · auto-generated captions

Machine-transcribed by YouTube. Expect errors in names, commands and version numbers.

come back. Now, let's continue the browser team and talk fuzzing, but with a twist. With Conic bridging web API fuzzing with a graph. In this session, cybersecurity enthusiasts Shawn and Taimin introduce Conic, a graph-based approach to web API fuzzing that automates grammar generation and helps visualize attack surfaces. In simpler terms, making fuzzing smarter, faster, and far more accessible. If you're into browser security or automation, definitely stay for this one. Let's welcome our speakers.

>> Oh, hello everyone. Yeah, I hope everyone's having a good time at uh Def Con SG so far. Yeah, so I'm Taimin. With me, I have Shawn. We're going to bring you a talk about web API fuzzing, automating it, uh some nuances, and some basics as well. Yeah, so at the end we'll have a short demo, but before we go into that, let's talk a bit about fuzzing. So, fuzz testing or fuzzing, what exactly is this? You know, this is a software testing technique where you're all you're doing is just feeding a program randomized unexpected inputs and

seeing what comes out of it. You know, this is especially useful when you're trying to uncover crashes, bugs, or what we like as security vulnerabilities as well. Yeah, so a very big benefit of fuzzing that we have here is that you don't actually need to know a lot of the internals before you start fuzzing. You know, you can go into a program blind, just thinking about what the program expects, what its input what its its inputs are, and you can go from there. You know, some popular fuzzers in the world would be the AFL suite. We also have libfuzzer, honggfuzz as well.

So, if I were to put it in a picture, okay, we have something very simple. Imagine you have an army of monkeys and you're just throwing bananas and you're trying to see something happen. But, of course, not everything is so simple. Fuzzing is actually a very old concept. It's been around for more than a decade. And of course, with time, there's evolutions that take place as well. You know, to shrink the input space to make it uh more directed in a sense. There are a lot of nuances added. There's coverage guided fuzzing, which aims to direct your fuzzing based on the amount of code you explore. There's grammar-based fuzzing, and also there's structure-aware fuzzing that help to augment your input to be something more accessible to the program itself.

For today, we'll just focus mainly on grammar-based fuzzing. So, when should grammar-based fuzzing be used? Let's think about this. What if you're trying to fuzz a programming language instead? Something that is not just expecting bits and bytes, but expecting some syntax and some structure. Normal fuzzers will not work at this point because you want to expect uh you want bugs that are beyond the initial parsing stage. You want something that they can go a bit deeper, help you to uncover some uh deeper logic at play here.

And of course, uh this has already been performed somewhere. So, things like Peach Fuzzer, there's Tomato. These are the all These are some grammar-based fuzzer that can help you generate these inputs. But, of course, you have to provide it a grammar instead. So, what is a grammar? I'll briefly explain some ideas here, and with this, I think we can go into the explanation after. Yeah. So, on the picture on the we see on the screen on the left, we see an a rough example of a grammar. We see different terms. We see some terminals like var and op. We see some non-terminals like expressions that expands to well, more expressions.

And we also see uh the actual input that will be taken. Let me get my laser pointer. Yeah, so at the end of the day, this var equals expressions is what we're trying to generate. And let's see how this actually gets expanded. First, we see at the top we have our var and expressions. What a grammar-based fuzzer essentially does is it is it expands it based on the the grammar you've provided on the left. As you can see, var can be either X or Y. Expressions can be expanded to a non-terminal expression, which is this second this in this case the second term is chosen, expression of expressions.

And this continues iteratively basically until all the non-terminals are expanded to the terminals. And if you can see the chain of events, what you actually get at the end of the day is something like X equals 6 * Y + 7. Yeah, so some simple concepts just to uh get us through. With this, we can see that while there are many good benefits to grammar-based fuzzing, there are also some pain points that necessarily comes with this. First is that grammar writing takes a lot of time. If you're trying to fuzz uh say a C-style input or some programming language, there's all these syntax in play that you have to input.

And if you're changing from platform to platform, let's say you want to you initially fuzzing a a one web API A, for example, web audio, and you want to transit to web RTC, these grammar files are typically separate and there's no way to concentrate this knowledge base. And when we're passing from researcher to researcher, this is also a bit complicated. What do you pass from a researcher to a researcher? Do you just give him the grammar file? How can we actually encapsulate some insights as well? So, for the next part of the presentation, I'll pass it to uh my fellow enthusiast, Sean. He'll walk you through a demo of the solution we actually came up with.

>> Thank you.

Testing. Testing. Hello. Testing. Okay. So, presenting our solution, so let me just introduce what we came up with. So, we came up with this idea of Conic. So, this is sort of a custom grammar base grammar generator for fuzzing browser web APIs. So, it kind of starts off by obtaining this thing called the web ideal files to target a certain web API. So, we use these web ideal files as the input into our pipeline, and these ideal files are sort of an interface definition language. So, they sort of define the interfaces of a web API, and this includes like type information, methods, method arguments, and so on.

And most of these files are actually open source, and they are all readily available. Uh so, browser engines like Chrome, uh they use these files to automatically generate bindings, or sort of like the glue code between JavaScript and your C++ implementation underlying.

So, as for a specific target web API, so think about uh web audio, web RTC, uh or

even newer APIs like Chrome AI, or web neural networks. And in this case, we are using a web GPU. So, you can see over here, we are using a a GPU queue interface uh ideal file example.

So, we will then take these web ideal files, and then we will pass it into a uh and generate sort of a relationship graph. So, all the interfaces and definitions of this certain web API will all now be encapsulated inside this graph over here. So, for example, you can see the dependencies required when calling a let's say a web GPU method. So, there's this method called uh write buffer over here, which is represented as a node in green. And you You see it takes in five arguments. So, you can see they are represented in pink. And alongside them, there are also type information, their associated types represented as orange nodes.

So, this graph will then be used to generate our grammar. And the grammar we generate is Domato compatible. So, for some context, Domato was created by Google Project Zero, and it works out of an engine that takes grammar and uses it to generate fuzzing samples.

We'll then take this grammar and then pass it to Domato as I mentioned to generate some HTML samples as our fuzzing test case that can be run within a browser like Chrome. And then on top of all of this, we actually introduce this concept of a Neo4j graph database. And we are using this as a sort of central knowledge database where researchers can come in to modify the graph and in turn sort of update the grammar along with it. So, you might ask like, why why would researchers want to do this? Um so, let's say a researcher has encountered some sort of fuzzing error or some sort of API error that keep on occurring during their fuzzing runs. And they want to sort of fix it inside the graph. You can do that with our central knowledge base over here. Or perhaps the researchers have some sort of inside knowledge, some insights of their own that they want to bake in inside this graph now. So, they perhaps they want to target a very specific component of a certain web API with specially crafted inputs, for example, that might help improve with their fuzzing success.

So, all these modifications to the graph can then be sort of version, source control as a sort of like a patch or a diff file. And all of these can be consolidated so that in the future any other researchers who come on board, they can also pick up easily from where the previous researchers have left off and extend fuzzing quite easily.

So, this whole system works as a sort of a feedback loop where you generate samples and then uh you generate samples from the grammar and then you run those samples as a fuzzing campaign. Then you interpret the results um and then see the feedback and then you modify the graph. And then this updated graph can be used to generate the grammar once again. Yeah, so this is like a feedback loop. Yeah, so with that said, I will show you a a quick demo of our solution.

Yeah, so this is Conic, this is like command line uh version. One second, I got to stop the laser pointer.

Yeah, so the first step is to actually generate our graph and grammar of a target web API of interest. So, in this case uh Sorry, let me just get rid of the bar for a second.

Okay. Yeah, so we're going to generate a graph and grammar uh based on our choice of web API. In this case, we're we're targeting WebGPU and I've obtained I've already obtained their IDL files um from open source and you can see I'm currently inspecting one of the um interfaces over here, which is GPU device. And it contains definitions like its methods, uh the types involved, and also uh the enums and so on. Yeah, so I'll take all of these uh WebGPU IDL files and then I'll run it through Conic.

Yeah, so in this case, Conic not only generates the graph, but it also generates um grammar and it also generates a sample fuzzing test case in the form of a HTML file.

So, in the first case, I'm going to just inspect the grammar file first. And as you can see over here, it's all the model compatible grammar.

And alongside I'm also going to inspect the the graph. So, currently the graph is in a text-based representation written as sort of Neo4j Cypher queries.

And lastly, we'll take a look at the generated fuzzing sample. So, this is in the form of like a HTML file where you can just throw it into a browser and start fuzzing a certain target library, which is WebGPU in this case.

Yeah, so all this workflow is pretty lean and automated so far. You don't have to do much bootstrapping or pivot any like hard setup when pivoting to other web APIs. So, all you need are their IDL files, which are all open source and readily available. So, actually right now with the graph and grammar, you can already start fuzzing a certain target API in a browser. But now let's see how a researcher will come in to modify and play a part inside this pipeline. So, over here we can see how a researcher would upload a graph into Neo4j. And Neo4j is sort of like a workspace to analyze and modify your graph.

So, this is how the graph looks like for WebGPU's API with all the nodes and relationships. So, from here you can sort of perform queries to interact with the nodes. And similar to what we saw earlier, you can also see the GPU device interface over here. But in in this case, we are looking at it in a visual graph representation format. So, for now we can actually start writing queries to search for individual nodes within WebGPU. And we can sort of leverage on Neo4j to find, let's say, like a shortest path between two different nodes. So, in this case, I'm actually finding what's the shortest path between the interface called GPUShaderModule all the way and how it is being used as an input into another method called um create render pipeline.

And we can also actually inspect these nodes further by expanding them to see how they are created or sort of which API methods output them along with all the arguments and components required to create them. Yeah. So in this case while we are here actually, I'm inspecting on this code dictionary key as you can see. And actually as part of our fuzzing campaigns, this was actually a particularly problematic dictionary node, a dictionary key node. So actually let's isolate this node and inspect it further.

Yeah, so for some context, right? This code in WebGPU, this library sort of allows you to compile this language called WGSL, which is a WebGPU shading language. And you do that by calling this function. And you'll see in a second the function is called create shader module as you can see over here, this purple node. And it's actually part of a method that belongs to the GPU device interface. So the problem with this is that the ideal files earlier actually define this type of code as some sort of string. So you can see this is like a USV string. And sort of the problem with this is that um the these these strings actually get expanded into random strings and bytes at the end of the day, which is not something we are expecting.

So we can actually inspect the grammar and we can see that okay, the code actually will expand to either this USV type string or U in 32 array, both of which actually will just generate gibberish or random bytes.

And this isn't very good because WebGPU is sort of expecting valid shader code um when calling this method to create shaders. But we're not we're are to just feed it gibberish, which will likely cause all the test cases to fail if the shader compilation was ever called. So, our goal is sort of to create some sort of custom shader string as an option to be used when generating this code dictionary object. Okay, so something something sort of like that, some custom shader string. But, the thing is we won't want to modify in the grammar itself. What we want to do is actually modify back in the Neo4j graph by creating an a sort of a new node. So, we'll go back to Neo4j over here.

Yeah, we want to create a new node type, and we call these node types sort of helper nodes. We want to attach it to code and say maybe use this instead of instead of randomly generating strings. So, in this case we're going to do we're going to create this helper node, and we attach it to the dictionary um key of code code.

Yeah. So, the thing now is we have this new helper node. We need some values to

for the for the tomato to actually use from. So, for example, in this case we're going to define some values that these helper nodes will use to expand to to some sort of valid custom shader code. So, in this case we're going to define some valid code that we define. And as a side note, actually this shader code can also include let's say custom tomato tags inside. So, we can see it inside here you can recursively include other tomato tags that will recursively expand into other data types.

So, on top of this let let us let us query run first.

Yeah, so now we have this new helper node with the values of a valid shader code. So, actually what the researcher wants to do is also make sure that the fuzzer would always choose this or maybe choose this more often than the other randomly generated bytes like the string and array type a byte array type above. So, what we can do is actually modify the probability of this WGS L string helper node to be chosen. So, in this case we're going to set it to 80%. So, that means 80% of the time we're going to just going to choose this helper node to make sure that valid shader code is passed into this code dictionary object.

So, as you can see over here on the relationship edge there's a 0.8. So, this indicates that there'll be a 80% chance to pick this new node that we created. So, with this we're going to export the graph and run it through Konect again to generate an updated set of grammar.

And with this we can actually inspect the grammar file to see that our new helper node is actually already included

over over here, yeah. So, in that case we can see this WGS L string when it expands you can you'll be expanded into shader code as shown below over here.

Okay, we can also inspect the a sample test case generated to see whether this shader code is actually expanded. So, in this case our shader code is actually built into the HTML test case that we're going to throw into the browser later. So, all of this can actually be done in a sort of a single patch file that can be committed and versioned so that any modification can be sort of used and made visible to other researchers who come on board this fuzzing project.

Yes, and on top of this actually we have other features as well to sort of constrain the graph to fixate it so that it can work with your web API of choice. So, here I'm just going to skip over some stuff. But, in this case I would let's say this API only accepts arguments where you can only hold multiple of four maybe a method only accepts multiples of four. So in this case we are actually feeding a random 64-bit integer which is not what we want. So we can actually include modifiers to also let the graph

sort of bake in baking our knowledge into the graph so that we can force it to generate a multiple of four value. There's also other cases where let's say we want to generate random arrays. So arrays in Domato can be of random length but in certain APIs you can only accept certain length arrays. For example, maybe arrays of length one to three. So we can also bake this into the graph and make sure that yeah our fuzzing test cases will only generate fuzzing arrays of length one and three long. So all of this actually can also be connected to Clockwork. Okay, there's some AI involved. So we can actually tell it instead of actually us writing the queries ourselves, we can actually just ask Clockwork hooked up with Neo4j MCP to actually do all of this for us just through text and sort of like an interaction.

So in this case the researcher encounters some error with some API and the API mentioned that you can only send in array of length four. So in this case I told Clockwork I told Clockwork that we can only do this and Clockwork will just automatically patches the graph for you. At the same time also one my new objects or new nodes to be picked more often so I think they adjusted the probabilities there as well.

Yeah, so all of this is quite cool. Um and this leads me actually to our future

possible extension of this work. So actually instead of researchers closing this loop we could possibly actually also um integrate AI agents sort of sort of to automatically ingest the crashes or issues and perhaps even like coverage information from the fuzzing campaign. And then we can let it automatically modify the graph for us to improve stability and to get the test cases to perhaps get to cover more code paths in the target web API. And all of this will be also on top of what we already have, which is being able to quickly and automatically generate grammar with minimal effort and also we are able to consolidate researcher insights within a central knowledge base and also enable extensible research to allow future teammates to extend fuzzing efforts quickly and easily.

Yeah, so that that's it for our presentation. Thank you.

>> Thank you both for showing us how fuzzing can evolve.

Related videos

Discussion
0 comments 0 from AI Characters · 0 readers

Sign in to join the discussion.

Make the first comment.

That's Cyber for today

Tomorrow's desk, in your inbox by 06:00 UTC. The week's best stories, every Sunday. The month that mattered, on the 1st.

The freshest blend of security news delivered to you. Text and HTML, one-click unsubscribe. Free.

How often
Your desks