arXiv:2610.35477cs.SEOct 2026

Manuscript Offprint

arXiv:2610.35477

Making Small Code LLMs More Efficient for Secure Code Review with Neuro-Symbolic Fine-Tuning

Mostafijur Rahman Akhond, Mahmuda Khatun, Gias Uddin

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

MOSTAFIJUR RAHMAN AKHOND, York University, Canada

MAHMUDA KHATUN, York University, Canada

GIAS UDDIN, York University, Canada

As AI coding assistants generate more code, the need to review it for security flaws grows. Existing approaches leave a gap: static analyzers identify program sites but offer little explanation, while language-model explanations can be difficult to verify. Small open-weight code models could make security review available without sending proprietary code to a hosted service. We study whether fine-tuning helps these models turn security evidence into explanations that developers and tools can check. We present secSemScan, which pairs a static analyzer with a locally deployable model that writes a schema-constrained security monologue naming program sites, assigning a CWE, and giving a machine-parseable verdict. We also introduce OGSM (Oracle-Grounded Security Monologue), a dataset of 1,993 C/C++ functions covering 22 CWEs in the taint and lifetime families. Each record pairs a function with analyzer-derived or fix-diff-derived evidence and a monologue. We fine-tune three open-weight code models in two stages, first on the output format and then on the monologue content. Because evaluation prompts supply the verdict and evidence, our results measure how well models use that information, not whether they detect vulnerabilities independently. On 355 test records, fine-tuning raised Qwen2.5-Coder-7B's verdict accuracy from 4.8% to 96.6%; DeepSeek-Coder-6.7B reached 78.9%, and StarCoder2-7B reached 43.7%. Qwen2.5-Coder-7B cited 87.5% of Tier 1 oracle sites, and every line it cited belonged to the oracle evidence. The results suggest that fine-tuning helps small models produce more structured, evidence-linked security reasoning.

Additional Key Words and Phrases: Code Security, LLM, Security Monologues, CWE, Security Semantics

1 Introduction

AI coding assistants can speed up development [24, 39], but the code they generate can contain vulnerabilities [12, 22]. Coding agents add to the review workload: a study of 128,018 GitHub projects estimates that 22.20%–28.66% had adopted them and reports more vulnerabilities in projects using agents than in projects developed without them [25]. Reviewing generated code is becoming a bottleneck [36]. At the same time, many organizations are reluctant to send proprietary code to third-party services [16, 19, 26]. These pressures motivate our question: can a relatively small, open-weight code model produce security explanations that developers can check and run locally?

We consider two requirements for such a reviewer. Its findings must be checkable (D1): each finding identifies the program sites that support it, so a developer or a tool can inspect the claim. It must also be local (D2): the model can run on hardware controlled by the organization, keeping proprietary code in-house. Existing approaches tend to meet one requirement more clearly than the other. Static analyzers run locally and report code locations, but cover only the weaknesses encoded in their rules and often provide little explanation for triage [20]. Learned detectors can also run locally, but commonly return a function-level label or suspicious lines rather than a trace of the sites needed to check a finding [7, 9]. Hosted LLMs can explain suspected vulnerabilities in prose [15, 35], but their explanations may be unfaithful [31], and using them requires sending code to an external service. Neuro-symbolic systems combine LLMs with program analysis [17, 18, 28, 32]; locally deployable models trained on teacher-generated reasoning take another route [7, 33]. These lines

Authors' Contact Information: Mostafijur Rahman Akhond, York University, Toronto, Canada, mostafij@yorku.ca; Mahmuda Khatun, York University, Toronto, Canada, mahmuda@yorku.ca; Gias Uddin, York University, Toronto, Canada, guddin@yorku.ca.

, Vol. 1, No. 1, Article . Publication date: October 2026.

of work leave open whether small, locally deployable models can be trained to express security evidence in a form that a tool can check.

We study two weakness families, taint and lifetime, because each can be characterized by a small tuple of program sites that a static analyzer can verify independently of the model. Both are established security problems: taint-style vulnerabilities are a common target of program analysis [30, 34], while memory-safety vulnerabilities include temporal errors such as use-after-free [29]. The two families also require different forms of program reasoning. For taint weaknesses such as CWE-78 and CWE-120, the evidence follows data flow and can be represented as a (source, sink) trace [34]; for lifetime weaknesses such as CWE-416, it follows object lifetime through an (alloc, free, use) trace [29]. A static analyzer can produce and verify these traces, but a bare trace is difficult for a developer to triage, while free-form prose is difficult for a tool to check. We therefore need an output that preserves this verifiable program evidence while presenting it as an explanation useful to developers.

