How repeated sampling improves vulnerability detection

Published on Nov 2, 2026

Introduction

Attackers are using AI models to find and exploit vulnerabilities [1]. An attacker only needs to find one exploitable vulnerability with a high payoff. Defenders need to find as many as they can, in every repository, every time the code changes. To win, defenders must use vulnerability scanners that have high coverage and don’t miss vulnerabilities that an attacker would find.

LLMs are probabilistic: running the same model on the same code can find different vulnerabilities each time it runs. We built controls into our product to make agent scans more consistent. However, we can also take advantage of this randomness. Each LLM agent gets new findings, so running them several times on the same repository and combining the results increases coverage (typically called Best of N).

We found running a cheap model several times finds more vulnerabilities than running an expensive model once (we can likewise increase recall for expensive models by running them multiple times). On a representative subset of dfbench detection tasks, five runs of DeepSeek v4.1 Flash find about 71% of the known vulnerabilities, up from about 52% for a single run. That is around the recall (the percent of known vulnerabilities we found) of the strongest published models (like Mythos 5) at a tenth of their cost or less.

Recall vs. cost

Recall

20% 30% 40% 50% 60% 70% 80% $0.30 $1 $3 $10 $30 $100 1 run 5 runs DeepSeek v4.1 Flash 15 runs 1 run GLM 5.3 Flash 5 runs 1 run GPT 5.6 Luna high 5 runs 1 run GPT 5.6 Luna medium 5 runs Mythos 5 GPT 5.6 Sol Opus 5.5 dfs-large1

Cost per task (log)

Figure 1: Recall against cost per repository on a representative 30-task subset of dfbench detection tasks. Each line shows one to five runs of the same model; the DeepSeek v4.1 Flash line extends to 15 runs. Faded points are published dfbench results, one per model at its high reasoning effort.

Recall keeps rising with the log of cost until a model starts to plateau, the same pattern that repeated sampling shows in coding and math [2]. GPT 5.6 Luna high flattens after about three runs, while DeepSeek v4.1 Flash and GLM 5.3 Flash are still climbing at five. Extending DeepSeek to 15 runs raises recall from 71% at five runs ($4.24 per task) to 80% at about $13 per task. For DeepSeek, each doubling of runs up to eight adds about 8 points of recall; going from eight to fifteen adds about 5. So more runs still help, but with diminishing returns.

Keeping false positives down

The problem is that more runs also mean more false positives and lower precision (the percent of findings that are real vulnerabilities).

To keep false positives down, we have an agent review / deduplicate findings across runs, giving each one a confidence from 0 to 100 for how likely it is to be real, and keep only findings above a confidence cutoff.

Precision vs. recall at confidence 50

Precision

20% 30% 40% 50% 60% 20% 30% 40% 50% 60% 70% 5 runs DeepSeek v4.1 Flash 1 run · cutoff 50 Opus 5.5 Gemini 3.8 Flash GPT 6 Luna GPT 5.6 Luna Grok 4.7 Mythos 5 GPT 5.6 Sol GPT 6 Sol dfs-large1

Recall

Figure 2: DeepSeek v4.1 Flash on dfbench validation tasks (27 tasks), keeping findings with confidence cutoff of at least 50 (arbitrarily chosen from 0 to 100). The line runs from one run to five runs.

With the approach above, we find that more runs generally raise both recall and precision, but not always. From one to four runs, DeepSeek v4.1 Flash increases recall, but not at the fifth run. We find this is because more information to the aggregator usually helps it calibrate confidence better, until too much information “distracts” the model.

We arbitrarily chose a confidence cutoff of 50%, but a better way to choose it is finding the right balance between recall and precision you want, and choosing accordingly.

In the following graph, we see how modifying the cutoff changes that balance. A high cutoff leads to higher precision while a lower cutoff produces higher recall.

Precision vs. recall at every confidence cutoff

Precision

20% 40% 60% 80% 100% 0% 10% 20% 30% 40% 50% 60% 70% 80% Opus 5.5 Gemini 3.8 Flash GPT 6 Luna GPT 5.6 Luna Grok 4.7 Mythos 5 GPT 5.6 Sol GPT 6 Sol dfs-large1 90 80 50 20 0 DeepSeek v4.1 Flash 1 run 90 80 50 20 0 DeepSeek v4.1 Flash 3 runs

Recall

Figure 3: DeepSeek v4.1 Flash on the dfbench validation tasks at every confidence cutoff. Numbers on each line mark cutoffs 20, 50 and 80.

We also see here that more runs can significantly increase recall while maintaining precision. For example, at the 50% and 20% confidence cutoffs, recall increases by over 20% from 1 to 3 runs while precision also increases.

Also, when we control for recall (for example at around 35%), we see that we can increase precision by 25% from the 20% confidence cutoff of 1 run to 80% confidence cutoff of 3 runs. This is because doing more runs gives us more vulnerability candidates, so we can more aggressively filter to the candidates that we are more confident about, letting us increase precision while maintaining recall.

Continuing the work

Repeated sampling is a simple way to increase recall, and having extra runs can also increase precision while controlling for recall. It lets a cheap model match frontier models for a fraction of the cost.

We’re excited to keep making vulnerability discovery cheaper with higher coverage for defenders.

References

[1] Anthropic, “Disrupting an AI-orchestrated cyber espionage campaign,” 2025.

[2] B. Brown, J. Juravsky, R. Ehrlich et al., “Large Language Monkeys: Scaling Inference Compute with Repeated Sampling,” 2024.