← Latest papers
💻 computer science

Bridging Code Property Graphs and Language Models for Program Analysis

This paper introduces codebadger, an open-source Model Context Protocol server that bridges Large Language Models with Joern's Code Property Graph engine to overcome token limits and inter-procedural analysis gaps, enabling LLMs to effectively perform semantic program analysis, vulnerability discovery, and patching across large-scale codebases.

Original authors: Ahmed Lekssays

Published 2026-03-27
📖 5 min read🧠 Deep dive

Original authors: Ahmed Lekssays

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

The Big Problem: The "Library" vs. The "Brain"

Imagine you have a brilliant, super-smart librarian (the Large Language Model or LLM) who knows everything about how books are written. You ask this librarian to find a specific typo in a massive library that has 8,000 books (a huge codebase).

The librarian has two major problems:

  1. The "Short Memory" Issue: The librarian can only hold a few pages in their head at once. If you try to shove the whole library into their memory, they get overwhelmed and stop working.
  2. The "Blind Search" Issue: If you ask the librarian to find a specific pattern, they usually just look for words that look similar. They can't easily see how a sentence in Book A connects to a sentence in Book Z, or how a character in one chapter flows into the next. They miss the "story" that spans the whole library.

Because of this, current AI tools usually just look at one page at a time. They miss the big picture, which is exactly where dangerous security bugs (like a thief slipping through a back door) often hide.

The Solution: The "Super-Smart Assistant" (CodeBadger)

The authors built a tool called CodeBadger. Think of CodeBadger as a specialized tour guide or a super-powered flashlight that sits between the Librarian and the Library.

Instead of forcing the Librarian to read every single book, CodeBadger gives the Librarian a set of special tools (like a map, a magnifying glass, and a highlighter) that let them ask specific questions about the library's structure without reading everything.

How it works:

  • The Map (Code Property Graph): CodeBadger first builds a giant, 3D map of the entire library. This map doesn't just show where the books are; it shows how the ideas in the books connect. It knows that "Chapter 1 in Book A" leads directly to "Chapter 5 in Book B."
  • The Tools (MCP): CodeBadger translates the Librarian's natural questions into actions on this map.
    • Instead of: "Read the whole library."
    • The Librarian asks: "Show me all the places where a guest enters the building (Source) and where they might break a window (Sink)."
    • CodeBadger says: "Here is the exact path the guest took. Here are the 3 spots where the window was broken."

The Three Big Wins (What They Tested)

The paper tested this new system with three real-world challenges:

1. The "Big Library" Audit (Code Comprehension)

  • The Task: The Librarian had to check an 8,000-book library for safety issues (memory safety).
  • The Old Way: The Librarian would try to read every book, get tired, and miss the danger.
  • The CodeBadger Way: The Librarian asked the guide, "Where are all the places we hand out keys?" The guide pointed to 54 spots. Then, "Where do we lock doors?" The guide pointed to 300 spots. The Librarian only looked at those specific spots and found hidden dangers (like a key that could open a door it shouldn't) without ever reading the whole library.

2. The "Hidden Trap" Discovery (Vulnerability Discovery)

  • The Task: Find a new, unknown trap in a library called libtiff (used for images).
  • The Result: The Librarian used the guide to trace a specific number (a coordinate) from the moment it was written down to the moment it was used to move a stack of papers. The guide showed that the number could get too big, causing the stack to fall over and crush the floor (a buffer overflow).
  • The Cool Part: The Librarian didn't just find the trap; they built a fake "test bomb" (an exploit) to prove it worked, and then found the exact fix the library owners had already secretly installed.

3. The "Perfect Fix" (Vulnerability Patching)

  • The Task: Fix a known bug in a library called libxml2 (used for web data).
  • The Result: The Librarian used the guide to trace the flow of data backward from the crash. They saw exactly where the math went wrong (an integer overflow). Without needing to write complex code queries themselves, the Librarian wrote a perfect patch to fix the math.
  • The Wow Factor: The fix the AI wrote was almost identical to the one the human experts eventually released. It got it right on the first try.

Why This Matters

Before this, AI was like a student trying to solve a math problem by reading the whole textbook hoping to guess the answer.

CodeBadger turns the AI into a detective. It gives the detective a map of the crime scene and a set of forensic tools. The detective doesn't need to read every page of the police report; they just need to know where to look, what to trace, and how to connect the dots.

In short: This paper shows that if you give AI the right tools to understand the structure of code (not just the words), it can find and fix security holes in massive software projects that were previously too big for it to handle.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →