This study introduces a framework for identifying and repairing vulnerabilities in smart contracts by utilizing multi-relational graphs combined with a pre-trained model, significantly outperforming current baseline approaches.
Abstract
A smart contract fundamentally consists of code deployed on the blockchain, noted for its transparent and unchangeable execution. These characteristics, however, also expose it to attackers once any weaknesses are present. In recent years, attacks targeting smart contracts have caused substantial financial losses, highlighting the importance of robust vulnerability detection approaches. Conventional detection techniques, which rely on contextual semantics or symbolic execution, often face limitations in efficiency. Although neural network-based approaches have enhanced detection speed, they frequently compromise accuracy. This study introduces a framework for identifying and repairing vulnerabilities in smart contracts by utilizing multi-relational graphs combined with a pre-trained model. Initially, a Multi-Relational Graph (MRG) is constructed to represent the multi-dimensional aspects of execution logic and data dependencies by integrating multiple program feature graphs. To reduce interference from extraneous code, contract slices are then generated according to node and edge types defined within the MRG. These vectorized slices are subsequently processed by a pre-trained model called SCCodeBERT for both detection and repair of potential vulnerabilities. Experiments show that SCCodeBERT achieves an average accuracy of 96.06% and an F1-score of 90.90% on mainstream vulnerability datasets. Moreover, it reaches an average repair effectiveness of 86.42%, significantly outperforming current baseline approaches. This work presents a highly effective automated solution for enhancing smart contract security, offering notable theoretical and practical contributions.
As a core technology in blockchain-based systems, smart contracts are widely used in various fields. Meanwhile, their post-deployment immutability and financial nature render vulnerabilities attractive to attackers, as evidenced by significant economic losses, making smart contract vulnerability detection a critical task. Traditional detection tools mainly rely on vulnerability patterns derived from static program analysis, but are limited by expert experience and exhibit poor scalability. Recently, Large Language Models (LLMs) have emerged as a new solution for identifying smart contract vulnerabilities due to their remarkable capabilities in code understanding and reasoning. However, current prompting-based approaches are often restricted by high token overhead and the lack of domain-specific knowledge. To this end, this paper proposes an LLM-driven approach for detecting vulnerabilities in Ethereum smart contracts. First, we construct a heterogeneous graph that fuses control flow graphs (CFGs) and data flow graphs (DFGs) to capture the execution logic and transaction behavior of each smart contract with significantly reduced token consumption. Second, we leverage LLMs to extract key paths from each heterogeneous graph to filter out branches unrelated to vulnerabilities. Third, we build a knowledge repository based on the extracted key paths of both vulnerable and non-vulnerable smart contracts, together with a dual-metric retrieval mechanism. Finally, we design a Chain-of-Thought (CoT)-based prompt to guide vulnerability detection using the target smart contract's retrieved similar paths. Experiments on a public dataset of 1,093 smart contracts demonstrate the effectiveness of our approach, outperforming traditional tools by average improvements of 25.75% in accuracy and 31.44% in F1 score. Compared with LLM-based baselines, our approach achieves average improvements of 21.89% in accuracy and 26.91% in F1 score, along with a decrease of 52.88% in token consumption.
Yunhan Zhang, Yanxiang Tong, Ben Wang et al.· Annual International Compute...· 0 citations
This paper is a failure analysis of the representation layer underlying GNN-based smart contract vulnerability detectors. These systems convert source code into graphs before any learning takes place; if the graph fails to capture the code's semantics, no model improvement can compensate. We investigate GNNSCVulDetector and identify four failures. First, structurally different contracts produce byte-for-byte identical graphs, constituting a concrete evasion attack. Second, graph construction is governed by a hardcoded 47-entry variable whitelist (including one duplicate entry), which constrains what the extractor can recognise. As a consequence, identical vulnerabilities with different variable names produce inconsistent graphs, graph quality degrades as naming diverges from the whitelist, and when no entry matches the pipeline produces structural output not grounded in source variables. Third, the C node (the graph element representing the external caller that triggers a reentrancy attack) is absent from even the most canonical vulnerable contract in the literature. Fourth, a controlled experiment confirms this as a direct misclassification: a fully exploitable contract is labelled safe because the C ->W edge is never constructed. All four failures are demonstrated experimentally. Current accuracy figures in the literature are measured under conditions that do not expose these failures. We demonstrate one confirmed case of misclassification caused directly by a representation-layer failure; the prevalence of such failures in real-world contract populations remains an open empirical question.
Birindwa Prisca Hondi, Chinoso Philip Nwishienyi, Charity Wanja Mwaura et al.· 0 citations
Ethereum non-fungible tokens (NFTs) implement ownership, transfer, authorization, and metadata operations through smart contracts, making contract vulnerabilities a direct risk to digital assets. Existing static analyzers provide efficient rule-based screening but can struggle with application-specific logic, whereas unconstrained large language model analysis may be distracted by irrelevant code or produce inconsistent outputs. We present a vulnerability-detection method that combines vulnerability-focused code slicing, an ERC-721-oriented knowledge base, and constrained DeepSeek analysis. Regular-expression patterns locate candidate statements for reentrancy, integer overflow or underflow, and timestamp dependence. A structure-aware context-window algorithm then extracts line-numbered code slices. DeepSeek analyzes each slice using explicit decision rules and a fixed output schema, and the resulting records support automated batch processing. On 450 NFT contract samples, the full configuration produced 437 positive labels, corresponding to a reported positive-label rate of 97.1%. Removing the external knowledge base reduced this rate to 87.11%, while analyzing complete contracts without the knowledge base reduced it to 73.78%. These results indicate that focused code context and domain constraints materially affect the detector's reported output.
Smart contract vulnerabilities remain a major source of financial loss in blockchain ecosystems. A large body of work has investigated automated detection using static analysis, symbolic execution, and more recently large language models (LLMs). While these approaches are effective for many syntactic and arithmetic issues, logic-centric vulnerabilities often require connecting dispersed evidence across code structure, security knowledge, and protocol assumptions. In this setting, promptonly LLM-based auditing can be brittle. Retrieval augmentation helps by supplying external knowledge, yet the retrieved evidence is not always well aligned with contract-specific code cues, which can still result in over-triggering and limited auditability. This paper presents GraphShield, a retrieval-augmented framework for smart contract vulnerability detection that grounds model judgments on complementary evidence. The key idea is to organize heterogeneous security knowledge and contract-structure cues into dual knowledge graphs, retrieve compact subgraph evidence for a target contract, and guide the model to produce an evidence-backed detection report that is suitable for auditor review. We evaluate GraphShield on a curated benchmark of audited contracts under a unified bug taxonomy. The results show that GraphShield improves detection effectiveness over representative prompting-based baselines, achieving a better balance between coverage and precision, and providing more verifiable rationales to support downstream manual inspection.
Yangzezhi Zheng, Yangbo Zhou, Yichen Wang et al.· Annual International Compute...· 0 citations