arXiv:2610.11801cs.SEOct 2026

Manuscript Offprint

arXiv:2610.11801

ObliVul: Alert-Conditioned Safety Obligation Modeling and Bidirectional Counterfactual Validation for Code Vulnerability Detection

Heyang Tan, Chengxin Gao, Xin Wen, Jiaxin Li, Rui Cao

HEYANG TAN, Taiyuan University of Technology, China

CHENGXIN GAO, Taiyuan University of Technology, China

XIN WEN, Taiyuan University of Technology, China

JIAXIN LI, Taiyuan University of Technology, China

RUI CAO, Taiyuan University of Technology, China

In real-world software development, the primary challenge in vulnerability detection is often not finding suspicious code, but identifying which alerts among the large number of candidate alerts produced by static analysis truly warrant attention. Existing learning-based methods mainly identify suspicious patterns at the function or line level, making it difficult to extract complete program evidence centered on an individual alert. Although large language models can infer risk sources, dangerous operations, protection conditions, and state preconditions from local program facts, such semantic information cannot be reliably aligned with specific program nodes, dependency relations, and propagation paths, and is therefore insufficient to verify whether the corresponding safety obligations truly affect the current alert. To address this problem, we propose OBLIVUL, an alert-conditioned safety obligation modeling and bidirectional counterfactual validation framework for vulnerability detection. For each candidate alert, OBLIVUL first extracts a Local Evidence Pack (LEP) from the Code Property Graph (CPG) and uses a large language model to recover candidate safety obligations. It then aligns the safety obligations with program nodes, dependency edges, and path scopes to construct a Local Safety Obligation Graph (LSOG). Finally, VAFI aggregates complementary verified alert evidence while suppressing redundant or weaker evidence to produce a function-level vulnerability prediction. Experimental results show that OBLIVUL effectively distinguishes vulnerable versions from fixed versions and reduces persistent false positives on fixed code. Ablation studies further confirm the necessity of each component for safety obligation recovery, risk response validation, and function-level vulnerability inference.

CCS Concepts: • Security and privacy → Software security engineering; • Software and its engineering → Software testing and debugging.

Additional Key Words and Phrases: vulnerability detection, static-analysis alerts, code property graphs, large language models, counterfactual validation, safety obligations, LLM-guided safety obligation recovery

1 Introduction

In real-world software development, the foremost challenge in vulnerability detection is often not finding suspicious code, but determining which alerts among a large number truly warrant attention. However, to cover potential risks, static analysis usually needs to conservatively approximate factors such as path reachability and alias relationships, thereby producing large numbers of unverified potential-vulnerability leads. We refer to such leads as candidate vulnerability alerts, hereafter abbreviated as “alerts,” and define a safety obligation (SO) as a security condition on which the validity or invalidity of an alert depends and that can be supported by program evidence and further checked. Alert validation therefore faces three questions: how to extract relevant program evidence around an individual alert, how to recover from this evidence the safety obligations that affect whether the alert is valid, and how to verify that the recovered safety obligations actually act on the current risk.

Authors' Contact Information: Heyang Tan, thy15333007817@163.com, Taiyuan University of Technology, Taiyuan, China; Chengxin Gao, gaochengxin@tyut.edu.cn, Taiyuan University of Technology, Taiyuan, China; Xin Wen, xwen@tyut.edu.cn, Taiyuan University of Technology, Taiyuan, China; Jiaxin Li, lijiaxin1926@link.tyut.edu.cn, Taiyuan University of Technology, Taiyuan, China; Rui Cao, caorui@tyut.edu.cn, Taiyuan University of Technology, Taiyuan, China.

Heyang Tan, Chengxin Gao, Xin Wen, Jiaxin Li, and Rui Cao

First, existing methods typically take a complete function, code slice, or statement sequence as the prediction object and output function-level labels or line-level suspiciousness by learning lexical, syntactic, and contextual patterns [3–5]. Predicting a function as vulnerable does not imply that every alert within it is valid, and line-level suspiciousness cannot establish whether an alert has complete support from data dependencies, control dependencies, and path reachability. In particular, when vulnerable and fixed versions share most code structures and dangerous operations, methods that rely on holistic function representations tend to produce the same prediction for both versions [6, 7]. Second, recovering the safety obligations that affect whether an alert is valid from local program facts remains challenging. Whether an alert is valid depends on whether external input can reach a dangerous operation, whether the relevant branches are reachable, and whether protection or sanitization measures cover the risk path and take effect before the dangerous operation. Although a Code Property Graph (CPG) can uniformly represent abstract syntax, control flow, data dependencies, and call relations, it is difficult for a CPG to directly characterize safety obligations together with their validity, satisfaction status, and scope.

An LLM can infer risk sources, dangerous operations, protection conditions, and state preconditions from local program facts [8, 9], but existing LLM-enhanced methods typically output only vulnerability labels, risk scores, natural-language explanations, or repair suggestions. These outputs are difficult to reliably align with concrete program nodes, dependency edges, and propagation paths, and are also difficult to further check through program analysis. The safety semantics recovered by an LLM must therefore be anchored to concrete program structures and organized as safety obligations with program locations, satisfaction status, scopes, and relational constraints.

Finally, even when safety obligations have been identified and anchored to program structures, model explanations or static correspondences alone remain insufficient to determine whether they genuinely affect the current alert. However, existing studies mostly use vulnerable/fixed pairs for model training, result comparison, or patch identification [10–12][10–12] and rarely verify whether changes in safety obligations cause risk responses along the same alert path. More reliable alert validation must not only determine the data and control dependencies among inputs, protection conditions, and dangerous operations, but also perform local interventions constrained by program structures to observe whether risk decreases after missing protection is added and whether risk reappears after existing protection is removed.

To address these problems, we propose OBLIVUL, an alert-driven bidirectional counterfactual graph-validation framework. It first extracts alert-relevant context from a function-level CPG to form a Local Evidence Pack (LEP). It then uses an LLM to recover alert-related safety semantics, maps the semantics to program nodes, dependency edges, and propagation paths to form safety obligations, and further constructs a Local Safety Obligation Graph (LSOG). Next, it compiles the safety obligations into two types of graph interventions—adding missing protection and removing existing protection—analyzes the resulting risk changes, and extracts minimal supporting evidence. The main contributions of this work are as follows:

  1. We propose an alert-conditioned local safety-obligation modeling method. Centered on an individual alert, the method extracts relevant program facts from a function-level CPG to form an LEP, uses an LLM to recover alert-related safety obligations, and constructs an LSOG by checking their correspondences with program nodes, dependency edges, and propagation paths.

  2. We propose a bidirectional counterfactual graph-validation mechanism for safety obligations. By adding missing protection and removing existing protection, it observes risk reduction and risk restoration, respectively, and combines the consistency between the original and counterfactual paths to extract minimal supporting evidence and generate alert-level validation results.

ObliVul: Alert-Conditioned Safety Obligation Modeling and Bidirectional Counterfactual Validation for Code Vulnerability Detection

3

  1. We propose VAFI, a validation-aware function-level vulnerability inference method. VAFI encodes local program structures, safety obligations, and counterfactual validation results as alert-evidence units, models complementarity and redundancy among different alerts, and coordinates predictions at different levels through alert-level, function-level, and vulnerable/fixed-pair constraints, thereby suppressing the excessive influence of duplicated or weak evidence on the final prediction.

  2. We conduct a preliminary real-world validation of ObliVul on the Linux kernel, using the trained model to prioritize alerts and combining it with manual review to identify four real vulnerabilities. We then prepare and submit the corresponding patches, three of which have been merged into the official Linux repository.

References (38)