Evaluating Recall in LLM-Based Security Scanning

    Security model benchmarks need more than a single recall score. This article explains how to interpret single-run recall, consistent detection, and multi-run union recall, assess benchmark scope and total cost, and connect evaluation results to practical security review workflows. It also outlines a checklist for comparing reports without confusing benchmark coverage with production reliability.

    Why “Highest Recall” Can Be Misleading

    Large language models are often used in security workflows to identify potential vulnerabilities and unsafe practices in code, configuration files, dependencies, and logs. Published results frequently emphasize how many known issues a model found. That number is easy to understand, but also easy to misinterpret: it usually measures detection coverage on a fixed benchmark, not whether false positives are manageable in production or whether every run produces the same findings.

    Evaluation itself can also be expensive. Scanning real repositories or synthetic vulnerability datasets may require repeated model calls, context assembly, and multiple rounds of cross-checking, with token consumption reaching billions. High spending does not establish that a conclusion is reliable. It makes a clear evaluation protocol even more important: without one, the numbers are difficult to compare.

    Before interpreting a result, ask three questions: What is being evaluated? Where do the test cases come from? How are the metrics aggregated?

    Evaluation Scope: Establish What Is Being Tested

    The evaluation target is usually not the overall usability of a chat product. It is whether a model, under specified context-window and tool constraints, can identify previously labeled security issues in code or configuration. Common tasks include injection flaws, missing authorization checks, hardcoded secrets, unsafe deserialization, and dependency configuration risks. Each test case needs a clear ground-truth set; otherwise, a claimed detection cannot be verified.

    The dataset source should be verifiable. Is it a public benchmark, an internally labeled dataset, or a sanitized sample from real projects? Coverage across programming languages and frameworks, deliberate obfuscation, and irrelevant files all affect difficulty. If a report omits the number of cases, whether each case includes complete context, or whether tool use is allowed, its percentages are barely comparable with those from other experiments.

    A practical approach is to document the protocol in a table covering:

    • Dataset size and language distribution
    • Whether retrieval and execution are allowed
    • Maximum number of interaction rounds
    • Whether findings from repeated runs on the same case are combined into a union

    Without this information, a claim of “first place” is more narrative than evidence.

    Test Method: Single-Run, Consistent, and Three-Run Union Recall

    Vulnerability detection evaluations should report at least three metrics rather than a single overall score.

    Single-run recall is the proportion of ground-truth issues detected in the first complete scan. It approximates what a team will see when it runs the model once in production, making it especially relevant to on-call work and automated pipelines. Low single-run recall suggests sensitivity to prompts, context truncation, or randomness.

    Consistent detection counts an issue only if the model finds it in every independent run of the same case. This measures repeatability. Security teams need to avoid situations where a vulnerability appears in a demonstration but disappears on a rerun, leaving a ticket difficult to validate and resolve. If consistent detection is much lower than union recall, the capability may exist, but it is not yet dependable enough to serve as a deterministic release gate.

    Multi-run union recall counts an issue if any run detects it—for example, at least one of three independent runs. It measures the coverage achievable with a retry budget. High union recall combined with low consistent detection suggests that randomness is helping the model occasionally find an issue rather than reliably recognize the same pattern.

    Consider this illustrative example. These figures explain the metric structure; they are not measured results:

    • Known issues in the dataset: 32
    • Issues detected in the first run: 17
    • Issues detected in all three runs: 10
    • Issues detected across the union of three runs: 28

    Union recall of 28/32 looks close to complete coverage, but only 10 issues were detected consistently. Engineering decisions should pay particular attention to the gap between consistent detection and union recall. A larger gap strengthens the case for majority voting, a fixed temperature setting, and structured-output validation in the pipeline—not simply reporting the highest recall.

    The scoring rules also matter. Does identifying a risk category without locating the affected line count as a partial match? Are false positives tracked separately? Reporting recall without precision encourages models to list more possible problems, which can quickly exhaust human review capacity.

    Focus on Transferable Conclusions, Not Rankings

    Once brand names and individual scores are removed, several useful principles remain.

    First, differences between frontier models on security benchmarks are often smaller than differences introduced by evaluation protocols. When union recall is similar, consistency and false positives become the more meaningful differentiators. Model selection should ask whether consistent detection is acceptable under the same budget.

    Second, recall and cost must be read together. If a lower-cost model trails a leading model by roughly one issue under the specified test conditions, it may be more useful for large-scale repository scanning. The trade-off is accepting a slightly lower coverage ceiling and using additional inexpensive retries to recover coverage. Those retries still cost money: include their tokens in the total rather than comparing per-call prices alone.

    Third, a ranking cannot establish the performance of stronger or newer model tiers that were not tested. Reports should explicitly state their coverage limits, including untested capabilities such as longer context windows, agentic multi-tool workflows, or security-specific fine-tuning. Treating those boundaries as conclusions can lead readers to overestimate or underestimate an entire class of technology.

    Fourth, high token consumption should prompt an investigation into unproductive retries. Repeatedly scanning the same files, placing an entire repository into context, or repeatedly revisiting paths already confirmed to be issue-free can inflate usage. A more sensible workflow uses static rules and dependency scanning to narrow the scope first. The model then explains high-risk code and reasons about exploit chains. Detected issues receive a second review with a different prompt, rather than running three full scans indiscriminately.

    Connect Evaluation to Development and Cloud Operations

    For most organizations, the goal is not a public benchmark score. It is to connect findings to defect tracking and release gates. Several practices help make that transition.

    Layered detection: Use rules and component vulnerability databases for broad baseline coverage. Use the model for semantic and business-logic issues, such as authorization failures, incorrect security assumptions, and dangerous default configurations. Cross-check the two layers rather than relying on either one alone.

    A fixed regression dataset: Build sanitized cases from historical, real-world vulnerabilities. Whenever the model or prompt changes, measure single-run recall, consistent detection, and union recall. Include negative cases that should not trigger findings, so improved recall does not conceal a surge in false positives.

    Output constraints: Require the model to provide the affected location, vulnerability type, exploitation prerequisites, and remediation advice, then validate the output against a schema. Treat unparseable responses as failures rather than allowing verbose but unusable output to count as a detection.

    Cost governance: Archive scan artifacts in object storage, process work asynchronously through message queues, and limit per-repository concurrency on a container platform. Use logging, monitoring, and alerts to track token usage, timeouts, and empty-result rates. These are general infrastructure capabilities, not requirements tied to a particular vendor’s proprietary API.

    Human review loops: Route consistently detected issues into automatic ticket creation. Send issues found only through the multi-run union to a spot-check queue. This uses the model’s broader coverage without treating an isolated successful response as a production conclusion.

    A Checklist for Reading Evaluation Reports

    1. Dataset transparency: Are the number of cases and their sources disclosed? Can the dataset be publicly verified?
    2. Metric coverage: Does the report include single-run recall, consistent detection, and union recall, along with precision or false-positive examples?
    3. Run configuration: Are temperature, seeds, tool access, and context truncation documented?
    4. Total cost: Does the cost include retries? A lower unit price may not produce a lower total bill.
    5. Scope boundaries: Does the report clearly identify what was not tested, rather than presenting a limited experiment as a market-wide conclusion?

    Conclusion

    The real value of a security evaluation that consumes enormous numbers of tokens is not its ranking on a particular day. It is what the evaluation reveals about metric design: union recall describes potential coverage, consistent detection describes repeatability and production readiness, and single-run recall describes the default experience.

    Separating these metrics—and considering cost and untested capabilities—helps determine whether a model belongs in preliminary screening, assisted review, or strict release gating. Instead of chasing the highest aggregate score, developers should measure all three on their own regression datasets and use layered detection to keep occasional findings in a human review queue.