berteuraika commited on
Commit
2a0b0fb
·
verified ·
1 Parent(s): ba5ab89

Add: The Interprocedural Ceiling — replication & boundary analysis responding to VulnLLM-R (arXiv:2512.07533)

Browse files
README.md ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ pretty_name: 'The Interprocedural Ceiling: a response to VulnLLM-R'
6
+ tags:
7
+ - vulnerability-detection
8
+ - security
9
+ - llm
10
+ - reproducibility
11
+ - replication
12
+ - primevul
13
+ - interpretability
14
+ task_categories:
15
+ - text-classification
16
+ ---
17
+
18
+ > **Technical report — independent replication & boundary analysis (draft).**
19
+ > This repository is a response to **Nie et al., _VulnLLM-R: Specialized Reasoning LLM with Agent Scaffold for Vulnerability Detection_** ([arXiv:2512.07533](https://arxiv.org/abs/2512.07533), 2025).
20
+ > It **reproduces** that paper's in-distribution result and then delimits where single-function vulnerability detection meets an *informational* ceiling on out-of-distribution, paired data.
21
+ > Model under study: [`Euraika/VulnLLM-R-7B-GGUF`](https://huggingface.co/Euraika/VulnLLM-R-7B-GGUF) · Benchmark: [PrimeVul](https://arxiv.org/abs/2403.18624).
22
+ > Every empirical number is reproducible from the `phase0_*` data and `make_figures.py` in this repo. Citation metadata for the two central works has been verified against arXiv; remaining references are canonical.
23
+
24
+ # The Interprocedural Ceiling: A Replication and Boundary Analysis of Single-Function Vulnerability Detection with VulnLLM-R-7B
25
+
26
+ *A response to Nie et al., "VulnLLM-R: Specialized Reasoning LLM with Agent Scaffold for Vulnerability Detection" (arXiv:2512.07533, 2025).*
27
+
28
+ **Author's draft — prepared for a Findings / short-paper venue.**
29
+
30
+ ---
31
+
32
+ ## Abstract
33
+
34
+ Specialized reasoning language models have recently reported strong results on function-level vulnerability detection, with VulnLLM-R-7B — a Qwen2.5-7B-Instruct model fine-tuned with an agent scaffold — achieving approximately 80% F1 on its curated benchmark. We independently reproduce that in-distribution result and then ask a different question: does the capability transfer to hard, out-of-distribution code under the balanced pairwise protocol of PrimeVul, where a model must correctly judge both a vulnerable function and its minimally-patched twin? Serving the released model locally in 8-bit and evaluating blind on 564 PrimeVul pairs, we find pair-correct accuracy collapses to 17.4% (per-function F1 44.7), close to the floor of the metric. We then attempt to raise this number through five orthogonal interventions — verdict-only LoRA, self-taught reasoning distillation, frontier-teacher reasoning distillation, a sevenfold scaling of that distillation, and substitution of a 3.8×-larger base model. None reliably exceeds the base; the best (frontier-teacher distillation at 212 traces) reaches 20.0% before *regressing* to 14.2% when scaled, and the larger base scores 0.0%. To explain this capacity wall, we introduce a two-part decidability probe. A frontier oracle, shown both twins of each pair, judges that only 29.3% of pairs are decidable from the vulnerable function's own text; 70.7% require information defined outside the function (caller-established bounds, externally-defined types, global or configuration state). An off-the-shelf static analyzer run on the same functions recovers a directional signal on just 2% of pairs. We conclude that single-function detection has an information-theoretic ceiling near 29% pair-correct on distribution-shifted code, that this ceiling — not model capacity — bounds every in-function method, and that the honest deployment posture is high-precision triage over the decidable minority rather than uniform per-function verdicts. Our findings are consistent with, rather than contradictory to, the original paper: they delimit where its reported capability does and does not extend.
35
+
36
+ ---
37
+
38
+ ## 1. Introduction
39
+
40
+ Large language models fine-tuned for code have become a prominent tool for automated vulnerability detection, and a recent line of work has shown that domain-specialized reasoning models can substantially outperform general-purpose baselines on function-level classification. The VulnLLM-R system exemplifies this trend, pairing a 7-billion-parameter base model with a structured reasoning procedure and an agent scaffold to report approximately 80% F1 on its evaluation set (arXiv:2512.07533). Results of this magnitude invite an obvious and consequential question for practitioners: if a 7B model can detect vulnerabilities this well, is function-level detection effectively solved for local, privacy-preserving deployment?
41
+
42
+ This paper argues that the answer depends entirely on the evaluation distribution, and that the gap between benchmark performance and deployable capability is not a matter of degree but of kind. Our motivation is practical. A security engineer who downloads the released weights and runs them over unfamiliar C or C++ functions is operating out-of-distribution relative to the model's training curation, and is typically interested in a stringent question — can the model tell a genuinely vulnerable function from a nearly-identical safe one — rather than the marginal per-function accuracy that dominates many benchmark scores. The PrimeVul benchmark was constructed precisely to expose this gap: it pairs each vulnerable function with its minimally-patched counterpart and rewards a model only when it judges both correctly, a protocol that punishes the label priors and superficial pattern-matching that inflate single-function metrics.
43
+
44
+ We make three contributions. First, we confirm that the original paper's headline result reproduces: under the authors' own prompt and task formulation, the released model recovers roughly 80% F1, so the low numbers we report elsewhere reflect distribution shift and protocol, not a failure to reproduce. Second, we show through five independent interventions — spanning supervised fine-tuning, reasoning distillation from a frontier teacher, data scaling, and a substantial increase in base-model size — that the out-of-distribution pairwise ceiling is remarkably rigid, and that additional in-function training or capacity does not move it. Third, and most importantly, we explain why: using a frontier oracle with access to the ground-truth patch, we quantify how much of the deciding vulnerable-versus-patched signal actually resides inside the function being judged, and find that it is a minority. The remainder is interprocedural — it lives in callers, in externally-defined types, or in program state that no single-function method can observe. This reframes the problem from "the model is not good enough" to "the information is not present," with direct implications for how such models should be deployed and evaluated.
45
+
46
+ ## 2. Background and Related Work
47
+
48
+ Function-level vulnerability detection has historically been benchmarked on datasets whose vulnerable and non-vulnerable examples are drawn from different functions, allowing models to exploit spurious correlations between surface features and labels. PrimeVul (Ding et al., 2024) responds to this weakness with a paired protocol: each vulnerable function is matched to the function that results from applying only the security patch, so that the two members of a pair differ minimally and share nearly all surface features. The associated pair-wise metrics — most stringently, the pair-correct rate, in which both members must be classified correctly — isolate genuine discrimination from label-prior exploitation. It is against this protocol that we evaluate.
49
+
50
+ VulnLLM-R builds on Qwen2.5-7B-Instruct (Qwen Team, 2024) and a structured chain-of-thought procedure, reporting strong results on its own curated data. Our interventions draw on established adaptation techniques: low-rank adaptation for parameter-efficient fine-tuning (Hu et al., 2021), self-taught reasoning in which a model's own correct-verdict rationales become training targets (Zelikman et al., 2022), and self-consistency as a test-time aggregation strategy (Wang et al., 2022). Our diagnostic contribution — measuring the fraction of pairs whose deciding signal is intra- versus inter-procedural — is, to our knowledge, a novel way of bounding the achievable performance of any single-function detector on a paired benchmark, and it complements static-analysis literature that has long distinguished intra- from inter-procedural dataflow.
51
+
52
+ ## 3. Methods
53
+
54
+ ### 3.1 Model and serving
55
+
56
+ We evaluate the publicly released VulnLLM-R-7B weights, a fine-tune of Qwen2.5-7B-Instruct. To reflect a realistic local-deployment setting, we serve the model through Ollama with 8-bit (Q8_0) quantization on an Apple M5 Pro with 48 GB of unified memory using the Metal backend. Unless otherwise noted, inference uses a temperature of 0.2 and the model's native ChatML formatting with the four-step reasoning procedure specified by the original authors, and a 32,768-token context window. Reproduction experiments (Section 4.1) additionally use the authors' exact prompt and candidate-CWE task framing.
57
+
58
+ ### 3.2 Benchmark and metrics
59
+
60
+ Out-of-distribution evaluation uses the `test_paired` split of the ASSERT-KTH distribution of PrimeVul: 564 vulnerable/patched pairs (1,128 functions), balanced by construction and overwhelmingly C and C++ (predominantly Chromium, TensorFlow, and similar large projects). We report per-function accuracy, precision, recall, and F1, and the PrimeVul pair-wise outcomes, of which the primary quantity is the pair-correct rate: the fraction of pairs in which the vulnerable function is judged vulnerable and its patched twin judged safe. Every judgment is blind — the model receives one function at a time with no indication of its pair membership or ground-truth label — and verdicts are parsed from the model's structured final line. All comparisons within an experiment use a fixed harness and identical decoding.
61
+
62
+ ### 3.3 Improvement interventions
63
+
64
+ We attempted to raise pair-correct accuracy through five interventions, each holding the base model and serving stack fixed except where noted. The first, verdict-only supervised fine-tuning, trained a LoRA adapter on 3,000 PrimeVul-training functions labeled with their correct verdicts. The second, self-taught reasoning distillation, sampled the base model's own reasoning traces on training functions and retained only those reaching the correct verdict as supervision targets. The third, frontier-teacher reasoning distillation, used a frontier model (GPT-5.6-Sol at maximal reasoning effort, accessed via a command-line interface) to write correct diagnostic reasoning for functions the base model misjudged, distilling those rationales into a LoRA adapter; a fourth intervention scaled this teacher set approximately sevenfold, from 212 to 1,307 traces. Adapters were trained with mlx-lm, fused into the base weights, converted to GGUF, and served identically to the base. The fifth intervention replaced the base entirely with a general-purpose model of 3.8× the parameter count (Qwen3.6-27B) under the same blind protocol.
65
+
66
+ ### 3.4 Decidability probe
67
+
68
+ To explain the observed ceiling, we designed a two-part probe on 100 randomly selected pairs. The first part measures *decidability*: a frontier oracle (GPT-5.6-Sol at maximal reasoning effort) is shown *both* members of a pair — so that the security-relevant difference between them is fully observable — and asked to classify whether the vulnerability is determinable from the vulnerable function's own text (labeled INTRA: the unsafe operation and the missing or insufficient guard are both visible within the function) or whether a correct judgment requires information defined outside the function (labeled INTER: a caller-established bound, an externally-defined type or size, or global and configuration state). The oracle returned a classification and a short justification naming the specific deciding operation or the specific external fact required. The second part measures the *differential rate* of a concrete extractor: we ran the cppcheck static analyzer (version 2.21, with all checks enabled and common typedefs stubbed to compensate for absent headers) on both members of each pair and recorded how often its security-relevant findings differed between twins, and in particular how often they were *directional* — present on the vulnerable function and absent on its patch. The differential rate upper-bounds the discriminative signal that this off-the-shelf tool could contribute, and is by construction no larger than the decidable fraction.
69
+
70
+ ## 4. Results
71
+
72
+ ### 4.1 The reported result reproduces in-distribution
73
+
74
+ Under the original authors' prompt and task formulation, the released model recovers approximately 81% accuracy and 80% F1 on a curated in-distribution sample, in line with the paper's claims and confirming that the weights and our serving stack are faithful. This reproduction is essential context for everything that follows: the sharply lower numbers reported below are a consequence of distribution shift and evaluation protocol, not of an inability to reproduce the original work. The left panel of Figure 2 places the two regimes side by side; moving from the authors' setup to a blind out-of-distribution evaluation reduces accuracy from 81% to 53% and F1 from 80 to 44.7.
75
+
76
+ ### 4.2 Pairwise discrimination collapses out-of-distribution
77
+
78
+ Evaluated blind on the 564 PrimeVul pairs, the base model achieves a pair-correct rate of 17.4%, with per-function accuracy of 53.0% and F1 of 44.7. A pair-correct rate near 17% indicates that, when confronted with a vulnerable function and its minimally-different patch, the model usually cannot assign the two the opposite verdicts they require. Per-function accuracy barely above 50% on a balanced set tells the same story from the pointwise side: the model's apparent competence in-distribution does not survive the removal of the label priors and surface cues that the paired protocol neutralizes. This is the number that all subsequent interventions attempt to raise.
79
+
80
+ ### 4.3 The generalization boundary is mechanism novelty, not label novelty
81
+
82
+ Before attempting to move the ceiling, we characterized what the model had actually learned, to avoid misattributing its limits. Two findings, summarized in the right panel of Figure 2, are relevant. First, an untrained CWE label whose underlying mechanism the model *had* seen transferred fully: functions labeled with buffer-family CWEs absent from training were classified at 80% accuracy, slightly above the 72% observed on trained buffer CWEs, because they invoke the identical bounds-checking reasoning. The model therefore did not merely memorize CWE labels. Second, and in contrast, genuinely novel *mechanisms* degraded substantially: on a balanced set of never-seen mechanism classes, accuracy fell from 85% to 70% and F1 from 87 to 64, driven almost entirely by a recall collapse from 100% to 53.3%. The model retains specificity on unfamiliar vulnerability logic but loses sensitivity, under-detecting what it has not been taught. This establishes that the model learned transferable reasoning rather than surface patterns, and locates its fragility in recall on unfamiliar mechanisms — a boundary distinct from, and milder than, the out-of-distribution collapse of Section 4.2.
83
+
84
+ ### 4.4 No intervention beats the wall
85
+
86
+ Figure 1 reports the pair-correct rate for the base model and all five interventions on the same protocol. Verdict-only fine-tuning (17.2%) and self-taught reasoning distillation (17.1%) were statistically indistinguishable from the base. Frontier-teacher reasoning distillation produced the only improvement, reaching 20.0% from 212 carefully-targeted traces — but scaling the same procedure sevenfold to 1,307 traces did not extend the gain; it *reversed* it, dropping pair-correct to 14.2% while raising recall, the signature of a decision threshold sliding toward indiscriminate positives rather than of improved discrimination. Most tellingly, replacing the base with a general-purpose model of 3.8× the size produced a pair-correct rate of 0.0%, accompanied by a high rate of unparseable outputs; additional capacity, absent task-specific grounding, made discrimination worse rather than better. The consistent picture across parameter-efficient tuning, reasoning distillation, data scaling, and model scaling is that the ceiling is a property of the task as posed, not of the model's capacity to fit it.
87
+
88
+ ### 4.5 The signal is mostly outside the function
89
+
90
+ The decidability probe explains the wall directly, and its result is shown in Figure 3. Of 99 scored pairs, the frontier oracle judged only 29.3% to be decidable from the vulnerable function's own text; the remaining 70.7% required information defined outside the function. The oracle's justifications for the interprocedural majority are concrete and consistent: whether a caller had already bounded an argument ("actual capacity of caller-provided szLine versus the strcpy output"), the externally-defined size or semantics of a parameter ("requires external BuildTensorShape semantics for malformed attacker-controlled dimensions"), or invariants established elsewhere in the program ("whether pad_width_ is prevalidated during construction is not visible in Compute"). Because these facts are absent from the function under judgment, no method restricted to that function — regardless of its training or size — can recover them. The 29.3% decidable fraction is therefore the ceiling on pair-correct accuracy for any single-function detector on this distribution, and it aligns closely with the 25–30% cap that a debate of five independent models had estimated a priori.
91
+
92
+ The second part of the probe shows that even the decidable minority is not cheaply recoverable by conventional tooling. Running cppcheck on the same functions produced findings that differed between twins in only 5% of pairs and were *directional* — flagging the vulnerable member and clearing its patch — in just 2%. On 65% of pairs the analyzer emitted the identical finding on both members, contributing no discriminative signal, and on 30% it flagged neither. An off-the-shelf intra-procedural analyzer applied to header-less functions from large C++ projects thus recovers almost none of even the in-function signal; the decidable pairs are decidable by semantic reasoning, not by pattern-matching linters. This closes the argument: the interprocedural majority is unrecoverable in principle by single-function methods, and the intra-procedural minority is not recovered in practice by the cheap tool most often proposed to supply it.
93
+
94
+ ## 5. Discussion
95
+
96
+ Our results are best read not as a refutation of the original paper but as a demarcation of its scope. VulnLLM-R-7B does what it claims on the distribution it was built for, and it learned transferable reasoning rather than brittle pattern-matching, as its full transfer to untrained labels of familiar mechanisms shows. What our experiments add is a precise account of where that capability stops. When the evaluation shifts to distribution-shifted code and to a protocol that demands genuine vulnerable-versus-patched discrimination, performance falls to a rigid ceiling that neither fine-tuning, reasoning distillation, data scaling, nor a near-quadrupling of model size can raise. The decidability probe identifies the cause as informational rather than representational: roughly seven in ten decisions depend on facts that are simply not present in the function being judged.
97
+
98
+ This reframing carries a clear methodological implication. Reporting single-function detection performance without a paired or otherwise prior-controlled protocol risks conflating label-prior exploitation with capability, and reporting it in-distribution risks overstating deployability. The pair-correct rate on distribution-shifted pairs is a demanding but honest summary, and by that measure the achievable ceiling for local single-function models is near 29% — a number practitioners should hold in mind when a benchmark advertises 80%. It also clarifies why the field's most promising direction is architectural rather than parametric: to move the ceiling one must supply the missing interprocedural context — callers, resolved types, reaching definitions — which necessarily means ingesting more of the program than a single function. The original paper's agent scaffold is precisely such a mechanism, and our results can be read as quantitative evidence for why scaffolding, rather than a larger model or more in-function data, is the lever that matters.
99
+
100
+ Finally, the decidability decomposition suggests a deployment posture that is honest about the ceiling rather than defeated by it. Because the decidable minority is identifiable in principle — these are the functions whose unsafe operation and missing guard are both locally visible — a practical system can route for high-precision triage: emit confident verdicts where the signal is in-function and abstain, flagging "insufficient context," where it is not. Such a system trades coverage for trustworthiness and aligns the model's outputs with the information actually available to it, which is preferable to uniform per-function verdicts that are reliable on only a third of cases. We regard this as the constructive conclusion of an otherwise negative result.
101
+
102
+ ## 6. Limitations
103
+
104
+ Several caveats bound our conclusions. Our serving stack uses 8-bit quantization and a single decoding configuration; although we matched all within-experiment comparisons, absolute numbers could shift modestly under full precision or alternative sampling. The decidability probe relies on a frontier model as an oracle, and although it was given the ground-truth patch and asked a narrowly-scoped structural question, its INTRA/INTER labels are judgments rather than proofs; a human-expert audit of a subset would strengthen the estimate, and the single unparsed case was excluded rather than adjudicated. The differential-rate measurement used one analyzer (cppcheck) on the C and C++ majority and did not include the Java minority or a heavier interprocedural tool such as CodeQL configured with a built project, which would recover more signal at substantially greater cost; our claim is specifically about cheap, locally-runnable, single-function static analysis. Our interventions, though spanning several distinct families, do not exhaust the space — notably, we did not build and evaluate the full repository-context scaffold that our own analysis identifies as the only mechanism with headroom, and we did not correct for position bias by evaluating each pair in both orderings. Finally, all results concern one model on one paired benchmark; the interprocedural-ceiling hypothesis should be tested on additional detectors and datasets before being treated as general.
105
+
106
+ ## 7. Conclusion
107
+
108
+ We reproduced the reported in-distribution strength of VulnLLM-R-7B and then showed that its capability does not survive the transition to blind, distribution-shifted, pairwise evaluation, where pair-correct accuracy sits at 17.4% and resists every attempt to raise it — verdict-only tuning, self- and frontier-distilled reasoning, sevenfold data scaling, and a 3.8×-larger base alike. A decidability probe explains the wall: only 29.3% of pairs are decidable from the function's own text, and an off-the-shelf analyzer recovers a directional signal on just 2%. The ceiling on single-function detection is therefore informational, not a matter of model capacity, and it is bounded near 29% on this distribution. The path past it is to supply the interprocedural context the task withholds — the very role of an agent scaffold — and, short of that, to deploy the model as a high-precision triage tool over the decidable minority rather than as a uniform per-function oracle. We offer these findings in the same spirit as the original work: as a sharpening of where reasoning-specialized detectors succeed, and of where the problem, not the model, sets the limit.
109
+
110
+ ## References
111
+
112
+ Ding, Y., Fu, Y., Ibrahim, O., Sitawarin, C., Chen, X., Alomair, B., Wagner, D., Ray, B., & Chen, Y. (2024). *Vulnerability Detection with Code Language Models: How Far Are We?* (PrimeVul). arXiv:2403.18624. To appear, ICSE 2025.
113
+
114
+ Hu, E. J., Shen, Y., Wallis, P., Allen-Zhu, Z., Li, Y., Wang, S., Wang, L., & Chen, W. (2021). *LoRA: Low-Rank Adaptation of Large Language Models.* arXiv:2106.09685.
115
+
116
+ Qwen Team (2024). *Qwen2.5 Technical Report.* arXiv:2412.15115.
117
+
118
+ Nie, Y., Li, H., Guo, C., Jiang, R., Wang, Z., Li, B., Song, D., & Guo, W. (2025). *VulnLLM-R: Specialized Reasoning LLM with Agent Scaffold for Vulnerability Detection.* arXiv:2512.07533.
119
+
120
+ Wang, X., Wei, J., Schuurmans, D., Le, Q., Chi, E., Narang, S., Chowdhery, A., & Zhou, D. (2022). *Self-Consistency Improves Chain of Thought Reasoning in Language Models.* arXiv:2203.11171.
121
+
122
+ Zelikman, E., Wu, Y., Mu, J., & Goodman, N. D. (2022). *STaR: Bootstrapping Reasoning With Reasoning.* arXiv:2203.14465.
123
+
124
+ ---
125
+
126
+ ## Figures
127
+
128
+ ![Figure 1](figures/fig1_ladder.png)
129
+
130
+ **Figure 1.** Pair-correct accuracy on PrimeVul `test_paired` for the base model and five improvement interventions. The dashed line marks the base ceiling (17.4%). No intervention reliably exceeds it; the best (frontier-teacher distillation) reaches 20.0% before regressing to 14.2% under scaling, and a 3.8×-larger general-purpose base scores 0.0%. (`figures/fig1_ladder.png`)
131
+
132
+ ![Figure 2](figures/fig2_boundary.png)
133
+
134
+ **Figure 2.** (A) Distribution shift: accuracy and F1 fall from the authors' in-distribution setup to a blind out-of-distribution PrimeVul evaluation. (B) Generalization boundary: trained versus novel vulnerability mechanisms, showing that recall collapses from 100% to 53.3% on unfamiliar mechanisms while accuracy and F1 degrade more gently. (`figures/fig2_boundary.png`)
135
+
136
+ ![Figure 3](figures/fig3_ceiling.png)
137
+
138
+ **Figure 3.** The core finding. (A) A frontier oracle, shown both twins, judges 71% of pairs to require interprocedural context and only 29% to be decidable from the function alone — the ceiling for any single-function method. (B) On the same functions, cppcheck yields a directional (usable) signal on only 2% of pairs, emitting the identical finding on both twins in 65% and flagging neither in 30%. (`figures/fig3_ceiling.png`)
figures/fig1_ladder.png ADDED

Git LFS Details

  • SHA256: c1092b2aef3389c9ebc91d4fc67e0a5d17547ff59a88b7957c947b8d28515617
  • Pointer size: 130 Bytes
  • Size of remote file: 46.2 kB
figures/fig2_boundary.png ADDED

Git LFS Details

  • SHA256: fbf3a12933c6cf93fea23361527725cb6d281b0bd79bd386fe87a0ebddf59377
  • Pointer size: 130 Bytes
  • Size of remote file: 56.3 kB
figures/fig3_ceiling.png ADDED

Git LFS Details

  • SHA256: ba69ecd08bd94fd380eed867b550123623a74df1a93bcc1657b8e5e734fe98ce
  • Pointer size: 130 Bytes
  • Size of remote file: 74.8 kB
make_figures.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Generate publication figures from the actual experimental result files."""
3
+ import json, os
4
+ import matplotlib
5
+ matplotlib.use("Agg")
6
+ import matplotlib.pyplot as plt
7
+ from matplotlib.patches import Patch
8
+ import numpy as np
9
+
10
+ FIG = os.path.expanduser("~/vulnllm-bench/paper/figures")
11
+ os.makedirs(FIG, exist_ok=True)
12
+ plt.rcParams.update({
13
+ "font.family": "DejaVu Sans", "font.size": 10,
14
+ "axes.spines.top": False, "axes.spines.right": False, "figure.dpi": 150,
15
+ "axes.titlesize": 11, "axes.titleweight": "bold", "savefig.bbox": "tight",
16
+ })
17
+ # colorblind-safe palette (Okabe-Ito)
18
+ BLUE="#0072B2"; ORANGE="#E69F00"; GREEN="#009E73"; RED="#D55E00"; GREY="#999999"; PURPLE="#CC79A7"; SKY="#56B4E9"
19
+
20
+ # ---------------- Figure 1: the ladder — every lever hits the same wall ----------------
21
+ def fig1():
22
+ labels = ["Base\n(+prompt)", "LoRA v1\nverdict", "LoRA v2\nSTaR", "LoRA v3\nteacher", "LoRA v3\n×7 scaled", "Qwen3.6-27B\n(3.8× base)"]
23
+ pc = [17.4, 17.2, 17.1, 20.0, 14.2, 0.0] # pair-correct %
24
+ colors = [GREY, SKY, SKY, GREEN, ORANGE, RED]
25
+ fig, ax = plt.subplots(figsize=(7.2, 3.7))
26
+ x = np.arange(len(labels))
27
+ bars = ax.bar(x, pc, color=colors, width=0.66, edgecolor="white", linewidth=0.6)
28
+ ax.axhline(17.4, ls="--", lw=1.1, color=GREY, zorder=0)
29
+ ax.text(len(labels)-0.5, 18.1, "base ceiling 17.4%", ha="right", va="bottom", fontsize=8.5, color="#555")
30
+ # random-pairing reference (both-correct by chance ~ 0.5*0.5=25% only if independent&balanced -> but empirical near-chance)
31
+ for b, v in zip(bars, pc):
32
+ ax.text(b.get_x()+b.get_width()/2, v+0.5, f"{v:.1f}", ha="center", va="bottom", fontsize=9, fontweight="bold")
33
+ ax.set_xticks(x); ax.set_xticklabels(labels, fontsize=8.4)
34
+ ax.set_ylabel("Pair-correct (%)"); ax.set_ylim(0, 24)
35
+ ax.set_title("Figure 1. No fine-tuning recipe or larger base beats the single-function wall")
36
+ fig.text(0.5, -0.06, "PrimeVul test_paired, blind, matched harness. Pair-correct = both the vulnerable function and its patched twin judged correctly.",
37
+ ha="center", fontsize=7.6, color="#555")
38
+ fig.savefig(f"{FIG}/fig1_ladder.png"); plt.close(fig); print("fig1 done")
39
+
40
+ # ---------------- Figure 2: in-distribution vs OOD, and the generalization boundary ----------------
41
+ def fig2():
42
+ fig, (axA, axB) = plt.subplots(1, 2, figsize=(7.6, 3.5), gridspec_kw={"width_ratios":[1,1.15]})
43
+ # Panel A: distribution shift
44
+ groups = ["In-distribution\n(authors' setup)", "Out-of-distribution\n(PrimeVul blind)"]
45
+ acc = [81.0, 53.0]; f1 = [80.0, 44.7]
46
+ x = np.arange(len(groups)); w=0.36
47
+ axA.bar(x-w/2, acc, w, label="Accuracy", color=BLUE, edgecolor="white")
48
+ axA.bar(x+w/2, f1, w, label="F1", color=ORANGE, edgecolor="white")
49
+ for xi,a,f in zip(x,acc,f1):
50
+ axA.text(xi-w/2, a+1, f"{a:.0f}", ha="center", fontsize=8.5, fontweight="bold")
51
+ axA.text(xi+w/2, f+1, f"{f:.0f}", ha="center", fontsize=8.5, fontweight="bold")
52
+ axA.axhline(50, ls=":", color=GREY, lw=1); axA.text(1.4, 51, "chance", fontsize=7.5, color="#666", ha="right")
53
+ axA.set_xticks(x); axA.set_xticklabels(groups, fontsize=8.2); axA.set_ylabel("Score (%)"); axA.set_ylim(0,95)
54
+ axA.set_title("A. Distribution shift", fontsize=9.5, loc="left")
55
+ axA.legend(frameon=False, fontsize=8, loc="upper right")
56
+ # Panel B: trained vs novel mechanism (recall is the collapse)
57
+ cats = ["Accuracy", "F1", "Recall"]
58
+ trained = [85.0, 87.0, 100.0]; novel = [70.0, 64.0, 53.3]
59
+ x2 = np.arange(len(cats))
60
+ axB.bar(x2-w/2, trained, w, label="Trained mechanisms", color=GREEN, edgecolor="white")
61
+ axB.bar(x2+w/2, novel, w, label="Novel mechanisms", color=PURPLE, edgecolor="white")
62
+ for xi,t,n in zip(x2,trained,novel):
63
+ axB.text(xi-w/2, t+1.5, f"{t:.0f}", ha="center", fontsize=8.5, fontweight="bold")
64
+ axB.text(xi+w/2, n+1.5, f"{n:.0f}", ha="center", fontsize=8.5, fontweight="bold")
65
+ axB.set_xticks(x2); axB.set_xticklabels(cats, fontsize=8.6); axB.set_ylim(0,112); axB.set_ylabel("Score (%)")
66
+ axB.set_title("B. Novel mechanisms: recall halves", fontsize=9.5, loc="left")
67
+ axB.legend(frameon=False, fontsize=8, loc="lower left")
68
+ fig.suptitle("Figure 2. The model learned transferable reasoning, but recall is fragile off-distribution", fontsize=10.5, fontweight="bold", y=1.02)
69
+ fig.savefig(f"{FIG}/fig2_boundary.png"); plt.close(fig); print("fig2 done")
70
+
71
+ # ---------------- Figure 3: the core finding — where the signal lives ----------------
72
+ def fig3():
73
+ dec = [json.loads(l) for l in open(os.path.expanduser("~/vulnllm-bench/phase0_decide_results.jsonl"))]
74
+ intra = sum(1 for r in dec if r.get("cls")=="INTRA"); inter = sum(1 for r in dec if r.get("cls")=="INTER")
75
+ tot = intra+inter
76
+ diff = [json.loads(l) for l in open(os.path.expanduser("~/vulnllm-bench/phase0_diff_results.jsonl"))]
77
+ cc = [r for r in diff if r.get("lang")=="c" and not r.get("skipped")]
78
+ directional = sum(1 for r in cc if r.get("directional")); both = sum(1 for r in cc if r.get("both_same_flag"))
79
+ neither = sum(1 for r in cc if r.get("neither_flagged")); other = len(cc)-directional-both-neither
80
+
81
+ fig, (axA, axB) = plt.subplots(1, 2, figsize=(7.8, 3.6), gridspec_kw={"width_ratios":[1,1]})
82
+ # Panel A: decidability decomposition (stacked horizontal bar)
83
+ ip = intra/tot*100; xp = inter/tot*100
84
+ axA.barh([0], [ip], color=GREEN, edgecolor="white", label=f"INTRA-procedural {ip:.0f}%")
85
+ axA.barh([0], [xp], left=[ip], color=RED, edgecolor="white", label=f"INTER-procedural {xp:.0f}%")
86
+ axA.text(ip/2, 0, f"{ip:.0f}%", ha="center", va="center", color="white", fontweight="bold", fontsize=11)
87
+ axA.text(ip+xp/2, 0, f"{xp:.0f}%", ha="center", va="center", color="white", fontweight="bold", fontsize=11)
88
+ axA.set_xlim(0,100); axA.set_ylim(-0.6,0.6); axA.set_yticks([]); axA.set_xlabel("Share of 99 PrimeVul pairs")
89
+ axA.set_title("A. Where the vuln↔patch signal lives\n(frontier oracle judgment)", fontsize=9.3)
90
+ axA.legend(frameon=False, fontsize=8.2, loc="upper center", bbox_to_anchor=(0.5,-0.28), ncol=1)
91
+ axA.text(50, 0.48, "29% is the ceiling for ANY\nlocal single-function method", ha="center", fontsize=8, color="#444")
92
+
93
+ # Panel B: what cppcheck actually delivers on the same pairs
94
+ segs = [("Directional\n(usable signal)", directional, GREEN),
95
+ ("Same finding\nboth twins", both, GREY),
96
+ ("Tool blind\n(neither)", neither, "#BBBBBB"),
97
+ ("Other\ndiff", other, ORANGE)]
98
+ names=[s[0] for s in segs]; vals=[s[1] for s in segs]; cols=[s[2] for s in segs]
99
+ y=np.arange(len(segs))[::-1]
100
+ axB.barh(y, vals, color=cols, edgecolor="white")
101
+ for yi,v in zip(y,vals): axB.text(v+0.8, yi, f"{v}%", va="center", fontsize=9, fontweight="bold")
102
+ axB.set_yticks(y); axB.set_yticklabels(names, fontsize=8.2); axB.set_xlim(0,72); axB.set_xlabel("Share of 100 C pairs")
103
+ axB.set_title("B. cppcheck recovers ~2% of it\n(intra-procedural linter, isolated fns)", fontsize=9.3)
104
+ fig.suptitle("Figure 3. The wall is interprocedural: 71% of the signal is outside the function, and the cheap extractor captures almost none of the rest",
105
+ fontsize=9.6, fontweight="bold", y=1.06)
106
+ fig.savefig(f"{FIG}/fig3_ceiling.png"); plt.close(fig); print("fig3 done", intra, inter, directional, both, neither, other)
107
+
108
+ fig1(); fig2(); fig3()
109
+ print("all figures in", FIG)
manuscript.md ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # The Interprocedural Ceiling: A Replication and Boundary Analysis of Single-Function Vulnerability Detection with VulnLLM-R-7B
2
+
3
+ *A response to Nie et al., "VulnLLM-R: Specialized Reasoning LLM with Agent Scaffold for Vulnerability Detection" (arXiv:2512.07533, 2025).*
4
+
5
+ **Author's draft — prepared for a Findings / short-paper venue.**
6
+
7
+ ---
8
+
9
+ ## Abstract
10
+
11
+ Specialized reasoning language models have recently reported strong results on function-level vulnerability detection, with VulnLLM-R-7B — a Qwen2.5-7B-Instruct model fine-tuned with an agent scaffold — achieving approximately 80% F1 on its curated benchmark. We independently reproduce that in-distribution result and then ask a different question: does the capability transfer to hard, out-of-distribution code under the balanced pairwise protocol of PrimeVul, where a model must correctly judge both a vulnerable function and its minimally-patched twin? Serving the released model locally in 8-bit and evaluating blind on 564 PrimeVul pairs, we find pair-correct accuracy collapses to 17.4% (per-function F1 44.7), close to the floor of the metric. We then attempt to raise this number through five orthogonal interventions — verdict-only LoRA, self-taught reasoning distillation, frontier-teacher reasoning distillation, a sevenfold scaling of that distillation, and substitution of a 3.8×-larger base model. None reliably exceeds the base; the best (frontier-teacher distillation at 212 traces) reaches 20.0% before *regressing* to 14.2% when scaled, and the larger base scores 0.0%. To explain this capacity wall, we introduce a two-part decidability probe. A frontier oracle, shown both twins of each pair, judges that only 29.3% of pairs are decidable from the vulnerable function's own text; 70.7% require information defined outside the function (caller-established bounds, externally-defined types, global or configuration state). An off-the-shelf static analyzer run on the same functions recovers a directional signal on just 2% of pairs. We conclude that single-function detection has an information-theoretic ceiling near 29% pair-correct on distribution-shifted code, that this ceiling — not model capacity — bounds every in-function method, and that the honest deployment posture is high-precision triage over the decidable minority rather than uniform per-function verdicts. Our findings are consistent with, rather than contradictory to, the original paper: they delimit where its reported capability does and does not extend.
12
+
13
+ ---
14
+
15
+ ## 1. Introduction
16
+
17
+ Large language models fine-tuned for code have become a prominent tool for automated vulnerability detection, and a recent line of work has shown that domain-specialized reasoning models can substantially outperform general-purpose baselines on function-level classification. The VulnLLM-R system exemplifies this trend, pairing a 7-billion-parameter base model with a structured reasoning procedure and an agent scaffold to report approximately 80% F1 on its evaluation set (arXiv:2512.07533). Results of this magnitude invite an obvious and consequential question for practitioners: if a 7B model can detect vulnerabilities this well, is function-level detection effectively solved for local, privacy-preserving deployment?
18
+
19
+ This paper argues that the answer depends entirely on the evaluation distribution, and that the gap between benchmark performance and deployable capability is not a matter of degree but of kind. Our motivation is practical. A security engineer who downloads the released weights and runs them over unfamiliar C or C++ functions is operating out-of-distribution relative to the model's training curation, and is typically interested in a stringent question — can the model tell a genuinely vulnerable function from a nearly-identical safe one — rather than the marginal per-function accuracy that dominates many benchmark scores. The PrimeVul benchmark was constructed precisely to expose this gap: it pairs each vulnerable function with its minimally-patched counterpart and rewards a model only when it judges both correctly, a protocol that punishes the label priors and superficial pattern-matching that inflate single-function metrics.
20
+
21
+ We make three contributions. First, we confirm that the original paper's headline result reproduces: under the authors' own prompt and task formulation, the released model recovers roughly 80% F1, so the low numbers we report elsewhere reflect distribution shift and protocol, not a failure to reproduce. Second, we show through five independent interventions — spanning supervised fine-tuning, reasoning distillation from a frontier teacher, data scaling, and a substantial increase in base-model size — that the out-of-distribution pairwise ceiling is remarkably rigid, and that additional in-function training or capacity does not move it. Third, and most importantly, we explain why: using a frontier oracle with access to the ground-truth patch, we quantify how much of the deciding vulnerable-versus-patched signal actually resides inside the function being judged, and find that it is a minority. The remainder is interprocedural — it lives in callers, in externally-defined types, or in program state that no single-function method can observe. This reframes the problem from "the model is not good enough" to "the information is not present," with direct implications for how such models should be deployed and evaluated.
22
+
23
+ ## 2. Background and Related Work
24
+
25
+ Function-level vulnerability detection has historically been benchmarked on datasets whose vulnerable and non-vulnerable examples are drawn from different functions, allowing models to exploit spurious correlations between surface features and labels. PrimeVul (Ding et al., 2024) responds to this weakness with a paired protocol: each vulnerable function is matched to the function that results from applying only the security patch, so that the two members of a pair differ minimally and share nearly all surface features. The associated pair-wise metrics — most stringently, the pair-correct rate, in which both members must be classified correctly — isolate genuine discrimination from label-prior exploitation. It is against this protocol that we evaluate.
26
+
27
+ VulnLLM-R builds on Qwen2.5-7B-Instruct (Qwen Team, 2024) and a structured chain-of-thought procedure, reporting strong results on its own curated data. Our interventions draw on established adaptation techniques: low-rank adaptation for parameter-efficient fine-tuning (Hu et al., 2021), self-taught reasoning in which a model's own correct-verdict rationales become training targets (Zelikman et al., 2022), and self-consistency as a test-time aggregation strategy (Wang et al., 2022). Our diagnostic contribution — measuring the fraction of pairs whose deciding signal is intra- versus inter-procedural — is, to our knowledge, a novel way of bounding the achievable performance of any single-function detector on a paired benchmark, and it complements static-analysis literature that has long distinguished intra- from inter-procedural dataflow.
28
+
29
+ ## 3. Methods
30
+
31
+ ### 3.1 Model and serving
32
+
33
+ We evaluate the publicly released VulnLLM-R-7B weights, a fine-tune of Qwen2.5-7B-Instruct. To reflect a realistic local-deployment setting, we serve the model through Ollama with 8-bit (Q8_0) quantization on an Apple M5 Pro with 48 GB of unified memory using the Metal backend. Unless otherwise noted, inference uses a temperature of 0.2 and the model's native ChatML formatting with the four-step reasoning procedure specified by the original authors, and a 32,768-token context window. Reproduction experiments (Section 4.1) additionally use the authors' exact prompt and candidate-CWE task framing.
34
+
35
+ ### 3.2 Benchmark and metrics
36
+
37
+ Out-of-distribution evaluation uses the `test_paired` split of the ASSERT-KTH distribution of PrimeVul: 564 vulnerable/patched pairs (1,128 functions), balanced by construction and overwhelmingly C and C++ (predominantly Chromium, TensorFlow, and similar large projects). We report per-function accuracy, precision, recall, and F1, and the PrimeVul pair-wise outcomes, of which the primary quantity is the pair-correct rate: the fraction of pairs in which the vulnerable function is judged vulnerable and its patched twin judged safe. Every judgment is blind — the model receives one function at a time with no indication of its pair membership or ground-truth label — and verdicts are parsed from the model's structured final line. All comparisons within an experiment use a fixed harness and identical decoding.
38
+
39
+ ### 3.3 Improvement interventions
40
+
41
+ We attempted to raise pair-correct accuracy through five interventions, each holding the base model and serving stack fixed except where noted. The first, verdict-only supervised fine-tuning, trained a LoRA adapter on 3,000 PrimeVul-training functions labeled with their correct verdicts. The second, self-taught reasoning distillation, sampled the base model's own reasoning traces on training functions and retained only those reaching the correct verdict as supervision targets. The third, frontier-teacher reasoning distillation, used a frontier model (GPT-5.6-Sol at maximal reasoning effort, accessed via a command-line interface) to write correct diagnostic reasoning for functions the base model misjudged, distilling those rationales into a LoRA adapter; a fourth intervention scaled this teacher set approximately sevenfold, from 212 to 1,307 traces. Adapters were trained with mlx-lm, fused into the base weights, converted to GGUF, and served identically to the base. The fifth intervention replaced the base entirely with a general-purpose model of 3.8× the parameter count (Qwen3.6-27B) under the same blind protocol.
42
+
43
+ ### 3.4 Decidability probe
44
+
45
+ To explain the observed ceiling, we designed a two-part probe on 100 randomly selected pairs. The first part measures *decidability*: a frontier oracle (GPT-5.6-Sol at maximal reasoning effort) is shown *both* members of a pair — so that the security-relevant difference between them is fully observable — and asked to classify whether the vulnerability is determinable from the vulnerable function's own text (labeled INTRA: the unsafe operation and the missing or insufficient guard are both visible within the function) or whether a correct judgment requires information defined outside the function (labeled INTER: a caller-established bound, an externally-defined type or size, or global and configuration state). The oracle returned a classification and a short justification naming the specific deciding operation or the specific external fact required. The second part measures the *differential rate* of a concrete extractor: we ran the cppcheck static analyzer (version 2.21, with all checks enabled and common typedefs stubbed to compensate for absent headers) on both members of each pair and recorded how often its security-relevant findings differed between twins, and in particular how often they were *directional* — present on the vulnerable function and absent on its patch. The differential rate upper-bounds the discriminative signal that this off-the-shelf tool could contribute, and is by construction no larger than the decidable fraction.
46
+
47
+ ## 4. Results
48
+
49
+ ### 4.1 The reported result reproduces in-distribution
50
+
51
+ Under the original authors' prompt and task formulation, the released model recovers approximately 81% accuracy and 80% F1 on a curated in-distribution sample, in line with the paper's claims and confirming that the weights and our serving stack are faithful. This reproduction is essential context for everything that follows: the sharply lower numbers reported below are a consequence of distribution shift and evaluation protocol, not of an inability to reproduce the original work. The left panel of Figure 2 places the two regimes side by side; moving from the authors' setup to a blind out-of-distribution evaluation reduces accuracy from 81% to 53% and F1 from 80 to 44.7.
52
+
53
+ ### 4.2 Pairwise discrimination collapses out-of-distribution
54
+
55
+ Evaluated blind on the 564 PrimeVul pairs, the base model achieves a pair-correct rate of 17.4%, with per-function accuracy of 53.0% and F1 of 44.7. A pair-correct rate near 17% indicates that, when confronted with a vulnerable function and its minimally-different patch, the model usually cannot assign the two the opposite verdicts they require. Per-function accuracy barely above 50% on a balanced set tells the same story from the pointwise side: the model's apparent competence in-distribution does not survive the removal of the label priors and surface cues that the paired protocol neutralizes. This is the number that all subsequent interventions attempt to raise.
56
+
57
+ ### 4.3 The generalization boundary is mechanism novelty, not label novelty
58
+
59
+ Before attempting to move the ceiling, we characterized what the model had actually learned, to avoid misattributing its limits. Two findings, summarized in the right panel of Figure 2, are relevant. First, an untrained CWE label whose underlying mechanism the model *had* seen transferred fully: functions labeled with buffer-family CWEs absent from training were classified at 80% accuracy, slightly above the 72% observed on trained buffer CWEs, because they invoke the identical bounds-checking reasoning. The model therefore did not merely memorize CWE labels. Second, and in contrast, genuinely novel *mechanisms* degraded substantially: on a balanced set of never-seen mechanism classes, accuracy fell from 85% to 70% and F1 from 87 to 64, driven almost entirely by a recall collapse from 100% to 53.3%. The model retains specificity on unfamiliar vulnerability logic but loses sensitivity, under-detecting what it has not been taught. This establishes that the model learned transferable reasoning rather than surface patterns, and locates its fragility in recall on unfamiliar mechanisms — a boundary distinct from, and milder than, the out-of-distribution collapse of Section 4.2.
60
+
61
+ ### 4.4 No intervention beats the wall
62
+
63
+ Figure 1 reports the pair-correct rate for the base model and all five interventions on the same protocol. Verdict-only fine-tuning (17.2%) and self-taught reasoning distillation (17.1%) were statistically indistinguishable from the base. Frontier-teacher reasoning distillation produced the only improvement, reaching 20.0% from 212 carefully-targeted traces — but scaling the same procedure sevenfold to 1,307 traces did not extend the gain; it *reversed* it, dropping pair-correct to 14.2% while raising recall, the signature of a decision threshold sliding toward indiscriminate positives rather than of improved discrimination. Most tellingly, replacing the base with a general-purpose model of 3.8× the size produced a pair-correct rate of 0.0%, accompanied by a high rate of unparseable outputs; additional capacity, absent task-specific grounding, made discrimination worse rather than better. The consistent picture across parameter-efficient tuning, reasoning distillation, data scaling, and model scaling is that the ceiling is a property of the task as posed, not of the model's capacity to fit it.
64
+
65
+ ### 4.5 The signal is mostly outside the function
66
+
67
+ The decidability probe explains the wall directly, and its result is shown in Figure 3. Of 99 scored pairs, the frontier oracle judged only 29.3% to be decidable from the vulnerable function's own text; the remaining 70.7% required information defined outside the function. The oracle's justifications for the interprocedural majority are concrete and consistent: whether a caller had already bounded an argument ("actual capacity of caller-provided szLine versus the strcpy output"), the externally-defined size or semantics of a parameter ("requires external BuildTensorShape semantics for malformed attacker-controlled dimensions"), or invariants established elsewhere in the program ("whether pad_width_ is prevalidated during construction is not visible in Compute"). Because these facts are absent from the function under judgment, no method restricted to that function — regardless of its training or size — can recover them. The 29.3% decidable fraction is therefore the ceiling on pair-correct accuracy for any single-function detector on this distribution, and it aligns closely with the 25–30% cap that a debate of five independent models had estimated a priori.
68
+
69
+ The second part of the probe shows that even the decidable minority is not cheaply recoverable by conventional tooling. Running cppcheck on the same functions produced findings that differed between twins in only 5% of pairs and were *directional* — flagging the vulnerable member and clearing its patch — in just 2%. On 65% of pairs the analyzer emitted the identical finding on both members, contributing no discriminative signal, and on 30% it flagged neither. An off-the-shelf intra-procedural analyzer applied to header-less functions from large C++ projects thus recovers almost none of even the in-function signal; the decidable pairs are decidable by semantic reasoning, not by pattern-matching linters. This closes the argument: the interprocedural majority is unrecoverable in principle by single-function methods, and the intra-procedural minority is not recovered in practice by the cheap tool most often proposed to supply it.
70
+
71
+ ## 5. Discussion
72
+
73
+ Our results are best read not as a refutation of the original paper but as a demarcation of its scope. VulnLLM-R-7B does what it claims on the distribution it was built for, and it learned transferable reasoning rather than brittle pattern-matching, as its full transfer to untrained labels of familiar mechanisms shows. What our experiments add is a precise account of where that capability stops. When the evaluation shifts to distribution-shifted code and to a protocol that demands genuine vulnerable-versus-patched discrimination, performance falls to a rigid ceiling that neither fine-tuning, reasoning distillation, data scaling, nor a near-quadrupling of model size can raise. The decidability probe identifies the cause as informational rather than representational: roughly seven in ten decisions depend on facts that are simply not present in the function being judged.
74
+
75
+ This reframing carries a clear methodological implication. Reporting single-function detection performance without a paired or otherwise prior-controlled protocol risks conflating label-prior exploitation with capability, and reporting it in-distribution risks overstating deployability. The pair-correct rate on distribution-shifted pairs is a demanding but honest summary, and by that measure the achievable ceiling for local single-function models is near 29% — a number practitioners should hold in mind when a benchmark advertises 80%. It also clarifies why the field's most promising direction is architectural rather than parametric: to move the ceiling one must supply the missing interprocedural context — callers, resolved types, reaching definitions — which necessarily means ingesting more of the program than a single function. The original paper's agent scaffold is precisely such a mechanism, and our results can be read as quantitative evidence for why scaffolding, rather than a larger model or more in-function data, is the lever that matters.
76
+
77
+ Finally, the decidability decomposition suggests a deployment posture that is honest about the ceiling rather than defeated by it. Because the decidable minority is identifiable in principle — these are the functions whose unsafe operation and missing guard are both locally visible — a practical system can route for high-precision triage: emit confident verdicts where the signal is in-function and abstain, flagging "insufficient context," where it is not. Such a system trades coverage for trustworthiness and aligns the model's outputs with the information actually available to it, which is preferable to uniform per-function verdicts that are reliable on only a third of cases. We regard this as the constructive conclusion of an otherwise negative result.
78
+
79
+ ## 6. Limitations
80
+
81
+ Several caveats bound our conclusions. Our serving stack uses 8-bit quantization and a single decoding configuration; although we matched all within-experiment comparisons, absolute numbers could shift modestly under full precision or alternative sampling. The decidability probe relies on a frontier model as an oracle, and although it was given the ground-truth patch and asked a narrowly-scoped structural question, its INTRA/INTER labels are judgments rather than proofs; a human-expert audit of a subset would strengthen the estimate, and the single unparsed case was excluded rather than adjudicated. The differential-rate measurement used one analyzer (cppcheck) on the C and C++ majority and did not include the Java minority or a heavier interprocedural tool such as CodeQL configured with a built project, which would recover more signal at substantially greater cost; our claim is specifically about cheap, locally-runnable, single-function static analysis. Our interventions, though spanning several distinct families, do not exhaust the space — notably, we did not build and evaluate the full repository-context scaffold that our own analysis identifies as the only mechanism with headroom, and we did not correct for position bias by evaluating each pair in both orderings. Finally, all results concern one model on one paired benchmark; the interprocedural-ceiling hypothesis should be tested on additional detectors and datasets before being treated as general.
82
+
83
+ ## 7. Conclusion
84
+
85
+ We reproduced the reported in-distribution strength of VulnLLM-R-7B and then showed that its capability does not survive the transition to blind, distribution-shifted, pairwise evaluation, where pair-correct accuracy sits at 17.4% and resists every attempt to raise it — verdict-only tuning, self- and frontier-distilled reasoning, sevenfold data scaling, and a 3.8×-larger base alike. A decidability probe explains the wall: only 29.3% of pairs are decidable from the function's own text, and an off-the-shelf analyzer recovers a directional signal on just 2%. The ceiling on single-function detection is therefore informational, not a matter of model capacity, and it is bounded near 29% on this distribution. The path past it is to supply the interprocedural context the task withholds — the very role of an agent scaffold — and, short of that, to deploy the model as a high-precision triage tool over the decidable minority rather than as a uniform per-function oracle. We offer these findings in the same spirit as the original work: as a sharpening of where reasoning-specialized detectors succeed, and of where the problem, not the model, sets the limit.
86
+
87
+ ## References
88
+
89
+ Ding, Y., Fu, Y., Ibrahim, O., Sitawarin, C., Chen, X., Alomair, B., Wagner, D., Ray, B., & Chen, Y. (2024). *Vulnerability Detection with Code Language Models: How Far Are We?* (PrimeVul). arXiv:2403.18624. To appear, ICSE 2025.
90
+
91
+ Hu, E. J., Shen, Y., Wallis, P., Allen-Zhu, Z., Li, Y., Wang, S., Wang, L., & Chen, W. (2021). *LoRA: Low-Rank Adaptation of Large Language Models.* arXiv:2106.09685.
92
+
93
+ Qwen Team (2024). *Qwen2.5 Technical Report.* arXiv:2412.15115.
94
+
95
+ Nie, Y., Li, H., Guo, C., Jiang, R., Wang, Z., Li, B., Song, D., & Guo, W. (2025). *VulnLLM-R: Specialized Reasoning LLM with Agent Scaffold for Vulnerability Detection.* arXiv:2512.07533.
96
+
97
+ Wang, X., Wei, J., Schuurmans, D., Le, Q., Chi, E., Narang, S., Chowdhery, A., & Zhou, D. (2022). *Self-Consistency Improves Chain of Thought Reasoning in Language Models.* arXiv:2203.11171.
98
+
99
+ Zelikman, E., Wu, Y., Mu, J., & Goodman, N. D. (2022). *STaR: Bootstrapping Reasoning With Reasoning.* arXiv:2203.14465.
100
+
101
+ ---
102
+
103
+ ## Figures
104
+
105
+ **Figure 1.** Pair-correct accuracy on PrimeVul `test_paired` for the base model and five improvement interventions. The dashed line marks the base ceiling (17.4%). No intervention reliably exceeds it; the best (frontier-teacher distillation) reaches 20.0% before regressing to 14.2% under scaling, and a 3.8×-larger general-purpose base scores 0.0%. (`figures/fig1_ladder.png`)
106
+
107
+ **Figure 2.** (A) Distribution shift: accuracy and F1 fall from the authors' in-distribution setup to a blind out-of-distribution PrimeVul evaluation. (B) Generalization boundary: trained versus novel vulnerability mechanisms, showing that recall collapses from 100% to 53.3% on unfamiliar mechanisms while accuracy and F1 degrade more gently. (`figures/fig2_boundary.png`)
108
+
109
+ **Figure 3.** The core finding. (A) A frontier oracle, shown both twins, judges 71% of pairs to require interprocedural context and only 29% to be decidable from the function alone — the ceiling for any single-function method. (B) On the same functions, cppcheck yields a directional (usable) signal on only 2% of pairs, emitting the identical finding on both twins in 65% and flagging neither in 30%. (`figures/fig3_ceiling.png`)
phase0_decidability.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Phase 0, measurement A — DECIDABILITY (D).
3
+ Frontier oracle (codex gpt-5.6-sol ultra) sees BOTH twins of a PrimeVul pair (so it knows
4
+ the ground-truth security fix = the diff) and classifies whether the vulnerability is
5
+ judgeable from the VULNERABLE FUNCTION ALONE (intra-procedural) or requires context
6
+ OUTSIDE the function (inter-procedural). D = intra fraction = hard ceiling of any
7
+ local single-function method. Compare against cppcheck's 2% directional to locate the lever."""
8
+ import json, os, re, subprocess, threading, time
9
+ from concurrent.futures import ThreadPoolExecutor, as_completed
10
+ from huggingface_hub import hf_hub_download
11
+ import pyarrow.parquet as pq
12
+
13
+ N_PAIRS=100; WORKERS=8
14
+ CK=os.path.expanduser("~/.cache/phase0_decide_ckpt.jsonl")
15
+ TMPDIR="/private/tmp/claude-501/-Users-bert/98b949c0-1b8d-4b6f-a742-3c071ad4b3f3/scratchpad/codex_dec"
16
+ os.makedirs(TMPDIR,exist_ok=True)
17
+
18
+ PROMPT="""You are auditing a security patch. Below are TWO versions of the same function: the VULNERABLE version and the PATCHED (fixed) version. The difference between them is the security fix.
19
+
20
+ Classify where the deciding signal lives, from the perspective of a detector that sees ONLY the vulnerable function in isolation (no callers, no other files, no repo):
21
+
22
+ - INTRA = the vulnerability is determinable from the vulnerable function's own text: the unsafe operation and the missing/insufficient guard are both visible inside this function (e.g. a missing bounds/null check before a local buffer op, an unchecked cast, a format-string, integer arithmetic overflow, a use-after-free within the function's own control flow). An expert reading ONLY the vulnerable function could flag it.
23
+
24
+ - INTER = correctly judging it REQUIRES information outside this function: whether a caller already validated/bounded an argument, the concrete size/type of a parameter defined elsewhere, global/config state, or cross-function aliasing. Reading only the vulnerable function, an expert could NOT reliably decide, because the deciding fact is external.
25
+
26
+ Think briefly, then output EXACTLY two final lines:
27
+ #class: <INTRA or INTER>
28
+ #why: <max 15 words naming the exact deciding operation or the exact external fact needed>
29
+
30
+ VULNERABLE version:
31
+ ```
32
+ {VULN}
33
+ ```
34
+
35
+ PATCHED version:
36
+ ```
37
+ {PATCH}
38
+ ```
39
+ """
40
+
41
+ CLS=re.compile(r"#class:\s*(INTRA|INTER)",re.I)
42
+
43
+ def call(vuln, patch, tmpf):
44
+ prompt=PROMPT.format(VULN=vuln[:9000], PATCH=patch[:9000])
45
+ try:
46
+ subprocess.run(["codex","exec","-m","gpt-5.6-sol","-c","model_reasoning_effort=ultra",
47
+ "--ignore-user-config","--skip-git-repo-check","--output-last-message",tmpf,prompt],
48
+ stdin=subprocess.DEVNULL,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,timeout=300)
49
+ return open(tmpf).read() if os.path.exists(tmpf) else ""
50
+ except Exception:
51
+ return ""
52
+
53
+ def main():
54
+ p=hf_hub_download("ASSERT-KTH/PrimeVul","data/test_paired-00000-of-00001.parquet",repo_type="dataset")
55
+ t=pq.read_table(p); func=t.column("func").to_pylist(); lab=t.column("is_vulnerable").to_pylist()
56
+ done=set()
57
+ if os.path.exists(CK):
58
+ for l in open(CK):
59
+ try: done.add(json.loads(l)["k"])
60
+ except: pass
61
+ todo=[k for k in range(N_PAIRS) if k not in done]
62
+ print(f"decidability todo {len(todo)}",flush=True)
63
+ lock=threading.Lock(); ck=open(CK,"a"); t0=time.time(); cnt=[0]
64
+ def work(k):
65
+ i0,i1=2*k,2*k+1
66
+ vi=i0 if lab[i0] else i1; pi=i1 if vi==i0 else i0
67
+ out=call(func[vi],func[pi],os.path.join(TMPDIR,f"d{k}.txt"))
68
+ m=None
69
+ for m in CLS.finditer(out): pass
70
+ cls=m.group(1).upper() if m else None
71
+ why=""
72
+ wm=re.search(r"#why:\s*(.+)",out)
73
+ if wm: why=wm.group(1).strip()[:120]
74
+ with lock:
75
+ ck.write(json.dumps({"k":k,"cls":cls,"why":why})+"\n"); ck.flush(); cnt[0]+=1
76
+ if cnt[0]%10==0 or cnt[0]==len(todo):
77
+ print(f" {cnt[0]}/{len(todo)} ({cnt[0]/(time.time()-t0)*60:.1f}/min)",flush=True)
78
+ with ThreadPoolExecutor(max_workers=WORKERS) as ex:
79
+ for _ in as_completed([ex.submit(work,k) for k in todo]): pass
80
+ ck.close()
81
+ recs={json.loads(l)["k"]:json.loads(l) for l in open(CK)}
82
+ recs=[recs[k] for k in sorted(recs) if k<N_PAIRS]
83
+ intra=sum(1 for r in recs if r["cls"]=="INTRA")
84
+ inter=sum(1 for r in recs if r["cls"]=="INTER")
85
+ unp=sum(1 for r in recs if r["cls"] is None)
86
+ scored=intra+inter or 1
87
+ print(f"\n===== PHASE 0 (A): DECIDABILITY D on {intra+inter} scored pairs ({unp} unparsed) =====")
88
+ print(f"INTRA (judgeable from function alone): {intra}/{scored} = {intra/scored*100:.1f}% <- D, the ceiling")
89
+ print(f"INTER (needs caller/external context): {inter}/{scored} = {inter/scored*100:.1f}%")
90
+ print("\nsample INTER reasons (why the signal is outside the function):")
91
+ for r in recs:
92
+ if r["cls"]=="INTER" and r["why"]:
93
+ print(f" - {r['why']}")
94
+ print("\nsample INTRA reasons:")
95
+ n=0
96
+ for r in recs:
97
+ if r["cls"]=="INTRA" and r["why"]:
98
+ print(f" - {r['why']}"); n+=1
99
+ if n>=8: break
100
+
101
+ if __name__=="__main__": main()
phase0_decide_results.jsonl ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"k": 6, "cls": "INTER", "why": "Security impact depends on external views::Widget::OnGestureEvent semantics and event propagation."}
2
+ {"k": 0, "cls": "INTER", "why": "Requires external knowledge of RefreshCellularDataPlans\u2019 lifetime and callback behavior."}
3
+ {"k": 4, "cls": "INTER", "why": "Required invariant that all page IDs enter m_processSuppressiblePages regardless of pageIsProcessSuppressible."}
4
+ {"k": 5, "cls": "INTER", "why": "Requires external semantics of toV8 wrapper creation when substituting the caller\u2019s creationContext."}
5
+ {"k": 2, "cls": "INTER", "why": "Copying versus moving is unsafe only given external path trust and work-item semantics."}
6
+ {"k": 9, "cls": "INTER", "why": "create_kernel\u2019s failure contract: whether it initializes item->kernel to a valid deletable pointer."}
7
+ {"k": 3, "cls": "INTRA", "why": "Unchecked reinterpret_cast of NSURL object to CFURLRef in empty-string path."}
8
+ {"k": 8, "cls": "INTER", "why": "Safety of Quantum-to-ssize_t cast depends on Quantum\u2019s externally defined type and range."}
9
+ {"k": 1, "cls": "INTER", "why": "Security impact of const qualification depends on class state and caller overload resolution."}
10
+ {"k": 11, "cls": "INTER", "why": "Whether callers safely handle the propagated MakeShape failure is external."}
11
+ {"k": 14, "cls": "INTER", "why": "Whether failed authentication must update existing session state via user_session_update."}
12
+ {"k": 17, "cls": "INTER", "why": "Whether CommonFinishDecode already frees decode, making cleanup a double-free."}
13
+ {"k": 13, "cls": "INTRA", "why": "Reference dtype rejection is fully visible before local Tensor construction."}
14
+ {"k": 12, "cls": "INTER", "why": "Whether InfoHeader can be NULL depends on external object-construction invariants."}
15
+ {"k": 15, "cls": "INTER", "why": "Requires knowing BuildTensorShape\u2019s external dimension-product overflow behavior."}
16
+ {"k": 16, "cls": "INTER", "why": "Safety of decrementing access mode requires external semantics of open_context and flag value 3."}
17
+ {"k": 21, "cls": "INTER", "why": "Whether absent config_proto makes omitted allowed_devices grant unrestricted GPU access is externally defined."}
18
+ {"k": 22, "cls": "INTRA", "why": "Unbounded batch_idx increment indexes splits_values without validating split monotonicity."}
19
+ {"k": 23, "cls": "INTER", "why": "Whether callers permit zero bias_size and require array_data processing is external."}
20
+ {"k": 24, "cls": "INTER", "why": "Whether callers reject malformed graphs when a missing input makes this function return false."}
21
+ {"k": 18, "cls": "INTRA", "why": "Attacker-controlled DebugString is logged on invalid output index, enabling log amplification."}
22
+ {"k": 27, "cls": "INTRA", "why": "Size-validation failure exits after decoder initialization without calling png::CommonFreeDecode."}
23
+ {"k": 10, "cls": "INTER", "why": "Security relevance depends on caller handling; the vulnerable function\u2019s iterator dereference is guarded."}
24
+ {"k": 29, "cls": "INTER", "why": "Forced VMLOAD/VMSAVE interception requires nested-SVM semantics defined outside this function"}
25
+ {"k": 28, "cls": "INTER", "why": "Safety of final gf_bs_align(bs) requires external semantics and caller\u2019s expected stream position."}
26
+ {"k": 26, "cls": "INTER", "why": "Requires external return-range and signedness guarantees for gf_bs_read_ue_log and s32."}
27
+ {"k": 32, "cls": "INTRA", "why": "Typeof default falls through and returns nullptr instead of rejecting an invalid literal kind"}
28
+ {"k": 31, "cls": "INTRA", "why": "Unchecked shapes[0] access when maxRank is zero and shapes may be empty"}
29
+ {"k": 20, "cls": "INTER", "why": "Whether allocate_temp buffers safely support these asynchronous assignments depends on external allocator semantics."}
30
+ {"k": 34, "cls": "INTER", "why": "Websocket server runs under another user and must rename sockets in sessions directory."}
31
+ {"k": 7, "cls": "INTRA", "why": "Direct float/double pointer casts dereference potentially misaligned EXIF byte addresses."}
32
+ {"k": 33, "cls": "INTRA", "why": "Unchecked X509_VERIFY_PARAM_set1_host return can silently leave hostname validation misconfigured."}
33
+ {"k": 30, "cls": "INTER", "why": "Safety of CASES_WITH_DEFAULT requires its external macro expansion and supported-type definitions."}
34
+ {"k": 19, "cls": "INTER", "why": "Requires knowing mrb_get_args can reenter and mutate self before array metadata capture"}
35
+ {"k": 37, "cls": "INTER", "why": "Whether callers guarantee output_port validity and context output-count consistency is external."}
36
+ {"k": 40, "cls": "INTER", "why": "Whether cc[1] is a validated in-range offset into ucd_caseless_sets."}
37
+ {"k": 38, "cls": "INTER", "why": "AddItem/AddNode side effects determine whether arg_index can diverge from result_.nodes.size()."}
38
+ {"k": 39, "cls": "INTRA", "why": "Parsed dimensions narrow through signed long before size_t, without range validation."}
39
+ {"k": 43, "cls": "INTER", "why": "Whether codegen(..., val=false) still changes the value stack."}
40
+ {"k": 44, "cls": "INTER", "why": "Requires StagingMap::put\u2019s external key-shape contract to judge the scalar restriction."}
41
+ {"k": 36, "cls": "INTER", "why": "Whether prior parsing guarantees avc->s_info.sps is non-NULL at this branch."}
42
+ {"k": 41, "cls": "INTER", "why": "Requires external invariant that node_map_->GetNode always returns non-null for these inputs"}
43
+ {"k": 42, "cls": "INTER", "why": "Safety of rhs.IsInitialized() depends on external Tensor state and concurrency semantics."}
44
+ {"k": 45, "cls": "INTER", "why": "gen_values\u2019 return/stack contract determines why n==13 must not trigger argument packing"}
45
+ {"k": 46, "cls": "INTER", "why": "Requires knowing drain() can invalidate iterator by invoking external callbacks."}
46
+ {"k": 49, "cls": "INTER", "why": "Actual capacity of caller-provided szLine versus strcpy output up to 2048 bytes."}
47
+ {"k": 48, "cls": "INTRA", "why": "GOPHER_WWW format has five conversions but supplies only three arguments."}
48
+ {"k": 51, "cls": "INTER", "why": "GF_SAFEALLOC\u2019s allocation semantics and failure behavior require its external macro definition"}
49
+ {"k": 50, "cls": "INTRA", "why": "Unchecked min_rank arithmetic can overflow for INT64_MIN or INT64_MAX concat_dim"}
50
+ {"k": 54, "cls": "INTER", "why": "Requires caller semantics: whether out_metadata requests optional metadata for metadata-less bundles."}
51
+ {"k": 56, "cls": "INTRA", "why": "Duplicate names only log; subsequent map assignment overwrites the existing entry."}
52
+ {"k": 35, "cls": "INTER", "why": "Whether callers prevalidate each report block\u2019s full size before this function parses it."}
53
+ {"k": 55, "cls": "INTER", "why": "Need conn->raddr.addr\u2019s externally defined size to judge the ai_addrlen-sized memcpy."}
54
+ {"k": 53, "cls": "INTRA", "why": "Negative pooling indices can reach Eigen coeffRef without bounds checks."}
55
+ {"k": 59, "cls": "INTER", "why": "Requires external knowledge whether silently accepting a missing graph node enables a security bypass."}
56
+ {"k": 25, "cls": "INTRA", "why": "gf_realloc may invalidate aliased data, then memcpy reads through that stale pointer"}
57
+ {"k": 60, "cls": "INTRA", "why": "Unchecked signed size converts to size_t, allowing negative values to wrap during size computation."}
58
+ {"k": 61, "cls": "INTER", "why": "Whether TfLiteIntArrayGetSizeInBytes can return negative before conversion to size_t."}
59
+ {"k": 52, "cls": "INTER", "why": "Requires external BuildTensorShape semantics for malformed or overflowing attacker-controlled dimensions"}
60
+ {"k": 47, "cls": "INTRA", "why": "Socket filtering uses non-exact seccomp_rule_add, visibly weakening the local sandbox policy"}
61
+ {"k": 58, "cls": "INTER", "why": "Requires external guarantees about dev->card_label contents and termination."}
62
+ {"k": 64, "cls": "INTER", "why": "Whether entries may be NULL while nb_entries is nonzero is established outside this function."}
63
+ {"k": 62, "cls": "INTER", "why": "Requires the external pooling_ratio_ contract; its removed comparison has no intrinsic unsafe effect."}
64
+ {"k": 65, "cls": "INTRA", "why": "Empty indices/values element counts are not cross-checked before sparse tensor construction."}
65
+ {"k": 63, "cls": "INTRA", "why": "Untrusted box dimensions narrow through signed long to size_t without range validation."}
66
+ {"k": 68, "cls": "INTRA", "why": "Non-digit snprintf output bypasses validation when tmplen\u226564 before unsafe pointer arithmetic."}
67
+ {"k": 70, "cls": "INTER", "why": "Requires external callback contract for make_fragmented_temporary_buffer\u2019s returned byte count."}
68
+ {"k": 72, "cls": "INTRA", "why": "Unbounded base64url decoding writes attacker-controlled signature into fixed 128-byte sig buffer."}
69
+ {"k": 71, "cls": "INTER", "why": "Requires external semantics explaining why rejecting empty resource tensors is unsafe."}
70
+ {"k": 74, "cls": "INTRA", "why": "Unconditional CDATA advance skips input without an EOF guard."}
71
+ {"k": 69, "cls": "INTRA", "why": "The iov_from_buf short-copy result is ignored before virtqueue_push reports the full len."}
72
+ {"k": 76, "cls": "INTER", "why": "Whether chroma storage width is governed by high_bit_depth(0), defined by de265_image allocation."}
73
+ {"k": 73, "cls": "INTER", "why": "Whether njs_array_alloc makes deleted->start[i] writable depends on its external allocation semantics."}
74
+ {"k": 77, "cls": "INTER", "why": "Whether bytecode operands were externally validated against register, pool, and symbol table bounds."}
75
+ {"k": 66, "cls": "INTER", "why": "IRC 352 grammar determines whether argv[8] asterisk must advance arg_start."}
76
+ {"k": 57, "cls": "INTER", "why": "Whether pad_width_ is prevalidated during construction is not visible in Compute."}
77
+ {"k": 78, "cls": "INTER", "why": "Whether configASSERT aborts on overflow depends on its external macro definition."}
78
+ {"k": 80, "cls": "INTER", "why": "Security impact depends on external handling of the duplicate-cipher exception."}
79
+ {"k": 81, "cls": "INTER", "why": "Whether callers invoke ParseMCU with zero remaining lines is external."}
80
+ {"k": 85, "cls": "INTER", "why": "Negative num_streams semantics in QuantileStreamResource are defined outside this function."}
81
+ {"k": 83, "cls": "INTER", "why": "Requires gf_isom_parse_root_box\u2019s contract for initializing a on nonnegative returns"}
82
+ {"k": 88, "cls": "INTRA", "why": "IS_UNDEF top-level branch returns without freeing ent1, unlike the sibling branch."}
83
+ {"k": 82, "cls": "INTER", "why": "Whether m_ulRemaining[0] can be nonpositive depends on externally maintained scan state."}
84
+ {"k": 86, "cls": "INTER", "why": "Requires external knowledge that writer-stack depth is enforced by new_unencoding_writer."}
85
+ {"k": 89, "cls": "INTER", "why": "Security impact depends on external implementations of logStartingSubPipeline and logShardedViewFound."}
86
+ {"k": 87, "cls": "INTER", "why": "Requires prior bi->pdwidth initialization and downstream use when pixelsize is zero."}
87
+ {"k": 75, "cls": "INTRA", "why": "ND option-header and SLLAO buffer reads lack sufficient local bounds checks."}
88
+ {"k": 93, "cls": "INTER", "why": "Security impact depends on the externally defined test_bad_write callback."}
89
+ {"k": 90, "cls": "INTRA", "why": "Bucket/name-count invariant is only warned about, allowing malformed table processing to continue."}
90
+ {"k": 91, "cls": "INTER", "why": "Whether device_path is guaranteed non-NULL when the ENOENT branch executes."}
91
+ {"k": 79, "cls": "INTER", "why": "Security impact depends on external getcwd_system semantics for one-byte buffers."}
92
+ {"k": 96, "cls": "INTRA", "why": "Unchecked s->size+1 can wrap, undersizing allocation before read and terminator write."}
93
+ {"k": 98, "cls": "INTER", "why": "Requires lsqpack_enc_init semantics for sub-minimum dyn_table_size versus forced zero."}
94
+ {"k": 95, "cls": "INTRA", "why": "Bounds checks and subsequent output_t(loc) writes are fully visible locally."}
95
+ {"k": 99, "cls": "INTER", "why": "Whether crypto_memneq safely handles digest_length(d) requires its external implementation and length contract."}
96
+ {"k": 97, "cls": "INTER", "why": "Requires bitbuffer_add_row semantics to know whether num_rows-1 indexing is in bounds"}
97
+ {"k": 67, "cls": "INTRA", "why": "Recursive container traversal lacks cycle detection for self-referential arrays or objects."}
98
+ {"k": 94, "cls": "INTER", "why": "Whether get_name_len guarantees four bytes remain after the parsed name."}
99
+ {"k": 84, "cls": "INTER", "why": "Requires external SparseTensor contract: zero-rank indices may be empty with nonempty values."}
100
+ {"k": 92, "cls": null, "why": ""}
phase0_diff_results.jsonl ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {"k": 0, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
2
+ {"k": 1, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
3
+ {"k": 2, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
4
+ {"k": 3, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["constStatement"], "differ": true, "directional": true, "both_same_flag": false, "neither_flagged": false}
5
+ {"k": 4, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
6
+ {"k": 5, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
7
+ {"k": 6, "lang": "c", "vuln_ids": [], "patch_ids": ["syntaxError"], "differ": true, "directional": false, "both_same_flag": false, "neither_flagged": false}
8
+ {"k": 7, "lang": "c", "vuln_ids": [], "patch_ids": ["invalidPointerCast"], "differ": true, "directional": false, "both_same_flag": false, "neither_flagged": false}
9
+ {"k": 8, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
10
+ {"k": 9, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
11
+ {"k": 10, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
12
+ {"k": 11, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
13
+ {"k": 12, "lang": "c", "vuln_ids": [], "patch_ids": ["nullPointerRedundantCheck"], "differ": true, "directional": false, "both_same_flag": false, "neither_flagged": false}
14
+ {"k": 13, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
15
+ {"k": 14, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
16
+ {"k": 15, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
17
+ {"k": 16, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
18
+ {"k": 17, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
19
+ {"k": 18, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
20
+ {"k": 19, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
21
+ {"k": 20, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
22
+ {"k": 21, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
23
+ {"k": 22, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
24
+ {"k": 23, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
25
+ {"k": 24, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
26
+ {"k": 25, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
27
+ {"k": 26, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
28
+ {"k": 27, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
29
+ {"k": 28, "lang": "c", "vuln_ids": ["unknownMacro"], "patch_ids": ["unknownMacro"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
30
+ {"k": 29, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
31
+ {"k": 30, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
32
+ {"k": 31, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
33
+ {"k": 32, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
34
+ {"k": 33, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
35
+ {"k": 34, "lang": "c", "vuln_ids": ["unknownMacro"], "patch_ids": [], "differ": true, "directional": true, "both_same_flag": false, "neither_flagged": false}
36
+ {"k": 35, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
37
+ {"k": 36, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
38
+ {"k": 37, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
39
+ {"k": 38, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
40
+ {"k": 39, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
41
+ {"k": 40, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
42
+ {"k": 41, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
43
+ {"k": 42, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
44
+ {"k": 43, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
45
+ {"k": 44, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
46
+ {"k": 45, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
47
+ {"k": 46, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
48
+ {"k": 47, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
49
+ {"k": 48, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
50
+ {"k": 49, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
51
+ {"k": 50, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
52
+ {"k": 51, "lang": "c", "vuln_ids": ["unknownMacro"], "patch_ids": ["unknownMacro"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
53
+ {"k": 52, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
54
+ {"k": 53, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
55
+ {"k": 54, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
56
+ {"k": 55, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
57
+ {"k": 56, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
58
+ {"k": 57, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
59
+ {"k": 58, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
60
+ {"k": 59, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
61
+ {"k": 60, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
62
+ {"k": 61, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
63
+ {"k": 62, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
64
+ {"k": 63, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
65
+ {"k": 64, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
66
+ {"k": 65, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
67
+ {"k": 66, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
68
+ {"k": 67, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
69
+ {"k": 68, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
70
+ {"k": 69, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
71
+ {"k": 70, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
72
+ {"k": 71, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
73
+ {"k": 72, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
74
+ {"k": 73, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
75
+ {"k": 74, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
76
+ {"k": 75, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
77
+ {"k": 76, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
78
+ {"k": 77, "lang": "c", "vuln_ids": ["autoVariables", "invalidPrintfArgType_sint", "returnImplicitInt"], "patch_ids": ["autoVariables", "invalidPrintfArgType_sint", "returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
79
+ {"k": 78, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
80
+ {"k": 79, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
81
+ {"k": 80, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
82
+ {"k": 81, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
83
+ {"k": 82, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
84
+ {"k": 83, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
85
+ {"k": 84, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
86
+ {"k": 85, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
87
+ {"k": 86, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
88
+ {"k": 87, "lang": "c", "vuln_ids": ["unknownMacro"], "patch_ids": ["unknownMacro"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
89
+ {"k": 88, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
90
+ {"k": 89, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
91
+ {"k": 90, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
92
+ {"k": 91, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
93
+ {"k": 92, "lang": "c", "vuln_ids": ["uninitvar"], "patch_ids": ["uninitvar"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
94
+ {"k": 93, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
95
+ {"k": 94, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
96
+ {"k": 95, "lang": "c", "vuln_ids": ["syntaxError"], "patch_ids": ["syntaxError"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
97
+ {"k": 96, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
98
+ {"k": 97, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
99
+ {"k": 98, "lang": "c", "vuln_ids": ["returnImplicitInt"], "patch_ids": ["returnImplicitInt"], "differ": false, "directional": false, "both_same_flag": true, "neither_flagged": false}
100
+ {"k": 99, "lang": "c", "vuln_ids": [], "patch_ids": [], "differ": false, "directional": false, "both_same_flag": false, "neither_flagged": true}
phase0_differential.py ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """Phase 0, measurement B — DIFFERENTIAL RATE.
3
+ For N PrimeVul pairs, run cppcheck on BOTH the vulnerable and patched function and
4
+ measure how often the extracted findings DIFFER. If evidence(vuln)==evidence(patch),
5
+ the intra-procedural tool gives ZERO discriminative signal for that pair.
6
+ This is the true usable-signal ceiling for a static-evidence LoRA (<= decidability D)."""
7
+ import json, os, re, subprocess, tempfile, hashlib
8
+ from huggingface_hub import hf_hub_download
9
+ import pyarrow.parquet as pq
10
+
11
+ N_PAIRS = 100
12
+ CK = os.path.expanduser("~/.cache/phase0_diff_ckpt.jsonl")
13
+
14
+ # stub common typedefs so cppcheck doesn't misinfer types on header-less functions
15
+ PREAMBLE = ("typedef unsigned long size_t; typedef unsigned char uint8_t; "
16
+ "typedef unsigned short uint16_t; typedef unsigned int uint32_t; "
17
+ "typedef unsigned long long uint64_t; typedef long ssize_t; "
18
+ "typedef int int32_t; typedef long long int64_t;\n")
19
+
20
+ def is_java(code):
21
+ return bool(re.search(r'\b(public|private|protected)\s+\w+|System\.|import java|@Override', code or ''))
22
+
23
+ def cppcheck_findings(code):
24
+ """Return a normalized set of (rule_id) findings from cppcheck on the isolated function."""
25
+ with tempfile.NamedTemporaryFile("w", suffix=".c", delete=False) as f:
26
+ f.write(PREAMBLE + code)
27
+ path = f.name
28
+ try:
29
+ # --enable=all, template gives us id per finding; suppress noise about missing includes
30
+ r = subprocess.run(
31
+ ["cppcheck", "--enable=all", "--inconclusive", "--suppress=missingIncludeSystem",
32
+ "--suppress=unusedFunction", "--suppress=missingInclude",
33
+ "--template={id}:{line}:{severity}", "--quiet", path],
34
+ capture_output=True, text=True, timeout=60)
35
+ out = (r.stderr or "") + (r.stdout or "")
36
+ except Exception:
37
+ out = ""
38
+ finally:
39
+ os.unlink(path)
40
+ ids = set()
41
+ detailed = []
42
+ for line in out.splitlines():
43
+ m = re.match(r'([a-zA-Z0-9_]+):(\d+):(\w+)', line.strip())
44
+ if m:
45
+ rid, ln, sev = m.group(1), m.group(2), m.group(3)
46
+ # drop pure style/information noise; keep security-relevant severities
47
+ if sev in ("error", "warning", "portability") or rid in (
48
+ "arrayIndexOutOfBounds","bufferAccessOutOfBounds","nullPointer","uninitvar",
49
+ "memleak","doubleFree","useAfterFree","integerOverflow","signConversion",
50
+ "invalidScanfFormatWidth","formatString","negativeIndex","pointerOutOfBounds"):
51
+ ids.add(rid)
52
+ detailed.append(f"{rid}/{sev}")
53
+ return ids, detailed
54
+
55
+ def main():
56
+ p = hf_hub_download("ASSERT-KTH/PrimeVul","data/test_paired-00000-of-00001.parquet",repo_type="dataset")
57
+ t = pq.read_table(p); func = t.column("func").to_pylist(); lab = t.column("is_vulnerable").to_pylist()
58
+ # pairs are consecutive (2k, 2k+1); identify which is vuln
59
+ done = {}
60
+ if os.path.exists(CK):
61
+ for l in open(CK):
62
+ try: r=json.loads(l); done[r["k"]]=r
63
+ except: pass
64
+ ck = open(CK, "a")
65
+ n_c = n_java = 0
66
+ for k in range(N_PAIRS):
67
+ if k in done: continue
68
+ i0, i1 = 2*k, 2*k+1
69
+ # vuln vs patched
70
+ vi = i0 if lab[i0] else i1
71
+ pi = i1 if vi==i0 else i0
72
+ vcode, pcode = func[vi], func[pi]
73
+ lang = "java" if (is_java(vcode) or is_java(pcode)) else "c"
74
+ if lang == "java":
75
+ # no semgrep yet -> record as skipped for cppcheck differential (java handled separately)
76
+ rec = {"k":k, "lang":"java", "skipped":True}
77
+ ck.write(json.dumps(rec)+"\n"); ck.flush(); continue
78
+ vids, vdet = cppcheck_findings(vcode)
79
+ pids, pdet = cppcheck_findings(pcode)
80
+ # differential: does the tool distinguish the twins at all?
81
+ differ = (vids != pids)
82
+ # stronger: did the tool flag the VULN and NOT the patched (correct direction)?
83
+ directional = bool(vids - pids) # findings present in vuln but gone in patch
84
+ both_flagged = bool(vids and pids and vids==pids)
85
+ neither = (not vids and not pids)
86
+ rec = {"k":k, "lang":"c", "vuln_ids":sorted(vids), "patch_ids":sorted(pids),
87
+ "differ":differ, "directional":directional,
88
+ "both_same_flag":both_flagged, "neither_flagged":neither}
89
+ ck.write(json.dumps(rec)+"\n"); ck.flush()
90
+ ck.close()
91
+ # aggregate
92
+ recs=[json.loads(l) for l in open(CK)]
93
+ recs={r["k"]:r for r in recs}; recs=[recs[k] for k in sorted(recs)][:N_PAIRS]
94
+ cc=[r for r in recs if r.get("lang")=="c" and not r.get("skipped")]
95
+ java=[r for r in recs if r.get("lang")=="java"]
96
+ differ=sum(1 for r in cc if r["differ"])
97
+ directional=sum(1 for r in cc if r["directional"])
98
+ neither=sum(1 for r in cc if r["neither_flagged"])
99
+ both=sum(1 for r in cc if r["both_same_flag"])
100
+ nc=len(cc) or 1
101
+ print(f"\n===== PHASE 0 (B): cppcheck DIFFERENTIAL RATE on {len(cc)} C pairs ({len(java)} Java skipped) =====")
102
+ print(f"tool findings DIFFER between twins : {differ}/{nc} = {differ/nc*100:.1f}% <- upper bound on usable static signal")
103
+ print(f" of which DIRECTIONAL (vuln flagged, patch clean): {directional}/{nc} = {directional/nc*100:.1f}%")
104
+ print(f"same finding on BOTH twins (zero signal) : {both}/{nc} = {both/nc*100:.1f}%")
105
+ print(f"NEITHER twin flagged (tool blind) : {neither}/{nc} = {neither/nc*100:.1f}%")
106
+ print(f"\nInterpretation: 'directional' is the fraction where cppcheck ALONE hands the LoRA a")
107
+ print(f"clean discriminative feature. That is the realistic intra-procedural signal floor.")
108
+
109
+ if __name__=="__main__": main()