Dilution Curves for Silent Vulnerability-Fix Detectors

Many security patches in open-source software ship quietly. A developer fixes the flaw under a message like "cleanup," and the formal advisory arrives weeks later: an average of 77 days after the fix commit, according to Sun et al.. Tools that flag these "silent fixes" early could shrink that window. Every such tool, however, scores the commit, and a commit is a bundle. A 14-line security fix (the median Rust fix size in Zheng et al.) often arrives packed alongside hundreds of lines of unrelated refactoring. Neuroscientists face the same problem. A brain-imaging voxel averages hundreds of thousands of neurons, so opposing responses can cancel (Smirnakis (2001)) and unrelated responses can merge into an illusory composite (Zhang et al. (2017)). Their remedy for untestable pooled signals is to build mixtures whose contents are known and ask whether the analysis recovers them.

We propose applying that logic to vulnerability-fix detection. We will build a controlled benchmark that takes verified security-fix hunks (a hunk is one contiguous block of changed lines in a diff) and mixes them into real benign commits at known dilution ratios. From this we measure a dilution curve for each detector: how its score decays as security content becomes a smaller share of the commit. We also measure a companion false-integration rate: how often bundles of harmless bug fixes get flagged as security fixes. We then test whether a detector trained to be invariant to added benign hunks keeps its accuracy on real, tangled commits. The central claim is that current commit-level evaluations hide a large, measurable sensitivity to tangling, and that this sensitivity, not raw classifier accuracy, is what limits early detection of the tangled fixes that sit longest before an advisory is issued.

Why this gap is real

The silent-fix literature disagrees about granularity without ever measuring it directly. VulFixMiner fine-tunes CodeBERT on file changes and pools them into one commit vector, detecting 49% of fixes within 5% of inspected lines of code. The authors themselves note that this pooling loses fine-grained context. CoLeFunDa argues that commit-level pooling is contaminated by tangled changes and moves to function-level program slices. It reports 11–14% gains over VulFixMiner on effort-aware metrics, but it admits it cannot handle cross-function dependencies. Fixseeker shows that over 70% of fixes span multiple hunks and that 93% of those hunks are structurally or semantically correlated. It models these links with hunk-correlation graphs at a cost of 12–31 seconds per commit. DiverseVul supplies the most damaging evidence: labels derived from fix commits are only about 60% accurate because non-security functions in the same commit get labeled vulnerable, and models collapse from about 49% F1 to about 9.4% F1 on unseen projects.

These papers motivate the proposal, because each presupposes an answer to how much tangling hurts. None of them varies tangling while holding the security content fixed. Their headline numbers therefore mix two quantities: detector quality, and the tangling distribution of the test set. Fixseeker is the closest prior work. It changes the model's unit of analysis from commits to correlated hunks. We change the evaluation's unit of analysis, by controlling what is mixed into a commit. We also test whether an explicit invariance objective beats Fixseeker's graph structure at resisting that mixing.

Core claim and mechanism

We make two claims. The first is empirical. Commit-level detectors, including text-based transformer models such as VulFixMiner and the CodeBERT–BART model of Sun et al., will show steep dilution curves. Their scores will fall well below their clean-fix scores once benign content exceeds a few times the size of the fix. They will also show non-trivial false-integration rates.

The second concerns the method. We model a commit $C$ as a set of hunks with per-hunk security probabilities $p_i$, predicted by a shared hunk encoder. The commit score is their noisy-OR:

$$s(C) = 1 - \prod_{i \in C} (1 - p_i),$$

which says a commit is a security fix if any hunk is. Correlated hunks are first merged into a single unit using Fixseeker-style data-flow links, but only within the flagged candidate set. Training adds a dilution-invariance penalty:

$$\mathcal{L} = \mathrm{BCE}(s(C), y) + \lambda\, \big| s(C) - s(C \cup B) \big|.$$

Here $y$ is the commit label, $B$ is a set of hunks drawn from a verified non-security commit, and $\lambda$ weights the penalty. This separation of "where the signal is" from "what the signal is" borrows its spirit from the factorized spatial-mask and feature readout of Khosla et al.. That readout learned retinotopic masks without spatial supervision. We reuse the idea, not the architecture.

Research program

Tangling taxonomy. The benchmark is only credible if its mixtures look like real tangling, so the first step is a qualitative study. Using the human–model coding protocol of Dai et al., we will inductively code the non-security changes that co-occur with real fixes in Fixseeker's 11,900 vulnerability-fixing commits. That protocol has a human craft worked examples, a language model code the bulk of the data, and both refine a shared codebook. Dai et al. reached Cohen's κ of 0.81 on security-adoption narratives against 0.77 human–human. Our data are diffs and commit messages rather than survey answers, so whether that agreement transfers is itself something we test. We will run an open-weight model locally, in line with the privacy concern the file raises about proprietary APIs. The resulting themes will be things like formatting sweeps, dependency bumps, test additions, and unrelated bug fixes. We use their empirical frequencies and sizes as the sampling distribution for $B$, which keeps the simulation from being an arbitrary stress test.

