Oumaima Fadi , Adil Bahaj , Karim Zkik , Abdellatif El Ghazi , Mounir Ghogho , Mohammed Boulmalf
{"title":"Smart contract anomaly detection: The Contrastive Learning Paradigm","authors":"Oumaima Fadi , Adil Bahaj , Karim Zkik , Abdellatif El Ghazi , Mounir Ghogho , Mohammed Boulmalf","doi":"10.1016/j.comnet.2025.111121","DOIUrl":null,"url":null,"abstract":"<div><div>Smart contracts are digital agreements automating the execution of transactions in a decentralized manner. Although they offer many advantages, smart contracts are prone to multiple security vulnerabilities that might cause severe financial losses. Traditional anomaly detection methods, including Machine Learning and Deep Learning, struggle to capture the complexity of smart contract features. Recent advancements have utilized graph neural networks (GNNs) by transforming smart contracts into graphs. However, these approaches face robustness challenges due to small data sizes and model overparameterization. To address these issues, this paper proposes <strong>ACAD</strong> (<strong>A</strong>daptive <strong>C</strong>ontrastive Learning for Smart Contract <strong>A</strong>ttack <strong>D</strong>etection), a novel framework employing a two-phase training process for smart contract classification. After converting smart contract codes to representative graphs, the task-agnostic features are learned using graph contrastive learning with adaptive augmentations. Next, these features are utilized for smart contract vulnerability classification in a downstream task. Unlike previous works, which rely on a single-phase GNN-based approach, ACAD leverages contrastive learning to improve robustness and generalization. This approach effectively overcomes data scarcity while capturing richer and more distinctive representations. Extensive experiments demonstrate that ACAD outperforms baseline models, achieving 95.7% accuracy and 92.44% precision in reentrancy attack detection, which represents an improvement of 5.78% in accuracy and 6.19% in precision compared to the best-performing baseline model.</div></div>","PeriodicalId":50637,"journal":{"name":"Computer Networks","volume":"260 ","pages":"Article 111121"},"PeriodicalIF":4.4000,"publicationDate":"2025-02-15","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Computer Networks","FirstCategoryId":"94","ListUrlMain":"https://www.sciencedirect.com/science/article/pii/S1389128625000891","RegionNum":2,"RegionCategory":"计算机科学","ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q1","JCRName":"COMPUTER SCIENCE, HARDWARE & ARCHITECTURE","Score":null,"Total":0}
引用次数: 0
Abstract
Smart contracts are digital agreements automating the execution of transactions in a decentralized manner. Although they offer many advantages, smart contracts are prone to multiple security vulnerabilities that might cause severe financial losses. Traditional anomaly detection methods, including Machine Learning and Deep Learning, struggle to capture the complexity of smart contract features. Recent advancements have utilized graph neural networks (GNNs) by transforming smart contracts into graphs. However, these approaches face robustness challenges due to small data sizes and model overparameterization. To address these issues, this paper proposes ACAD (Adaptive Contrastive Learning for Smart Contract Attack Detection), a novel framework employing a two-phase training process for smart contract classification. After converting smart contract codes to representative graphs, the task-agnostic features are learned using graph contrastive learning with adaptive augmentations. Next, these features are utilized for smart contract vulnerability classification in a downstream task. Unlike previous works, which rely on a single-phase GNN-based approach, ACAD leverages contrastive learning to improve robustness and generalization. This approach effectively overcomes data scarcity while capturing richer and more distinctive representations. Extensive experiments demonstrate that ACAD outperforms baseline models, achieving 95.7% accuracy and 92.44% precision in reentrancy attack detection, which represents an improvement of 5.78% in accuracy and 6.19% in precision compared to the best-performing baseline model.
期刊介绍:
Computer Networks is an international, archival journal providing a publication vehicle for complete coverage of all topics of interest to those involved in the computer communications networking area. The audience includes researchers, managers and operators of networks as well as designers and implementors. The Editorial Board will consider any material for publication that is of interest to those groups.