TL;DR
VulWeaver is a novel neuro-symbolic, LLM-based approach that fixes inaccurate program representations and extracts holistic context to accurately detect source code vulnerabilities. By combining deterministic static analysis rules with LLM semantic inference and structured meta-prompting, it significantly reduces false positives and resists adversarial tricks like identifier renaming.
What Problem Does This Paper Address?
Automated vulnerability detection is caught between two flawed paradigms. Traditional Static Application Security Testing (SAST) tools scale well but struggle with complex language features like polymorphism and reflection, leading to inaccurate program representations (broken semantics). Conversely, Large Language Models (LLMs) excel at understanding code text but suffer from a lack of global context and a tendency to rely on superficial pattern matching (e.g., guessing a function is vulnerable just because a variable is named password).
When existing methods attempt to bridge this gap using program slicing, they often provide LLMs with fragmented, unidirectional code snippets that omit critical implicit context like global configurations, type declarations, or downstream sanitization logic. VulWeaver addresses this dual challenge: incomplete vulnerability context and unstructured LLM reasoning.
Methods
VulWeaver operates in three main stages to ensure grounded reasoning:
- Unified Dependency Graph (UDG) Construction & Neuro-Symbolic Enhancement: It starts with a base graph from the open-source tool Joern. To fix static analysis inaccuracies, VulWeaver uses a neuro-symbolic strategy: it injects global nodes via Tree-sitter, leverages an LLM to resolve ambiguous polymorphic and reflective call edges, and applies deterministic rules to restore non-local control flows (like labeled jumps) and prune spurious data dependencies.
- Holistic Vulnerability Context Extraction: Instead of relying solely on standard explicit slicing, VulWeaver extracts both explicit context (forward/backward data and control flows) and implicit context. This includes usage context (how variables are handled inside callees), definition context (tracing upstream initializations of unresolved variables), and declaration context (imports and packages needed for unambiguous type resolution).
- Context-Aware LLM Reasoning: Rather than using standard Chain-of-Thought (CoT) prompting, VulWeaver implements a structured meta-prompting framework. It guides the LLM through a strict, four-step, CWE-specific expert trajectory (Contextual Flow Understanding, Trigger Condition Verification, Defense Assessment, and Evidence-Driven Verdict Synthesis). Finally, it uses majority voting over multiple independent queries to mitigate LLM randomness.
Datasets
- PrimeVul4J: A high-quality, denoised, and chronologically split Java vulnerability dataset curated by the authors following the rigorous methodology of the original C/C++ PrimeVul benchmark. It contains 1,620 unique functions (790 vulnerable, 830 non-vulnerable) spanning 102 distinct CWE types.
- C/C++ PrimeVul: Used directly to evaluate the cross-language generalizability of VulWeaver.
Key Insights and Ideas
- The Fragility of Lexical Cues: A pilot study revealed that standard CoT prompting is incredibly fragile when faced with adversarial semantic-preserving changes. Simply prepending
non_vulnerableto identifiers in vulnerable code caused massive performance drops in vanilla LLMs. Meta-prompting forces the model to anchor its logic in dataflows and control dependencies rather than superficial names. - Neuro-Symbolic Feedback Loops: Pure static analysis cannot resolve dynamic features like reflection, but pure LLMs hallucinate code paths. By using the LLM to predict missing graph edges under strict confidence thresholds, and then using that enhanced graph to slice the code, VulWeaver creates a highly accurate, self-contained semantic unit for final analysis.
Key Results
- State-of-the-Art Performance: On the PrimeVul4J dataset, VulWeaver achieved a precision of 0.82, recall of 0.71, and F1-score of 0.76, outperforming the best learning-based, LLM-based, and agent-based baselines by 25%, 17%, and 21% in F1-score, respectively.
- Pairwise Discrimination: VulWeaver achieved a VP-S score of 0.58 (a metric measuring the ability to distinguish a vulnerable pre-patch function from its non-vulnerable post-patch counterpart), outperforming the best baseline by 164%.
- Real-World Impact: In an evaluation of 9 real-world Java projects, VulWeaver detected 26 true, previously unknown vulnerabilities (15 confirmed by developers, 5 CVEs assigned). In an industrial deployment with a major tech company, it identified 40 confirmed vulnerabilities with a False Discovery Rate (FDR) of just 0.17.
Limitations and Future Work
- Language-Specific Heuristics: While the framework is conceptually language-agnostic (and performed well on C/C++), its current graph-enhancement heuristics are optimized for Java features like reflection and do not yet support dynamic languages like Python or JavaScript.
- Asynchronous Control Flows: The tool cannot currently capture implicit cross-function control flows introduced by asynchronous callbacks (e.g.,
CompletableFuture). - Predefined Sinks: VulWeaver relies on a static slicing strategy with predefined sensitive APIs and cannot automatically discover entirely new vulnerability sinks. The authors plan to explore LLM agents for adaptive, on-demand sink discovery in future work.
Summary updated