Evaluating LLM Security Auditing: Recall, Reliability, and Cost
Evaluating LLM-assisted code security auditing requires more than a recall leaderboard. This article explains how to distinguish single-run recall, combined recall, and consistent detection; assess precision and review workload; interpret small benchmarks; and measure end-to-end costs. It also outlines a reproducible evaluation process and a risk-based approach to production deployment.
1. Security Evaluation Is Not Just About Finding the Most Vulnerabilities
When using large language models to assist with code security audits, the most intuitive metric is the number of vulnerabilities found. Enterprise decisions, however, often depend on other questions: Are results reliable when the same code is reviewed repeatedly? Can reported vulnerabilities be validated? How much additional execution cost is required to reduce missed findings? How much work do the resulting alerts create for human reviewers?
Security model evaluation should therefore go beyond a recall leaderboard. It should cover the entire delivery pipeline: ingesting code and environmental context, generating candidate findings, verifying the conditions that make a vulnerability valid, deduplicating reports, and delivering actionable results.
The key distinction is that cumulative coverage across multiple runs, performance in a single run, and repeated detection may differ substantially. Without complete benchmark samples, execution configurations, and validation records, isolated figures cannot establish a general ranking of model capabilities. A more useful question is how to distinguish “sometimes finds it,” “finds it after several attempts,” and “finds it every time.”
2. Three Different Metrics: Single-Run Recall, Combined Recall, and Consistent Detection
Suppose a benchmark contains 32 manually confirmed vulnerabilities, all within the audit’s defined scope. One run detects 17, and validation confirms that all 17 are genuine.
Single-run recall = Confirmed ground-truth vulnerabilities detected in one run ÷ Total ground-truth vulnerabilities
In this example, single-run recall is approximately 53.1%. It measures coverage in one execution and is especially relevant to workflows that can accommodate only one scan.
Now suppose the system runs three times. After deduplication, the combined results cover 28 distinct ground-truth vulnerabilities.
Three-run combined recall = Number of distinct confirmed vulnerabilities detected across the three runs ÷ Total ground-truth vulnerabilities
Combined recall is approximately 87.5%. This shows that repeated execution can recover some missed vulnerabilities, but it must not be presented as recall achievable in a single scan.
If only 10 vulnerabilities are detected in all three runs:
Consistent-detection coverage = Number of confirmed vulnerabilities detected in every run ÷ Total ground-truth vulnerabilities
This gives approximately 31.3%. The ratio of the intersection to the union—10 ÷ 28, or approximately 35.7%—also shows what proportion of the cumulative findings appeared in every run.
These numbers illustrate metric definitions only. They are not performance claims about any specific system.
The three metrics answer different questions:
- Single-run recall: How much does one execution cover?
- Combined recall: How much coverage can additional execution budget accumulate?
- Consistent detection: Which findings are repeatedly detected across runs?
A small intersection alone does not establish that the overall system is unreliable. A fuller assessment also requires the distribution of recall across runs, vulnerability difficulty, pairwise overlap between results, and consistency of the execution environment. High combined recall can indicate strong complementarity between runs, but it does not replace single-run reliability.
3. Why the Same Code Can Produce Different Audit Results
LLM-assisted security auditing involves some generative uncertainty. Even with identical inputs, separate runs may choose different analysis entry points, focus on different functions, or devote different amounts of reasoning to the same call chain.
Many differences, however, originate in the surrounding workflow rather than the model itself.
Context selection
Large repositories usually cannot fit into a single model input. The system must select files, split code into segments, or retrieve dependencies. If one run omits an authorization function, the model may incorrectly report a vulnerability. If a critical caller is missing, it may overlook the conditions that make a vulnerability exploitable.
Execution budget
Limits on analysis steps, context length, tool calls, and execution time all affect coverage. What appears to be “the same model running again” may involve materially different audit conditions because of timeouts or truncation.
Environmental context
Dependency versions, deployment modes, access boundaries, and configuration flags can change whether a vulnerability exists. A dangerous operation in a code fragment may not be reachable by an attacker in the actual deployment. Conversely, an apparently safe function may become risky through cross-module interactions.
Evaluations should therefore record the model, inputs, retrieval strategy, execution budget, and environmental information. Controlling these variables makes differences between runs easier to interpret.
4. Beyond Recall: Precision and Human Validation Workload
Rewarding recall alone can encourage a system to produce large numbers of vague risk hypotheses. Statements such as “validation may be missing here” or “this could allow unauthorized access” should not count as valid findings without a clear path and the necessary triggering conditions.
Precision = Confirmed valid vulnerability reports ÷ Total submitted candidate vulnerability reports
Two workflows may find the same number of real vulnerabilities while generating very different review workloads. The workflow that submits more invalid reports may require substantially more human effort. Alert noise wastes time and can delay the handling of high-risk issues.
A useful candidate report should include at least:
- Location: Relevant files, functions, and code ranges.
- Risk path: How external input reaches a sensitive operation.
- Required conditions: Attacker privileges, configuration prerequisites, and necessary environmental conditions.
- Validation evidence: Inspectable call relationships, test results, or controlled reproduction steps.
- Impact and remediation direction: Why the security boundary fails and where the correction belongs.
Reports that cannot be validated should remain unconfirmed rather than being counted as detections to improve recall. Confident wording is not a substitute for technical evidence.
5. Small Benchmark Differences Do Not Establish a Reliable Advantage
In a benchmark with 32 vulnerabilities, detecting one additional vulnerability changes recall by approximately 3.1 percentage points. A result of 26 findings rather than 25 is a genuine difference on that sample, but it does not automatically establish that one technical approach is stronger across all projects.
At least four factors require examination.
Vulnerability diversity
Does the benchmark cover enough vulnerability types? If most samples involve similar data-flow problems, results may primarily reflect how well a workflow handles that particular class.
Sample independence
Multiple vulnerabilities derived from the same project or defect pattern are not fully equivalent to independent samples from different systems.
Information leakage
Public vulnerability descriptions, patch explanations, and test files may turn the task from discovering an unknown issue into recognizing known clues.
Paired comparisons
When two workflows inspect the same vulnerabilities, evaluation should examine which issues each workflow misses, not just compare totals. Formal reports should include uncertainty intervals and use methods appropriate for paired outcomes.
Results should also be broken down by severity and business impact. Missing a critical authorization-boundary issue can have a very different cost from missing a low-impact vulnerability. Overall recall and high-risk vulnerability recall should be reported together.
6. Measuring Cost: A Low Unit Price Does Not Mean Low Delivery Cost
Input and output token consumption represents only part of the cost of a security audit. Total cost may also include context retrieval, code parsing, environment preparation, repeated execution, candidate validation, and human review.
A more practical metric is:
Cost per valid finding = Total cost of the complete audit workflow ÷ Number of unique confirmed vulnerabilities
The accounting boundary must be explicit. Does the total include human review time? Failed attempts and retries? The initial cost of building an index? Figures based on different boundaries are not directly comparable.
Repeated-run strategies should also be evaluated by their marginal benefit:
New valid findings in run n = Size of the union after n runs − Size of the union after n − 1 runs
If later runs mostly repeat existing reports, further execution delivers diminishing value. At that point, improving context, adding call relationships, or focusing on high-risk modules may be more useful than repeating the same configuration.
A fair comparison should distinguish at least three perspectives:
- Coverage achieved under an equal budget.
- Cost required to reach a comparable coverage target.
- Number of valid findings delivered within the same deadline.
These perspectives may produce different conclusions and should not be mixed.
7. Building a Reproducible Security Model Evaluation
A practical evaluation process can follow five steps.
Step 1: Establish a reviewed benchmark
Assign each known vulnerability a unique identifier and record its type, location, triggering conditions, impact, and confirmation evidence.
Include some vulnerability-free samples to check whether the system tends to overreport. For real repositories, also acknowledge that the ground-truth set may be incomplete. An unmatched report should not automatically be classified as a false positive.
Step 2: Fix the task boundaries
Specify whether the task covers a single function, an entire repository, or a cross-service call chain. Define whether the system may execute tests, inspect dependencies, or access external networks.
Results produced under different permissions and information conditions should not be ranked directly as though the tasks were equivalent.
Step 3: Preserve complete execution records
Retain input snapshots, configurations, candidate reports, validation results, elapsed time, and resource consumption.
When sensitive code is involved, apply access controls and appropriate redaction so that the evaluation process does not introduce new data risks.
Step 4: Standardize vulnerability matching and deduplication
Decide in advance whether reports describing the same root cause at multiple locations count as one vulnerability or several.
A model’s wording may differ from the reference answer while describing the same technical issue. Allow evidence-based matching rather than treating textual similarity as a substitute for security judgment.
Step 5: Repeat runs and analyze results by category
Report more than the overall average. Include per-run distributions, combined results, consistent detection, and the cumulative discovery curve.
Break results down further by vulnerability type, codebase size, and risk level to identify weaknesses that matter to the business.
8. Production Deployment: Use Layered Auditing Instead of a Single Ranking
Organizations do not need one auditing method to handle every task. A more practical approach is to build a layered workflow based on risk and cost.
Routine code changes can receive lightweight scanning focused on new input entry points, authorization checks, and sensitive operations. High-risk modules involving authentication, financial transactions, or sensitive data access can justify more context, repeated analysis, and human review.
Suspected high-severity findings should be validated in an isolated, authorized environment rather than through destructive testing against production systems. Model outputs should be treated as technical leads requiring verification, not as instructions to execute automatically.
The workflow should also have clear stopping conditions. Hand work over to people when consecutive runs produce fewer new valid findings, the audit budget is exhausted, or further progress requires business knowledge. Repeated model execution should not continue indefinitely.
Ultimately, a deployable security auditing capability is not simply one that accumulates the most findings. It must consistently deliver well-supported, actionable results with manageable false positives, within acceptable time and budget limits. Recall is an important starting point; repeatability, validation quality, and end-to-end cost determine whether the capability becomes dependable engineering practice.
