Benchmarking LLMs for Vulnerability Detection: Recall, Consistency, and Cost Trade-offs

    This article breaks down the methodology behind large-scale benchmarks of LLM-based vulnerability detection. It explains why recall alone is an incomplete metric, how single-run versus pooled results reveal model stability, why cost per finding must be part of any evaluation, and how to build a reusable benchmarking framework with multi-run strategies and verifiable datasets.

    1. Background: Why Burn Tokens on Security Benchmarks

    The performance of large language models on security tasks such as code understanding, log analysis, and vulnerability discovery cannot be reliably inferred from general-purpose conversational benchmarks. Security scenarios are special in three ways:

    1. False negatives are extremely costly. A real vulnerability that goes undetected can turn directly into a production security incident, while false positives are relatively manageable — they can be absorbed by human review.
    2. Capability is highly context-dependent. The same model behaves very differently across languages, frameworks, and coding styles, so scores on general leaderboards don’t transfer directly.
    3. Cost sensitivity. Security auditing often means feeding an entire codebase, large volumes of logs, or streams of alerts into a model, one item at a time. Token consumption is enormous. A team recently published a security model evaluation that consumed tokens on the order of tens of billions — a reminder that serious security capability assessment is fundamentally an engineering experiment that trades compute for conclusions.

    This article does not target any specific model or vendor. Instead, it dissects the methodology behind this kind of benchmarking: how a proper vulnerability detection recall evaluation should be designed, which metrics matter, and which pitfalls to avoid.

    2. Core Metrics: Recall Is Only Half the Story — Consistency Matters Just as Much

    2.1 Recall: The First Metric in Security Scenarios

    In vulnerability detection tasks, recall is defined as:

    1. Recall = number of vulnerabilities correctly found by the model / total number of real vulnerabilities in the dataset

    For example, if a test set contains 32 real vulnerabilities and the model finds 25 in a single run, recall is 25/32. When ranking multiple models, results are typically sorted by this metric in descending order.

    2.2 The Large Gap Between Pooled and Single-Run Results

    One notable phenomenon in practice: single-run results and pooled multi-run results can differ dramatically. Some models find only around 17 vulnerabilities on a first single run, but taking the union (pooled) of three independent runs pushes coverage to 28 — enough to jump near the top of the leaderboard.

    The mechanism behind this: LLM outputs are stochastic (influenced by sampling temperature, context window truncation, attention allocation, and other factors), so each scan focuses on different “angles.” Union-merging effectively buys broader coverage through repeated sampling.

    But this exposes another problem — stability. Stability can be quantified with “stable hits”: the number of vulnerabilities found in all three runs. If a model achieves pooled recall of 28/32 but only 10 stable hits, its capability fluctuates heavily — it relies on “casting a wide net” rather than “aiming precisely.”

    2.3 Interpreting the Three Metric Types Together

    Metric Meaning Engineering Significance
    Single-run recall Coverage from one run Reflects “out of the box” capability
    Pooled recall Coverage from the union of multiple runs Reflects the capability ceiling, approachable via retries
    Stable hits Vulnerabilities found every time Reflects reliability; determines whether unattended operation is viable

    An ideal model should have both high single-run recall and high stable hits. If high pooled recall can only be achieved by stacking repeated runs, the engineering side must build retry and result-merging mechanisms — which directly drives up token cost and latency.

    3. The Cost Dimension: Cost-Effectiveness Must Be Part of the Evaluation

    Security auditing is a task at scale. An evaluation that looks only at recall and ignores cost produces severely distorted conclusions. In practice, two derived metrics are recommended:

    1. Cost per finding: the token expense consumed per real vulnerability discovered;
    2. Minimum runs to reach equivalent recall: how many reruns are needed to hit the target recall — the more runs required, the more the actual cost is amplified.

    Real-world tests have shown cases where non-flagship models trail the strongest model by only one or two vulnerabilities in recall, yet cost 60–70% less. For budget-sensitive teams, these “value” models are often the more rational choice — especially when top-tier models need multiple reruns for stable output, which further widens the real cost gap.

    4. Building a Reusable Evaluation Framework

    4.1 Test Set Design

    • Cover diverse vulnerability types: injection, broken access control, deserialization, misconfiguration, dependency vulnerabilities, etc., sampled in stratified layers;
    • Labels must be verifiable: each vulnerability should come with a reproducible trigger path or PoC description, avoiding disputes over “the model claims it found something but it can’t be confirmed”;
    • Difficulty grading: grade vulnerabilities from “discoverable via explicit pattern matching” to “requires cross-file dataflow analysis,” so the model’s real weaknesses can be located.

    4.2 Run Strategy

    1. RUNS = 3 # at least three independent runs
    2. results = []
    3. for run in range(RUNS):
    4. found = scan_with_model(dataset, temperature=run_config(run))
    5. results.append(set(found))
    6. pooled = set().union(*results)
    7. stable = set.intersection(*results)
    8. recall_pooled = len(pooled) / TOTAL
    9. recall_stable = len(stable) / TOTAL

    Key point: the three runs must remain independent of each other (separate session contexts, sampling parameters within a reasonable range); otherwise the results have no statistical significance.

    4.3 Result Adjudication

    A two-stage approach of “rule-based pre-screening + human review” is recommended: first use static rules or scripts to normalize model output formatting and perform preliminary matching, then manually adjudicate borderline cases. Record the rationale for every decision to build an auditable evaluation archive.

    5. Practical Recommendations for Engineering Teams

    1. Don’t trust single-run leaderboards. Any evaluation that runs only once can severely underestimate or overestimate a model. Run at least three times and report pooled recall and stable hits.
    2. Build retry mechanisms into the pipeline. If the chosen model has mediocre consistency, embed multi-sampling and result-merging logic into the automated audit pipeline, compensating for model variance with engineering.
    3. Select models by task tier. High-value, low-frequency deep audits can tolerate higher costs; high-frequency CI pipeline scans should prioritize cost-effectiveness and stability.
    4. Run continuous regression. Model versions iterate frequently. The test set should be maintained as a long-term asset, with benchmarks re-run on every version update to prevent silent capability regressions.

    6. Conclusion

    The biggest takeaway from benchmarks consuming tens of billions of tokens is not any single model’s ranking, but the evaluation methodology itself: recall determines the capability ceiling, consistency determines usability, and cost determines whether scaling is feasible. Missing any one of the three makes the conclusion one-sided. For security teams, building an internal evaluation system covering all three dimensions has more long-term value than chasing positions on any single leaderboard.