Robust Smart Contract Vulnerability Detection via Contrastive Learning-Enhanced Granular-ball Training
Zeli Wang, Qingxuan Yang, Shuyin Xia, Yueming Wu, Bo Liu, Longlong Lin · 2026
Read Robust Smart Contract Vulnerability Detection via Contrastive Learning-Enhanced Granular-ball Training by Zeli Wang, Qingxuan Yang, Shuyin Xia, Yueming Wu, Bo Liu, Longlong Lin (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2603-27734.txt.
Introduction
Wang and co-authors harden smart contract bug hunting against noisy labels. Labels often come from tools of unsure accuracy. Their CGBC method inserts a granular-ball layer into the network. Similar contracts group into balls with shared centers. Ball labels can correct single noisy labels. Contrastive learning sharpens the feature space further. Compactness losses act between and within balls. Tests show stronger robust detection scores.
Catalog record
| CREATOR | Zeli Wang, Qingxuan Yang, Shuyin Xia, Yueming Wu, Bo Liu, Longlong Lin |
|---|---|
| YEAR | 2026 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 60248 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2603.27734
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Robust Smart Contract Vulnerability Detection via Contrastive Learning-Enhanced Granular-ball Training Zeli Wang, Qingxuan Yang, Shuyin Xia, Yueming Wu, Bo Liu, Longlong Lin Abstract Blockchain has become the fundamental infrastructure for building a digital economy society. As the key technology to implement Blockchain applications, smart contracts face serious security vulnerabilities. Deep neural networks (DNNs) have emerged as a prominent approach for detecting smart contract vulnerabilities, driven by the growing contract datasets and advanced deep learning techniques. However, DNNs typically require large-scale labeled datasets to model the relationships between contract features and vulnerability labels. In practice, the labeling process often depends on existing open-sourced tools, whose accuracy cannot be guaranteed. Consequently, label noise poses a significant challenge for the accuracy and robustness of the smart contract, which is rarely explored in the literature. To this end, we propose C ontrastive learning-enhanced G ranular- B all smart C ontracts training, CGBC, to enhance the robustness of contract vulnerability detection. Specifically, CGBC first introduces a Granular-ball computing layer between the encoder layer and the classifier layer, to group similar contracts into Granular-Balls (GBs) and generate new coarse-grained representations (i.e., the center and the label of GBs) for them, which can correct noisy labels based on the most correct samples. An inter-GB compactness loss and an intra-GB looseness loss are combined to enhance the effectiveness of clustering. Then, to improve the accuracy of GBs, we pretrain the model through unsupervised contrastive learning supported by our novel semantic-consistent smart contract augmentation method. This procedure can discriminate contracts with different labels by dragging the representation of similar contracts closer, assisting CGBC in clustering. Subsequently, we leverage the symmetric cross-entropy loss function to measure the model quality, which can combat the label noise in gradient computations. Finally, extensive experiments show that the proposed CGBC can significantly improve the robustness and effectiveness of the smart contract vulnerability detection under various noisy settings when contrasted with baselines. I Introduction Blockchain is a distributed and decentralized ledger technology, which has been widely applied across various domains [ 40 , 19 ] . Smart contracts, which serve as the core mechanism for automating and enforcing business logic on blockchain platforms, have become indispensable for enabling these applications. However, the prevalence of security vulnerabilities in smart contracts remains a major obstacle, significantly hindering the broader adoption and real-world deployment of blockchain-based solutions [ 43 , 12 , 42 ] . Vulnerability detection is a widely studied approach to enhancing smart contract security. Traditional program analysis methods often depend on manually defined vulnerability patterns, which are constrained by expert knowledge and struggle to scale with the intricate logic semantics of smart contracts [ 45 , 29 , 23 ] . Deep learning offers a promising solution by automatically learning vulnerability patterns through its powerful pattern recognition capabilities [ 1 , 28 , 10 , 4 , 33 ] . MTVHunter leverages multiple teacher models to guide the training process by aggregating their predictions into more accurate soft labels, improving robustness and accuracy [ 33 ] . Clear achieves significant detection accuracy improvements by generating labeled contract pairs through data sampling and extracting semantic features using a Transformer module, followed by model fine-tuning for vulnerability detection [ 4 ] . Although these learning-based models have achieved remarkable performance in detecting smart contract vulnerabilities, their effectiveness relies on extensive high-quality labeled datasets. In practice, existing smart contract datasets are generally annotated by open-source tools [ 1 , 28 , 4 ] However, the accuracy of current contract vulnerability detection tools is far from expectations: for example, the empirical study on 47,587 contracts and nine tools demonstrate that only 42% of contract vulnerabilities are detected [ 6 ] ; the research conducted on 18 contract detection tools proves that they have poor performance. Consequently, the existing tool-based label procedure will inevitably introduce much label noise, which can significantly degrade model performance [ 32 ] . Thus, mitigating the impact of label noise on learning-based vulnerability detection is urgent. Much research has been conducted to resolve the label noise in computer vision [ 37 , 48 ] and natural language processing [ 47 , 46 ] , but only a few studies explore this problem in software vulnerability detection. ACGVD [ 14 ] adopts a framework that combines GNN and GAT, constructing a comprehensive graph representation that integrates various types of information from source code. This approach mitigates the noise interference that may arise from relying on a single information source, enhancing the model’s ability to adapt to complex data. [ 25 ] designs adaptive graph convolution operations that allow the model to adjust to noisy patterns automatically, and employs a weighted loss function to mitigate the impact of noisy labels. These tools demonstrate that deep learning-based vulnerability detection methods in traditional software systems are susceptible to label noise and propose effective mitigation strategies. However, these approaches cannot be directly generalized to smart contracts due to their fundamental differences, such as programming languages and logical architectures. To the best of our knowledge, no countermeasures have been proposed to address label noise in smart contract vulnerability detection frameworks. An intuitive way to address this problem is to identify and correct noisy labels. However, it is nontrivial and computationally exhaustive to spot all noisy labels precisely. To alleviate this dilemma, bearing the core observation that most samples are correctly annotated, we aim to cluster similar smart contracts and remove noise through the centers of clusters, which represent the common features and most labels. There are two key challenges to achieve this goal: (1) generating close embeddings for similar contracts. The embeddings of smart contracts determine their similarity, namely, the correctness of clustering. Since smart contracts have complicated code structures and diverse user-defined variables, it is tricky to embed contracts with the same labels closely. (2) Adaptively clustering smart contracts. Smart contracts even belonging to the same category may have distinct representative features. This implies that smart contracts should be clustered according to their data distribution features, rather than strictly clustering the contracts with the same label into a set. Such requirements ask for an adaptive multi-granularity clustering approach. To overcome these challenges, we propose a novel robust training approach for learning-based smart contract detection models through contrastive learning-enhanced Granular-ball computing (CGBC). Our CGBC achieves coarse-grained representation learning through a Granular-ball (GB) clustering layer. The label and vector representation of a GB center are the new coarse-grained representation for all samples in the current GB. This procedure can correct noisy labels and diminish their influence. To address the first challenge and bring similar contracts closer, we pretrain CGBC with unsupervised contrastive learning to optimize the embeddings of smart contracts. Additionally, we introduce the intra-GB compactness loss and inter-GB looseness loss function to the fine-tuning loss function to further pull the embeddings of similar contracts closer. For the second challenge, we adopt the Granular-ball computing method, an adaptively multi-granularity clustering algorithm, to automatically group smart contracts following data distribution features, without predefined parameters such as the amount or size of sets. By integrating these designs, CGBC realizes robust vulnerability detection for smart contracts. We conduct extensive experiments on a large-scale dataset across three common vulnerability types: Reentrancy (RE), Timestamp Dependency (TD), and