The Patch Wasn’t Enough

· The Tech Stack ·

8 min read Original article ↗

A few months back, I published a brief about finding bugs using Code Graphs and our story with Log4J v2.

Hunting Bugs using Semantic Code Graphs

Since then, a lot of things have changed. We welcomed a new life into this world and got busy with the new-parent duties.

But, at the heart, I am an Engineer and a person who wants to improve the way we develop and deploy software into production. That passion has lead me to continue working on Decypher. Over the last few months, I focused on building Decypher as a compiler grade Code Property Graph generator, which can map classes, methods, their relationships as well as how variable data moves across product and dependency codebase. All of this, while reducing the storage requirements by 100x on disk and making queries 3-5x faster.

While this happened, one of the major use cases that started showing up was Neuro-Symbolic Security Analysis of products. The core idea is that, with the advancement in frontier LLM development, the LLMs can act as a great tool to find and validate security issues in products.

While a lot of companies as well as open source projects are growing in this space, majority of them heavily depend on LLMs to find susceptible sinks and sources which can introduce Security issues by not having appropriate guardrails.

This lead me to start exploring if Decypher can pivot the picture. With its compiler grade Code Property Graph and ability to ingest and map configuration data across products, it should be easier to drive Static Security Analysis and Dynamic Runtime Analysis in a cost effective manner.

Let’s talk about how Decypher is helping uncover Security vulnerabilities and partial patches to existing CVEs in a cost effective manner.

One of the biggest issues impacting LLM driven vulnerability hunting, discovery and validation is the fact that LLMs by the nature of their approach are non-deterministic.

A LLM can decide to take completely different paths even if it is given the same vulnerability prompt 100 times. This makes vulnerability discovery hard to reproduce and even harder to verify. Further, not every company has infinite tokens which they can burn on running a wild chase on their code bases spanning hundreds and thousands of lines of code.

This makes Decypher and our approach interesting. Instead of making LLM and multi agent architectures drive the whole security and vulnerability analysis, we put them behind a deterministic code graph and then leverage LLMs to discover new attack vectors as well as validations for them, verifying whether they can be exploited or not.

The core of this effort is a 5 stage process:

Leveraging compiler grade tooling of Decypher and by directly hooking into the compiler build stages, we ensure an end to end Code Property Graph of the product along with its dependencies mapping every small detail. This code property graph is stored in a highly optimized Decypher Index Format (DIF) which allows for optimized storage on disk as well as sub-millisecond query capabilities, allowing LLMs to realize whole source to sink paths throughout the codebase in a fraction of time.

Once the CPG is built up and code is indexed, every other layer of the Decypher Security Pipeline queries the underlying dataset ensuring the target products security model can be mapped accurately.

This stage generally will generate all the possible classes, data flow paths, config connectors, etc and the overall index size could go in millions of nodes and hundreds-of-thousands data flow paths.

Purpose built on top of Decypher, hunter itself has 2 stages:

Deterministic tooling built on top of graph rules walks through the whole Decypher index and realizes the different public entry points and data sinks throughout the project and libraries and creates an overlay which could be the potential attack surface.

Each of these realized paths contain data flow entry points (HTTP request handlers, CLI command entry points, message consumers, etc.), the validation layers, sanitization code and finally the data sinks.

For the realized paths, the LLM based inference layer goes through the different paths and infers attack specifications that might be possible. The LLM layers performs the grouping based on validators, type of data and the sanitization code, grouping the different paths into a specification group (e.g., SQL injection, Remote Code Execution, Server Side Request Forgery, etc.,).

These specs once inferred are cached into the DB, so that the future runs don’t have to reinterpret them again.

Combined, the Stage 2 produces a list of candidates that could potentially have a vulnerability and are worth taking a look. By this layer, the number of possible paths that the LLM layer has to judge is reduced to a few thousands.

Once the hunter has given a list of paths that could be a potential attack vector, the multi stage LLM layer kicks in.

This layer consumes the flow paths from the hunter stage and validates whether the generated path actually allows the data to flow to the sink or not. If it allows the data to flow, then whether the validation and sanitization layers provide enough protection or not.

This layers output is binary:

  • Flows: The raw user provided data flows from Source to Sink, and, the validation and sanitization layer is not enough.

  • Blocked: The raw user provided data cannot flow from source to sink.

By the end of Stage 3, majority of the paths discovered by the Hunter stage along with their specs are pruned and reduced to a few hundreds.

For the paths where the outcome of Stage 3 was Flows, the Condition phase explores what conditions (config, parameters, etc.) are required to guard the flow path.

The output of this stage further prunes the possible paths if appropriate configuration settings are in place to prevent the flow of raw user data from the source to sink.

By this layer, the potential paths are reduced to either 0 or a few tens of them.

Whatever survives Flow and Condition phases is passed down to the Challenge phase.

This phase essentially challenges all the facts that were generated by the Flow and Condition phase and matches them against the product and library documentation, known deployment techniques and attempts to contradicts the findings.

While this phase executes, we expect that the LLM judge may want additional facts to establish a claim. For this, the judge is allowed unto 30 turns where it can issue material requests, each request asking for unto 5 additional data points, along with the reasoning and Decypher’s MCP will serve them back.

The outcome of this stage is categorized into 3 major categories:

  • Flow Confirmed: The raw user provided data can flow from source to sink and can be executed without guardrails

  • Blocked Confirmed: The raw user provided data does not have any path to flow from source to sink.

  • Needs Human: There are gaps in the gathered facts and a final decision cannot be arrived at.

By the time the challenge stage is over, we have a very small subset of attack vectors that can be realized and potentially ready for human eyes or another LLM to go ahead and fix.

This stage gathers all the facts from the prior layers and generates a report per accepted or refuted vulnerability and provides the following details as a JSON report:

  • Vulnerability description

  • Vulnerability class

  • Source file/library where the vulnerability exists

  • The exact code flow path and conditions that lead to an exploit

  • Confidence rating

  • How the judge arrived at the conclusion

At no point does the reporting stage emits a way through which the vulnerability can be exploited.

While the product is still very early, it has helped in discovering severe vulnerabilities (CVSS 3.1 rating of 9+) as well as patches which don’t patch the existing vulnerabilities appropriately in open source projects, which can lead to remote code execution, SSRF attacks.

Considering the blast radius of these projects and responsible disclosure policy for these vulnerabilities, I will hold back publishing about them until the embargo lifts and the patches are released in public.

While those disclosures are under embargo, one metric I do want to highlight is efficiency: all these discovered vulnerabilities costed only a few cents (USD $0.20-$0.90) and less than 15 minutes of time per project, with Sonnet 5.5 on Medium thinking.

With the LLMs in picture, the Software engineering space is definitely up for disruption. Even more so will be Information Security, where new classes of bugs will be discovered, and potentially exploited (we already saw a global patching effort with the PHP vulnerabilities that got into the limelight in October).

Over the next few days to weeks, I plan to start polishing the product layer and open it up for a few open source projects, where it will help them scan every single incoming PR for any security issue and also to help discover hidden vulnerabilities.

If you maintain any open source project and will like to onboard, do drop me a note! The product will be completely free of cost for any open source project.