Vulnerability Detection with Interprocedural Context in Multiple Languages: Assessing Effectiveness and Cost of Modern LLMs
This study empirically evaluates four modern LLMs on 509 interprocedural vulnerabilities across C, C++, and Python, demonstrating that incorporating caller and callee context significantly enhances detection effectiveness and that Gemini 3 Flash offers the best cost-effectiveness while Claude Haiku 4.5 excels in accurate identification and explanation.
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
Imagine you are a detective trying to solve a crime in a massive, bustling city (the software code). Your job is to find the "vulnerabilities"—the hidden traps or broken locks that bad guys could use to break in.
For a long time, detectives (and computer programs) have been looking at crime scenes one room at a time. They would walk into a single room (a single function of code), look around, and say, "This looks safe," or "This looks dangerous."
But here's the problem: The crime often happens between rooms.
Maybe the thief didn't break the lock in the kitchen; they tricked the person in the living room into handing them the keys. If you only look at the kitchen, you miss the whole story. This is called an interprocedural vulnerability—a flaw that only exists when you see how different parts of the code talk to each other.
This paper is a big experiment to see if using AI detectives (Large Language Models or LLMs) works better when we give them the whole story (the caller and the callee) instead of just the single room.
The Cast of Characters (The AI Models)
The researchers tested four different AI detectives, each with a different personality and price tag:
- Claude Haiku 4.5: The meticulous, expensive expert who writes very detailed reports.
- Gemini 3 Flash: The fast, cost-effective worker who gets the job done well without breaking the bank.
- GPT-4.1 Mini: The budget option that sometimes gets confused when given too much information.
- GPT-5 Mini: A newer, slightly smarter budget option, but still prone to getting overwhelmed.
The Experiment: Three Ways to Look at the Crime Scene
The researchers took 509 real-world "crimes" (vulnerabilities) from the ReposVul dataset (a library of known software bugs) and asked the AI to find them using three different strategies:
- Strategy A (Code Only): "Here is the room where the crime happened. Is it safe?"
- Strategy B (Code + Callers): "Here is the room, AND here is the person who walked in and handed the keys to the thief."
- Strategy C (Code + Callees): "Here is the room, AND here is the person the thief called for help."
The Big Surprises
1. "More Info" Doesn't Always Mean "Better"
You might think, "If I give the detective more clues, they'll solve it faster!"
The Reality: For some detectives, giving them more clues actually made them worse.
- The Analogy: Imagine trying to find a needle in a haystack. If you hand the detective a second, bigger haystack (extra code context), they might get distracted by the extra straw and miss the needle.
- The Result: The GPT models (especially the Mini versions) got confused. When the researchers added extra context, the GPT-4.1 Mini's accuracy dropped by a huge 25%. It was like a student who, when given a 10-page textbook instead of a 1-page cheat sheet, forgot the answer entirely.
- The Winners: Claude and Gemini were the "smart" detectives. They could look at the extra info, ignore the noise, and still find the bug. Their performance stayed steady no matter how much context they got.
2. The Cost of "Thinking Hard"
Every time you ask an AI to read more code, it costs money (based on how many "tokens" or words it processes).
- The Analogy: Reading a single room costs $0.50. Reading the whole house (with all the extra context) costs $1.00.
- The Result: Adding context doubled the cost for almost everyone. But did it double the results? No. In fact, for the GPT models, it made the results worse while costing more.
- The Best Value: Gemini 3 Flash was the clear winner for the wallet. It found the bugs almost perfectly (97.8% accuracy) for about $0.50 per check. It was the "Goldilocks" model: not too expensive, not too confused.
3. Speaking the Language Matters
The experiment tested three languages: C, C++, and Python.
- C/C++: These are like old, complex machinery where one broken gear can crash the whole engine. The "noise" from extra context hurt the GPT models the most here.
- Python: This is like a modern, self-contained app. The code is usually cleaner and more isolated. The results were a bit more mixed, but generally, the AI did well regardless of context.
4. The "Why" Matters (Explanations)
Finding the bug is good, but explaining why it's a bug is better.
- The Analogy: A doctor telling you "You have a broken leg" is helpful. A doctor telling you "You have a broken leg because you tripped on a loose rug, and here is how to fix the rug" is great.
- The Result: Claude Haiku 4.5 was the best teacher. It explained the bugs correctly and clearly 93.6% of the time. The GPT models, however, sometimes got the diagnosis wrong and gave a confusing explanation.
The Bottom Line
If you are building a security tool to scan code for bugs:
- Don't just throw everything at the AI. Giving an AI the entire history of a function (all the callers and callees) might confuse it, especially if you use a smaller, cheaper model. Sometimes, looking at the specific function in isolation is actually better.
- Pick your detective based on your budget.
- If you want the best balance of price and performance, use Gemini 3 Flash.
- If you need a detailed, high-quality explanation for a human to read, use Claude Haiku 4.5.
- Avoid using the GPT Mini models if you plan to give them a lot of extra context; they tend to get overwhelmed.
- Context is a double-edged sword. In the world of AI security, "more data" isn't always "better data." Sometimes, less is more.
In short: The study teaches us that AI is powerful, but it's not magic. You have to know which AI to use, how much information to feed it, and how much you're willing to pay to get the job done right.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.