ContractScanner: Detecting and Localizing Vulnerabilities of Smart Contracts via Graph-Based Semantic Modeling of Source Code
Smart contract vulnerabilities pose persistent threats to decentralized applications, causing substantial financial losses across the Web 3.0 ecosystem. Although recent deep learning-based detectors improve scalability, they face two key limitations: (i) limited semantic fidelity because bytecode- or sequence-level representations fail to capture contextual dependencies; and (ii) inadequate vulnerability localization, as most approaches are confined to contract-level classification, limiting their audit utility. To address these challenges, we present ContractScanner for joint vulnerability detection and fine-grained localization directly from the source code. First, we propose an anchor-aware semantic slicing method to filter contracts into vulnerability-relevant regions by matching structural anchor patterns and preserving contextual dependencies. Second, we transform these slices into heterogeneous program graphs that encode control, data, and syntactic flows.We then apply a dual-stage reasoning pipeline. A Graph Isomorphism Network (GIN) extracts global structural features for contract-level classification, while a Graph Autoencoder (GAE) reconstructs fine-grained topological patterns to localize vulnerability-critical code regions. Third, to address data scarcity, we introduce anchor-guided G-Mixup, which generates augmented training samples by interpolating feature embeddings of contract slices with similar vulnerability semantics. We evaluate ContractScanner on two real-world benchmarks spanning five major vulnerability types—reentrancy, integer overflow/underflow, timestamp dependency, and callstack depth exhaustion. Our method achieves an average F1-score of 94.74%, significantly outperforming symbolic analyzers, classical learning models, and prior graph-based methods.
Authors
- Xiaohan Yuan (ORCID: https://orcid.org/0000-0002-8489-4018)
- Xueshuo Xie (ORCID: https://orcid.org/0000-0002-8245-8415)
- Shan Li (ORCID: https://orcid.org/0009-0007-2822-2392)
- Bin Wang
- Wei Wang (ORCID: https://orcid.org/0000-0002-5477-1017)
- Tao Li (ORCID: https://orcid.org/0000-0002-4913-4486)
- Junyong Wang (ORCID: https://orcid.org/0000-0003-3797-6819)
- Bin Wang
Institutions
- Beijing Jiaotong University (CN)
- Zhejiang Lab (CN)
- Tianjin haihe hospital (CN)
Publication Details
- Journal
- IEEE Transactions on Network Science and Engineering
- Published
- 2025-06-27
- DOI
- https://doi.org/10.1109/tnse.2025.3583926
- Primary Topic
- Blockchain Technology Applications and Security
- Type
- article
- Field-Weighted Citation Impact
- 0.00