We present secSemScan, a neuro-symbolic approach in which the analyzer supplies the evidence and a locally deployable model turns it into a readable, checkable explanation. Semgrep [27] with custom taint and lifetime rules serves as the analyzer. We fine-tune an open-weight code model with LoRA [13] to write a security monologue, adapting monologue reasoning [6]: a narration, constrained by a fixed schema, that names each site by identifier and line, assigns a CWE, and ends with a machine-parseable verdict. The symbolic component enters in three places. At data construction, the analyzer's trace, or the fix diff where no rule fires, is given to a generator LLM, so each narration names sites that come from the analyzer or the fix and not from the generator's own guess. At training and evaluation time, the prompt supplies the trace to the model. At inference, a fresh analyzer run checks the sites that a monologue names. We apply the approach to three open-weight models: Qwen2.5-Coder-7B [14], DeepSeek-Coder-6.7B [11], and StarCoder2-7B [21].

We study two questions. The first is monologue creation: can an open-weight model learn to write schema-conforming monologues that state the right verdict and CWE? The second is monologue usefulness: do the monologues contain what D1 requires, namely the oracle's sites, identifiers that occur in the code, and a CWE that agrees with the verdict? We define usefulness by these checkable properties and do not measure developer effort or triage time. We evaluate on OGSM (Oracle-Grounded Security Monologue), a dataset we construct from DiverseVul, PairVul, and MVD: 1,993 C/C++ functions (1,010 vulnerable, 983 safe) covering 22 CWEs, split by CVE into 1,248 training, 390 validation, and 355 test records. Each record pairs a function with a verdict, a CWE, evidence, and a security monologue, where the evidence is either an analyzer trace or the lines changed by a fix commit. Every prompt in the evaluation states the record's verdict, CWE, and oracle trace, so the evaluation measures whether a model turns a supplied trace into a narration.

On the 355 test records, fine-tuning raised verdict accuracy of Qwen2.5-Coder-7B from 4.8% to 96.6%, and the result is unchanged across five sampled outputs per record. The fine-tuned model cites 87.5% of the Tier 1 oracle sites (untuned: 60.0%), and every line it cites is an oracle site. The gain depends on the base model: verdict accuracy is 78.9% for DeepSeek-Coder-6.7B and 43.7% for StarCoder2-7B. Our checks test the surface of a narration, not whether its explanation is correct. A case study on five Linux kernel functions, in which Semgrep fires no rule, shows the model labeling all five VULNERABLE with the correct CWE.

This paper makes three contributions. First, OGSM, a C/C++ dataset in which each record pairs a function with a verdict, a CWE, evidence tagged by tier (analyzer-confirmed or diff-derived), and a security monologue. Second, a two-stage fine-tuning recipe that separates learning the schema from learning its content. Third, an evaluation of creation and usefulness, with rule-based checks that need no judge model. The design also checks a monologue's sites with a fresh analyzer run at

Analyst prompt

Is this function vulnerable? Name the sites.

Function (constructed example)

2: free(c->buf); 4: memcpy(c->buf, src, n);

(a) Distilled reasoning

Sample 0

memcpy at line 4 overflows c->buf.

CWE-787.

Sample 1

Missing bounds check on n before the copy.

CWE-120.

Sample 2

Frees c->buf at line 2, then uses it.

CWE-416.

No analyzer check

Samples disagree; claims remain

unverified

Unchecked claim

Reader redoes the analysis

(b) secSemScan

Evidence-constrained monologue

Name the program sites that support the security claim.

Monologue

free(c->buf), line 2, releases;

memcpy(c->buf, ...), line 4, uses.

CWE-416, VULNERABLE

Fresh Semgrep run

Recover the trace and check the sites named in the monologue.

Trace check: matched

The free (line 2) and use (line 4) appear in the trace.

Final verdict: insecure

Retained verdicts: secure or insecure

Fig. 1. A constructed use-after-free example. Panel (a) shows unchecked free-form reasoning; panel (b) shows secSemScan checking a monologue against a fresh Semgrep run. The illustrated final verdict is insecure; the retained verdicts are secure and insecure. The function and samples are invented for exposition.

inference, but the evaluation does not test this step, and whether the approach finds vulnerabilities that the analyzer’s rules miss remains open.