Security LLM Evaluation: From Recall Metrics to Engineering Deployment

    Security LLMs are increasingly used in code auditing, vulnerability analysis, and alert triage, but a single recall number cannot show whether they are reliable or useful in production. This article explains the differences between single-run, cumulative, and stable recall; why precision and evidence quality matter; how to design fair and reproducible evaluations; and how cost and layered workflows affect engineering value.

    1. Why “How Many Vulnerabilities Were Found” Is Not Enough

    Large language models are entering workflows for code auditing, vulnerability analysis, and security alert triage. For development teams, the most intuitive question is: how many real vulnerabilities can a model find?

    But “how many” is not a complete evaluation standard. The same model may produce different vulnerability sets when run once versus three times. A plausible-sounding risk description may not correspond to a real, exploitable security defect. Even if a process eventually covers more vulnerabilities, its deployment value may be lower than expected if it requires extensive repeated scanning and manual screening.

    A security model evaluation therefore needs to answer at least four questions at the same time:

    1. Within a fixed budget, how many real vulnerabilities can be found?
    2. Under the same conditions, are repeated runs stable?
    3. How many false positives appear in the output, and how much verification cost do they create?
    4. Can discovered issues be converted into engineering tasks that are locatable, reproducible, and fixable?

    The figures referenced in the original material are useful for explaining differences among metrics, but the material does not fully disclose test-set composition, execution configuration, or validation details. They are therefore used here as examples of measurement definitions, not as a basis for product rankings or direct extrapolation to production performance.

    2. Single-Run, Cumulative, and Stable Recall Are Three Different Capabilities

    2.1 Single-Run Recall: Closer to the Experience of One Scan

    Suppose a test set contains 32 confirmed vulnerabilities, and one scan identifies 17 of them. The recall for that run is:

    Recall = correctly identified true vulnerabilities ÷ known true vulnerabilities in the test set

    The result is approximately 53.1%.

    This metric is suitable for measuring the effect of “one trigger, one output” in an automated pipeline. Many real-world scenarios do not involve unlimited repeated scanning, so single-run recall is often closer to the capability developers experience in daily work.

    However, a single result can still be affected by input trimming, context selection, generation randomness, and the execution environment. You should not select only the best run, nor draw conclusions from only the worst run. Instead, report the distribution across multiple independent runs.

    2.2 Cumulative Recall: Measuring Coverage After Multiple Exploration Rounds

    Suppose the same test set is run three times, and the three result sets are deduplicated by true vulnerability identity. If they ultimately cover 28 vulnerabilities, the cumulative recall is 87.5%.

    If the true vulnerability sets found in each round are A, B, and C, then:

    Cumulative recall = number of vulnerabilities in the union of sets A, B, and C ÷ total known vulnerabilities

    This metric answers: “If repeated attempts are allowed, how many known issues can the system cover?”

    It does not answer: “Can any single run achieve the same result?”

    Cumulative recall is naturally affected by the number of runs. More rounds usually have a chance to expand coverage, so different approaches must be compared under the same number of rounds or a similar resource budget. Otherwise, the comparison may reflect differences in investment rather than differences in capability.

    2.3 Stable Recall: Observing Which Issues Can Be Found Repeatedly

    If only 10 of the 32 vulnerabilities are identified in all three runs, the stable recall corresponding to the three-run intersection is approximately 31.3%.

    The calculation is:

    Stable recall = number of vulnerabilities in the intersection of sets A, B, and C ÷ total known vulnerabilities

    This does not mean the remaining vulnerabilities definitely cannot be reliably identified, but it does indicate that the current process has significant run-to-run variation for some issues.

    Note that a three-run intersection is not a direct estimate of the per-run hit probability, nor is it a guarantee for future runs. The more rounds there are, the stricter the condition that an issue must be hit in every round becomes, so stable recall must also state the number of runs.

    A more valuable reporting method is to list how many times each vulnerability was hit and to analyze sources of variation by vulnerability type, code span, and context requirements.

    3. What It Means When Cumulative Coverage Is High but Consistency Is Low

    Security analysis is not simple keyword matching. A vulnerability may require the model to understand the relationships among input sources, permission boundaries, data flows, and dangerous operations at the same time.

    When cumulative coverage is high but single-run performance fluctuates significantly, the following factors are usually worth investigating.

    3.1 Is the Context Complete?

    If the model sees only the code near a dangerous operation, it may be unable to determine whether the input is controlled. If it sees only the entry function, it may miss subsequent validation.

    The evaluation should record which files were provided in each round, whether they were truncated, and whether cross-file call relationships were included. Otherwise, an apparent model difference may actually come from differences in how the input was prepared.

    3.2 Does the Analysis Path Vary Randomly?

    One run may prioritize permission checks, while another may focus on input handling. Different paths can produce complementary findings, but they can also cause unstable results.

    This complementarity can be used for multi-round auditing, but its cost must be made explicit, and the number of additional findings must be validated. Simply increasing repetitions is not enough.

    3.3 Is Result Adjudication Consistent?

    The same vulnerability may be described as different risks, or it may be split into multiple alerts. If results are counted directly by text entries, repeated descriptions may be mistaken for new vulnerabilities.

    Cumulative results must therefore be deduplicated by vulnerability identity. The deduplication basis should include root cause, key code location, and trigger conditions, not merely wording similarity.

    4. Beyond Recall: Precision and Evidence Quality Are Mandatory

    High recall does not mean the output can be used directly. If a system submits many unverified guesses, it may also happen to cover more real issues.

    A common definition of precision is:

    Precision = confirmed valid vulnerability reports ÷ all vulnerability reports

    In practical security work, precision directly affects manual review pressure. If alerts lack evidence, security engineers need to reread code, trace calls, and construct verification conditions. The time saved by the model may be offset by review effort.

    Each report should therefore include at least:

    • Issue location: relevant files, functions, and key code sections.
    • Risk root cause: what constraint is missing, or which trust boundary is crossed.
    • Trigger preconditions: what input control capability or access conditions an attacker needs.
    • Evidence chain: how input reaches the dangerous operation and what validation it passes through.
    • Impact scope: data, permissions, or business processes that may be affected.
    • Remediation direction: measures aimed at the root cause, rather than a generic suggestion to “strengthen validation.”

    Conclusions that cannot be confirmed should be marked as “pending verification” and must not be counted directly as discovered vulnerabilities. Automated validation should also be performed in an isolated, authorized environment to avoid turning the audit process into a disruption to real business operations.

    5. How to Build a Fair and Reproducible Evaluation Process

    5.1 Define Task Boundaries First

    “Security capability” is a broad term. Source-code vulnerability localization, configuration review, dependency risk identification, and alert triage are not the same task.

    Before comparison, fix the input format, output requirements, and success criteria. For example, source-code auditing can require the issue location, exploitability conditions, and evidence chain at the same time. Merely restating a general risk should not be considered a successful localization.

    5.2 Build a Test Set That Includes Non-Vulnerable Samples

    If all samples contain vulnerabilities, a model may tend to report one issue for every code segment, and the evaluation cannot fully expose false-positive risk.

    The test set should include both vulnerable samples and reviewed non-vulnerable samples, and it should cover different code sizes, vulnerability categories, and cross-file analysis difficulty. For samples that have not been fully confirmed, label uncertainty should be retained so that genuine new issues found by the model are not misjudged as false positives.

    5.3 Fix Inputs and Run Conditions

    Record prompt content, code version, context scope, available auxiliary capabilities, timeout limits, and retry rules. If different processes receive different code information, the results cannot simply be attributed to the model itself.

    If test materials may appear in public training corpora, memory effects also need to be considered. Independent holdout sets, reasonable variants, and unpublished samples can reduce the risk, but it should not be claimed that data contamination has been completely eliminated.

    5.4 Use Independent Review and Dispute Handling

    Model output should not be scored directly by the same model’s own judgment. A more reliable approach combines human review, code evidence, and necessary isolated validation.

    For disputed reports, record the reason for the dispute and the basis for the final decision. This improves confidence in the results and prevents scoring criteria from changing with each candidate approach.

    5.5 Report Distributions, Not Only the Best Result

    At minimum, publish single-run average performance, run-to-run variation, cumulative coverage, stable hits, and false-positive behavior. For small test sets, interpret small differences cautiously.

    In a sample of 32 vulnerabilities, finding one more vulnerability produces a change of about 3.1 percentage points. Such a difference may be engineering-relevant, but it is not enough on its own to prove a general advantage. More samples and repeated experiments are still needed.

    6. Cost Is Not Just Generation Cost

    Security evaluation costs include at least three parts:

    Total cost = model run cost + auxiliary execution cost + human review cost

    Model run cost may also include multi-round scanning, long-context processing, and failed retries. Auxiliary execution cost includes resources such as isolated environments, test tasks, and log storage.

    The original material involves relatively large cost differences, but it lacks complete billing definitions and execution configurations. Specific ratios should therefore not be treated directly as universal conclusions. Different input lengths, output sizes, and retry strategies can all change the final bill.

    A more business-relevant metric is “cost per effective vulnerability”:

    Cost per effective vulnerability = complete evaluation process cost ÷ number of confirmed valid and deduplicated vulnerabilities

    You can further measure “cost per new effective vulnerability.” For example, how many new issues did the second scan find, and how many did the third scan add? If later rounds mainly produce duplicate alerts, consider stopping repeated scanning and shifting to deeper manual analysis or improved context preparation.

    Vulnerabilities of different severity levels can also be counted separately, but weights should be defined in advance and must not be adjusted arbitrarily after seeing the results.

    7. Use a Layered Workflow in Deployment, Not Unlimited Reruns

    A practical security auditing workflow can be divided into four stages.

    The first stage is low-cost triage. Use information such as code structure, sensitive operations, and permission boundaries to concentrate limited analysis resources on high-risk areas. Triage only sets priorities; it cannot be used to claim that areas not selected contain no vulnerabilities.

    The second stage is targeted analysis. For candidate issues, supplement call relationships, configuration, and validation logic, and require a complete evidence chain. Providing effective context relevant to the issue is more important than repeatedly submitting the entire code repository.

    The third stage is validation and deduplication. Merge alerts from the same source, validate suspected issues manually or in an isolated environment, and distinguish real vulnerabilities, general hardening suggestions, and hypotheses with insufficient information.

    The fourth stage is fix regression. After remediation, check not only the original trigger path but also similar paths, confirming that the root cause has been eliminated rather than merely making the original test stop triggering.

    The entire process should follow least privilege and data minimization principles. Avoid bringing keys, production credentials, or unrelated sensitive information into the analysis context. Model output should be treated as untrusted input and must not directly drive high-privilege operations without review.

    8. How to Decide Whether a Security Model Is Worth Using

    A trustworthy security evaluation should not provide only a “highest recall” conclusion. It should provide a complete capability profile:

    • How many real issues can be covered in a single run?
    • How many new findings can multiple runs add?
    • Which vulnerabilities can be hit reliably?
    • How many alerts require manual exclusion?
    • How long does it take to validate one effective report?
    • Within a fixed budget and time limit, how many fixable issues can be delivered?

    Cumulative recall reflects exploration coverage, single-run recall reflects one execution, and stable recall reflects repeatable hits. Precision and validation cost determine whether a team truly benefits.

    For developers and enterprises, the goal is not to maximize a single number. The real goal is to continuously convert security findings into effective fixes under clearly defined boundaries, reproducible validation, and controllable cost. That is the key for LLM security capability to move from experimental results to engineering value.