arXiv:2610.34928cs.SEOct 2026

Manuscript Offprint

arXiv:2610.34928

SemWeaver: Refining LLM-Generated Static Vulnerability Checkers with Analyzer-Internal Evidence

Chengzhi Yi, Shenao Wang, Yanjie Zhao, Xiao Cheng, Haoyu Wang

CHENGZHI YI, Huazhong University of Science and Technology, China

SHENAO WANG, Huazhong University of Science and Technology, China

YANJIE ZHAO, Huazhong University of Science and Technology, China

XIAO CHENG, Macquarie University, Australia

HAOYU WANG, Huazhong University of Science and Technology, China

Recent work shows that LLMs can synthesize static-analysis checkers from security patches, but a compilable checker is not necessarily a correct one. A patch reveals what changed, not why the change is safe, so generated checkers often match only the surface edit and miss the deeper semantic condition. Existing refinement loops feed back compilation errors and validation reports, yet these signals describe symptoms without explaining what the checker misunderstands about the code.

We observe that the analysis framework itself already computes the information needed to close this gap. Control-flow graphs, symbolic values, memory regions and checker callbacks are available inside the analyzer but unused by current refinement strategies. SEMWEAVER is a plug-in refinement layer that extracts patch-relevant analyzer evidence and assembles it with source context and validation feedback into a structured, provenance-labelled bundle. An iterative editing loop refines the checker on both the vulnerable and fixed revisions, guarded by a retention gate that accepts warning recovery or false-positive reduction while preventing over-pruning.

We evaluate SEMWEAVER on 39 KNighter-derived CSA checkers from Linux kernel fixes. With analyzer evidence, refinement reaches 23 warning-positive vulnerable revisions (vs. 15 for KNighter's loop) and raises version-level F1F_{1} from 0.448 to 0.575. An ablation removing internal evidence recovers fewer silent cases and produces different checker edits, indicating that the two evidence configurations address complementary recognition gaps. Additional experiments cover three editor models on a 12-subject subset, a CodeQL query refinement, and controlled source-form variations. A qualitative follow-up on all 11 non-tied comparisons traces each warning-count change to a specific checker repair, such as recognizing a lowered callback or unwrapping an expression cast.

CCS Concepts: • Software and its engineering → Automated static analysis; • Security and privacy → Systems security.

Additional Key Words and Phrases: static analysis, vulnerability checkers, large language models, patch-guided refinement

1 Introduction

Static analysis is a cornerstone of software security assurance for systems code. Tools such as CodeQL [18] and Clang Static Analyzer (CSA) [37] detect vulnerabilities by checking source code against predefined rules without executing it [4, 7, 15, 49]. The effectiveness of these tools depends on the quality of their vulnerability checkers, each of which must encode the semantic conditions that distinguish a real bug from safe code. Writing such checkers by hand requires expertise in both the target codebase and the analysis framework, making manual authoring expensive and difficult to scale.

LLM-based patch-driven synthesis offers a promising alternative. In this paradigm, a security patch serves as a compact before-and-after specification: the LLM consumes the patch and synthesizes a checker that should fire on the vulnerable revision but remain silent on the fixed revision.

Authors' Contact Information: Chengzhi Yi, Huazhong University of Science and Technology, China, yimou@hust.edu.cn; Shenao Wang, Huazhong University of Science and Technology, China, shenaowang@hust.edu.cn; Yanjie Zhao, Huazhong University of Science and Technology, China, yanjie_zhao@hust.edu.cn; Xiao Cheng, Macquarie University, Australia, jumormt@gmail.com; Haoyu Wang, Huazhong University of Science and Technology, China, haoyuwang@hust.edu.cn.

Yi et al.

KNighter [60], a representative system, has demonstrated that this approach can produce compilable and executable CSA checkers from historical Linux kernel fixes.

However, a compilable checker is not necessarily a correct one. The difficulty is that a patch shows what changed in the code, but not why the change makes the code safe. Consider a one-character fix that tightens a loop bound from i < N to i < N-1: the real reason this works is that it prevents an array access at i+1 from exceeding the array's capacity. A checker that merely looks for the old loop bound but does not understand the array access behind it will either report both versions or detect neither. Attempting to fix such a checker can also backfire: edits that suppress spurious reports may simultaneously remove the trigger for the true bug, a failure mode we call over-pruning.

A natural response is to iteratively refine the checker using feedback. Existing strategies, including KNighter's own loop, feed compilation errors and validation reports back to the LLM so it can edit the checker [40, 53, 60]. Yet this feedback only describes symptoms. A message such as "the vulnerable side is silent" tells the model that something is wrong, but not what the checker misunderstands about the code. A cleanup attribute may name a lowered callback that the checker never recognizes. A cast may hide the expression expected by a callback. A state lookup may use a different region from the preceding update.

Our key observation is that the analysis framework itself already computes the semantic information needed to close this gap, but existing refinement loops do not use it. CSA, for example, exposes control-flow graphs, symbolic values, memory regions and checker callbacks. CodeQL provides similar depth through its program database and queries [2,18][2, 18]. This information can reveal why a checker misses a vulnerability, not just that it does. The challenge is selecting the relevant parts of this rich output and relating them to the patch and the checker under refinement.

We present SEMWEAVER, a refinement framework that bridges this gap by feeding analyzer-internal evidence into the LLM's editing loop. Where existing refinement loops rely primarily on compilation and report feedback, SEMWEAVER additionally extracts semantic context from the analyzer itself: a rule-guided preflight selects patch-relevant views such as control-flow structure, symbolic-value bindings and checker callback traces, so the model can see what the checker actually observes at runtime rather than guess from silence alone. These facts are assembled with source context and validation feedback into a typed evidence bundle with explicit provenance, giving the model a structured diagnosis instead of a flat error log. The agent then edits the checker and validates it on both revisions, guarded by a retention gate that accepts warning recovery or false-positive reduction but rejects edits that lose an existing vulnerable-side warning, directly countering the over-pruning problem.

This paper makes the following contributions:

  • We identify a gap between paired warning feedback and the analyzer’s representation of the code a generated checker inspects. We define analyzer-internal evidence by its backend origin, extraction interface and source binding, and study how it can guide edits to an existing checker rather than regenerate one.

  • To address this gap, we build SEMWEAVER as an end-to-end plug-in refinement system. It selects patch-relevant views, joins analyzer, source and validation records in a typed, provenance-labelled bundle, and iteratively edits, compiles and scans the detector on both revisions. A retention gate accepts warning recovery or fixed-side report reduction without losing an existing vulnerable warning. The main implementation targets CSA, with a separate CodeQL query adapter.

  • We then evaluate all 39 selected generated-only Linux CSA checkers from the same starting artifacts, comparing the actual KNighter refinement loop with native and no-internal refinement. Native recovers eight initially silent vulnerable revisions; the ablation without internal evidence recovers six, with each arm repairing cases the other does not, indicating that internal and source-derived evidence address complementary recognition gaps. We also repeat the evidence comparison on 12 subjects, run three editor configurations three times on that subset, refine an archived CodeQL query in three decodes, and inspect all 11 non-tied comparisons alongside controlled source changes. These analyses trace each warning-count change to a specific checker repair, such as recognizing a lowered callback or unwrapping an expression cast.

References (42)