How to Evaluate LLM Vulnerability Discovery Capabilities: Benchmarks, Metrics, and Cost Control

    When a model safety evaluation that "burned tens of billions of tokens" goes viral, developers should focus less on the leaderboard ranking and more on whether the evaluation methodology holds up. This article breaks down the evaluation logic for LLM vulnerability discovery across benchmark design, metric definitions, statistical pitfalls, and practical deployment. It shows how to build a reproducible, explainable, and comparable evaluation system on a limited budget, avoid being misled by a single recall number, and more rationally assess where domestic and frontier models can actually be used in real code audit scenarios.

    When a model security capability evaluation that “burned tens of billions of tokens” goes viral, what developers should really pay attention to is not the ranking, but whether the evaluation methodology itself holds up. This article breaks down the evaluation logic for LLM vulnerability discovery, from benchmark design and metric definitions to statistical pitfalls and engineering deployment. It helps you build a reproducible, explainable, and comparable evaluation system on a limited budget, avoid being misled by a single recall number, and more rationally assess the usable boundaries of domestic and frontier models in real code audit scenarios.

    1. Why Vulnerability Discovery Is Harder to Evaluate Than General Benchmarks

    General capability leaderboards usually consist of closed-ended questions: the input is clear, the answer is unique, and scoring is automated. Vulnerability discovery is an open-ended retrieval and reasoning task with three characteristics:

    1. A huge answer space. A real codebase may contain hundreds of thousands of lines, with vulnerability clues scattered across configuration, dependencies, business logic, and commit history.
    2. Subjective judgment. Whether something constitutes an exploitable vulnerability depends on the threat model, deployment environment, and preconditions.
    3. Highly random results. The same model on the same question may follow completely different paths in two runs.

    This means the evaluation cannot draw conclusions from a single run. The more mainstream industry practice is “multiple runs on the same question + aggregated metrics + cost normalization”, which is essentially using statistical methods to counter randomness.

    2. Benchmark Construction: Preventing Models From “Memorizing Answers”

    The credibility of an evaluation depends first on where the questions come from. A common mistake is to test directly with a public question bank: the model may have already seen the question or even the answer during pre-training, inflating the score.

    A more rigorous benchmark construction process usually includes the following steps:

    • Questions are taken from recently disclosed real vulnerability entries, dated later than the training data cutoff of most models;
    • Vulnerabilities are re-planted into real open-source codebases rather than presented as standalone small snippets;
    • Limited context entry points are provided (such as repository paths and dependency lists), but no hints about the vulnerability location;
    • The model is offline throughout, prohibited from retrieving external information, ensuring that what is tested is code understanding and reasoning ability rather than retrieval ability.

    A sample evaluation task description structure is as follows:

    1. {
    2. "case_id": "CVE-like-017",
    3. "repo": "sample-service",
    4. "language": "Java",
    5. "context_files": ["src/auth/TokenService.java", "pom.xml"],
    6. "constraints": {
    7. "network": false,
    8. "max_turns": 30
    9. },
    10. "ground_truth": {
    11. "sink": "TokenService#verify",
    12. "category": "auth_bypass"
    13. }
    14. }

    The key point is constraints: the turn limit and the offline constraint together determine the “difficulty baseline” of the evaluation, and scores across different turn limits cannot be compared directly.

    3. Metric Design: Recall Is Only the Tip of the Iceberg

    Recall from a single run (how many known vulnerabilities were found) is the most intuitive metric, but it is extremely unstable. A more complete evaluation should report at least three types of metrics.

    The first is pooled recall, the total number of vulnerabilities hit at least once across multiple runs. It measures the “capability ceiling” but overestimates actual usability, because in production you only run once.

    The second is stable hit rate, the number of vulnerabilities hit in all three runs. It measures “reliability” and is most closely related to engineering deployment. In practice, it is common to see high pooled recall but noticeably lower stable hit rate, indicating that the model is “casting a wide net” rather than “reasoning stably”.

    The third is cost-normalized metrics, such as token consumption or cost per effective hit. Without normalization, simply comparing recall rewards a strategy of “thinking indefinitely”.

    The relationship among the three can be roughly expressed as:

    1. effective capability ≈ stable hit rate × single-run success rate × cost affordability
    2. pooled recall ≈ capability ceiling (optimistic estimate)

    A typical phenomenon is that one model ranks first in pooled recall, but finds only about half on the first run and has a stable hit rate below one third; another model has pooled recall lower by only one, but at a much lower cost. If the goal is automated gating in a CI pipeline, the latter is often more suitable.

    4. Statistical Pitfalls: Rankings Are Almost Meaningless With Small Samples

    With 32 questions and 3 runs each, the sample size is very small. A difference of one or two vulnerabilities between models falls within the range of random fluctuation and does not constitute a significant difference. A rigorous presentation should include:

    • Reporting confidence intervals rather than a single point estimate;
    • Stating the run temperature, random seed, and retry strategy;
    • Distinguishing “pre-release checkpoints” from “official versions”; different checkpoints cannot be lumped together;
    • Clarifying the scope of models not tested, to prevent readers from extrapolating conclusions.

    In addition, the difficulty distribution of the questions significantly affects rankings. If most questions concentrate on one category of vulnerability (such as injection), the ranking reflects capability in that category rather than comprehensive security understanding. An ideal benchmark should be stratified by vulnerability category and report per-category recall.

    5. From Evaluation to Deployment: How Enterprises Should Choose

    For enterprises, evaluation conclusions need to be mapped to specific scenarios. The following decision path can be followed:

    1. Clarify the purpose: is it pre-submission self-check, CI gating, or red team assistance? The purpose determines the acceptable false positive rate and latency.
    2. Use models in tiers: high-value, low-frequency deep audits can use models with a higher capability ceiling; high-frequency, low-cost daily scans use cost-effective models.
    3. Build an internal benchmark: constructing 20-50 internal questions from historical vulnerabilities in your own codebase is more instructive than external leaderboards.
    4. Enforce manual review: model output must enter the code review process and cannot directly modify code automatically or automatically block releases.

    A simplified pseudocode illustrates the tiered scheduling idea:

    1. def audit(repo, diff):
    2. quick = run_model(cheap_model, repo, diff, max_turns=8)
    3. if quick.confidence > 0.8 or not diff.is_sensitive():
    4. return quick.findings
    5. deep = run_model(frontier_model, repo, diff, max_turns=30)
    6. return merge_and_deduplicate(quick.findings, deep.findings)

    6. Cost Control: Spend the Token Budget Where It Counts

    An evaluation at the scale of tens of billions of tokens is not replicable for most teams, but the cost control approach can be borrowed:

    • First use a small sample (5-10 questions) for coarse screening to eliminate clearly lagging configurations;
    • Expand the sample for configurations that pass the coarse screening, reducing wasted consumption;
    • Context trimming: feed only files and dependency lists related to the change, rather than the entire repository;
    • Caching and reuse: static analysis results for the same repository can be reused, avoiding repeated reasoning;
    • Set dual limits on turns and budget to prevent a single question from spiraling out of control.

    7. How to Read Common Conclusions Correctly

    When facing headlines like “a model ranks first in recall”, it is recommended to verify in four steps: first, look at the question source and timing; second, look at whether it is pooled recall or stable hit rate; third, look at whether cost normalization was done; fourth, look at the sample size and significance. After these four steps, most exaggerated conclusions automatically downgrade to “a phased observation under specific settings”.

    In real code audit practice, the gap between frontier closed-source models and open-source or domestic models is narrowing, but the cost difference remains significant. The rational approach is not to chase a single ranking, but to build your own evaluation set and tiered scheduling strategy, forming a closed loop among model capability, budget constraints, and manual review. This both avoids being led by leaderboards and allows AI to be truly and stably embedded in the R&D security process.