It’s late, you’ve spent all day staring at code, and now you’re reading about Large Language Models (LLMs) doing the same. We’ve all seen the headlines: "AI outperforms humans at finding security bugs." But when an LLM flags a function as vulnerable, does it actually understand the logic, or is it just a very sophisticated parrot that remembers seeing that specific bug on GitHub?
A new paper, "Right Verdict, Right Reason?", puts 13 different LLMs through a rigorous "vulnerability ladder" to find out if they are truly reasoning or just reciting from memory.
TL;DR
Just because an LLM correctly identifies a bug doesn't mean it knows why it's a bug. By testing models against actual program execution and "post-cutoff" vulnerabilities (bugs they couldn't have seen in training), researchers found that while top-tier models are great at spotting the "smoking gun" line, they struggle to distinguish a bug from its fix and rely heavily on memorizing known CVEs.
What Problem Does This Paper Address?
We are increasingly trusting LLMs to audit our code. These models don't just give a "Yes/No" verdict; they provide natural-language explanations. However, existing benchmarks are often "leaked"—the models likely saw the vulnerabilities and their fixes during training.
If a model has memorized a specific bug from a famous project, its high score is a measure of its memory, not its reasoning. The authors wanted to move beyond static code snippets and ground the evaluation in program execution. If the model truly understands the vulnerability, it should be able to predict how the code behaves when it runs.
Methods
The researchers built a "ladder" of five tests (L1 to L5), each progressively harder and designed to strip away the possibility of "getting lucky" or pattern matching.
- L1 (Discriminate): Can the model tell a vulnerable function apart from its fixed version?
- L2 (Localize): Can it point to the exact "trigger line" where the fault occurs?
- L3 (Sensitivity): If we hide the "trigger line," does the model change its mind?
- L4 (Counterfactual): If we rename variables or add "decoy" fixes (checks that look right but don't actually protect the code), is the model fooled?
- L5 (Execution): Given a specific input, can the model predict if the program will crash?
To make this "execution-grounded," they replayed 515 real-world exploits (Proof of Concepts) to identify the trigger line (where it crashes) and the dynamic slice (all the lines of code that actually influenced that crash).
Datasets
- BigVul & PrimeVul: 515 C/C++ functions with confirmed vulnerabilities.
- Post-Cutoff Set: 195 brand-new vulnerabilities published between September and November 2026 (after the training cutoffs for models like GPT-4o and Claude 3.5).
- Counterfactual Benchmark: 315 execution-confirmed variants where researchers manually edited code to test model robustness.
Key Insights and Ideas
- The "Bug vs. Fix" Paradox: Surprisingly, many models (especially open-weight ones) are terrible at L1. They often label both the original bug and the developer's fix as "vulnerable." They have a strong bias toward saying "Yes, this is a bug" regardless of the code's actual state.
- Localization $\neq$ Understanding: Commercial models are actually quite good at finding the "trigger line" (L2), significantly beating simple keyword-search rules. However, L3 showed that their verdicts don't always depend on that evidence. They might find the right line but still give the right verdict for the wrong reason.
- The Memorization Wall: When tested on vulnerabilities published after their training data was collected, the performance of the strongest models (like Claude Opus 5.5) dropped significantly. This suggests that a large part of their "intelligence" is actually just a very good memory for existing CVEs.
Key Results
- Open-weight models (like Qwen2.5-Coder or CodeLlama) performed no better than chance at distinguishing a bug from its fix.
- Commercial models (GPT and Claude variants) were much stronger, citing the correct trigger line in 55% to 81% of cases.
- Memorization Impact: On the pre-cutoff set, Claude Opus 5.5 had a 67.2% success rate in distinguishing bugs from fixes. On the post-cutoff set, this plummeted to 37.1%.
- Execution Reasoning: When given the actual program input (L5), commercial models could predict crashes with 86% to 94% accuracy, far better than simple rules that just look for missing bounds checks.
Limitations and Future Work
The study primarily focuses on C and C++ memory-safety vulnerabilities (like buffer overflows). While these are critical, it remains to be seen if these findings hold for higher-level logic flaws in languages like Python or Java.
The authors also note that their method requires a working Proof of Concept (PoC) to ground the tests in execution. If a bug is "silent" or hard to trigger, this framework can't evaluate it. Future work could involve integrating these "execution-grounded" signals directly into the training process to help LLMs move from memorization to true program reasoning.
Summary updated