Benchmark construction. Security hunks come from the HCG dataset (six languages) and the CoLeFunDa Java dataset (1,436 fixes). Benign donors come from CoLeFunDa's 841,118 non-fix commits and Sun et al.'s 1.6-million-commit pool. We mix at dilution ratios (benign lines to fix lines) from 0 to about 50, matching language and repository where possible. False-integration probes bundle two or three verified non-security bug fixes.

Hunk-level ground truth on real commits. Synthetic mixtures are not enough, so we will also annotate which hunks in real tangled fixes carry the security change. This follows an explicit two-stage design. A pilot of roughly 100 commits, coded by two security annotators, estimates agreement and the effect size between the invariance-trained and plain models. Rater severity is corrected with the item-response-theory approach of Casabianca & Beiting-Parrish. The confirmatory set is then sized from the pilot's variance and preregistered. This addresses the weakness of VulFixMiner's 82-commit audit, which had no rater model and no confirmatory follow-up.

Latency link. On Sun et al.'s data, which carries commit-to-advisory lag, we test whether a commit's tangling degree predicts longer lag. A positive result would tie dilution sensitivity directly to the exposure window.

Baselines

The naive reference point is a commit-level CodeBERT classifier with mean pooling over the whole diff, trained on the raw commit labels with no dilution augmentation. Every dilution curve is reported relative to this model.

VulFixMiner is the canonical commit-pooling detector. It reports 49% of fixes found at 5% inspected lines of code on its Java/Python data. CoLeFunDa is the function-level alternative. It reports 11–14% CostEffort and Popt gains over VulFixMiner but no absolute F1 for this setting, as far as the file shows.

The strongest competitor is Fixseeker, which reports 0.8404 F1 on balanced data and a 32.4% F1 improvement over baselines at a 1:25 imbalance. It is strongest because its correlation graph could plausibly ignore uncorrelated benign hunks by construction. For cross-project reference we cite DiverseVul's 47.15% within-dataset F1 for NatGen and its ~9.4% unseen-project F1. Sun et al.'s 0.89 AUC anchors the text-and-code transformer family.

All models are retrained on identical splits with project-disjoint test sets and the same hyperparameter-search budget. Fixseeker receives its full static-analysis pipeline, and its per-commit runtime is reported alongside ours.

Two results count as beating Fixseeker. The first is a significantly flatter dilution curve, measured as the slope of commit score against log dilution ratio, together with lower false integration at equal clean-fix F1. The second is equal robustness at a fraction of its compute.

The key ablation removes the invariance penalty, keeping the same noisy-OR architecture. A second ablation replaces noisy-OR with learned attention pooling. Together these isolate whether robustness comes from the training objective or from the pooling rule.

Why not just…?

Why not just use attention-based pooling over hunks, which already learns to ignore irrelevant ones? This is a real threat, because attention pooling might learn much of what the invariance penalty enforces. The ablation settles it. If attention pooling without augmentation matches our model's dilution slope, the methodological contribution shrinks to the benchmark and the measured fragility of existing tools. We would report that as the finding.

Why not just use Fixseeker, since its hunk graphs already model multi-hunk structure? Fixseeker models correlations among hunks, but nothing in its reported evaluation shows how it behaves when uncorrelated benign hunks are added, and its cost of 12–31 seconds per commit limits its use on streams of millions of commits. It may prove robust. If so, the benchmark confirms that robustness for the first time, and our contribution becomes a cheap first-stage filter that matches Fixseeker's robustness on the flagged subset.

Why not just prompt a long-context language model with the full diff? DiverseVul found that GPT- and T5-family models still top out near 47% F1 in-distribution and near 9.4% F1 on unseen projects. Nothing in the file shows long context fixes tangling. We include a prompted open-weight model as an extra curve rather than assume it fails.

Why not just read commit messages? VulFixMiner excluded messages because silent fixes are deliberately described as routine changes. Our benchmark keeps donor messages intact, so any message-based shortcut would show up as a flat but uninformative curve.

Decisive checks

The proposal succeeds if three things hold. First, existing detectors' scores must fall substantially with dilution on the synthetic benchmark. Second, the invariance-trained model must preserve clean-fix F1 while flattening that curve. Third, and most important, the synthetic ranking must predict the ranking on the confirmatory, IRT-corrected real hunk annotations. If the synthetic and real rankings disagree, the benchmark is not a valid proxy, and we will say so. If tangling degree also predicts longer advisory lag in Sun et al.'s data, dilution robustness becomes a direct lever on the vulnerability exposure window.