Checking Smart Contracts With Structural Code Embedding

被引:69
|
作者
Gao, Zhipeng [1 ]
Jiang, Lingxiao [2 ]
Xia, Xin [1 ]
Lo, David [2 ]
Grundy, John [1 ]
机构
[1] Monash Univ, Fac Informat Technol, Melbourne, Vic 3800, Australia
[2] Singapore Management Univ, Sch Informat Syst, Singapore 188065, Singapore
基金
澳大利亚研究理事会;
关键词
Computer bugs; Smart contracts; Cloning; Blockchains; Security; Smart contract; code embedding; clone detection; bug detection; ethereum; blockchain;
D O I
10.1109/TSE.2020.2971482
中图分类号
TP31 [计算机软件];
学科分类号
081202 ; 0835 ;
摘要
Smart contracts have been increasingly used together with blockchains to automate financial and business transactions. However, many bugs and vulnerabilities have been identified in many contracts which raises serious concerns about smart contract security, not to mention that the blockchain systems on which the smart contracts are built can be buggy. Thus, there is a significant need to better maintain smart contract code and ensure its high reliability. In this paper, we propose an automated approach to learn characteristics of smart contracts in Solidity, which is useful for clone detection, bug detection and contract validation on smart contracts. Our new approach is based on word embeddings and vector space comparison. We parse smart contract code into word streams with code structural information, convert code elements (e.g., statements, functions) into numerical vectors that are supposed to encode the code syntax and semantics, and compare the similarities among the vectors encoding code and known bugs, to identify potential issues. We have implemented the approach in a prototype, named SmartEmbed,(1) 1. The anonymous replication packages can be accessed at: https://drive.google.com/file/d/1kauLT3y2IiHPkUlVx4FSTda-dVAyL4za/view?usp=sharing. and evaluated it with more than 22,000 smart contracts collected from the Ethereum blockchain. Results show that our tool can effectively identify many repetitive instances of Solidity code, where the clone ratio is around 90 percent. Code clones such as type-III or even type-IV semantic clones can also be detected accurately. Our tool can identify more than 1000 clone related bugs based on our bug databases efficiently and accurately. Our tool can also help to efficiently validate any given smart contract against a known set of bugs, which can help to improve the users' confidence in the reliability of the contract.
引用
收藏
页码:2874 / 2891
页数:18
相关论文
共 50 条
  • [1] SmartEmbed: A Tool for Clone and Bug Detection in Smart Contracts through Structural Code Embedding
    Gao, Zhipeng
    Jayasundara, Vinoj
    Jiang, Lingxiao
    Xia, Xin
    Lo, David
    Grundy, John
    [J]. 2019 IEEE INTERNATIONAL CONFERENCE ON SOFTWARE MAINTENANCE AND EVOLUTION (ICSME 2019), 2019, : 394 - 397
  • [2] Model-Checking of Smart Contracts
    Nehai, Zeinab
    Piriou, Pierre-Yves
    Daumas, Frederic
    [J]. IEEE 2018 INTERNATIONAL CONGRESS ON CYBERMATICS / 2018 IEEE CONFERENCES ON INTERNET OF THINGS, GREEN COMPUTING AND COMMUNICATIONS, CYBER, PHYSICAL AND SOCIAL COMPUTING, SMART DATA, BLOCKCHAIN, COMPUTER AND INFORMATION TECHNOLOGY, 2018, : 980 - 987
  • [3] Model checking smart contracts for Ethereum
    Osterland, Thomas
    Rose, Thomas
    [J]. PERVASIVE AND MOBILE COMPUTING, 2020, 63
  • [4] An Efficient Code-Embedding-Based Vulnerability Detection Model for Ethereum Smart Contracts
    Xu, Zhigang
    Chen, Xingxing
    Dong, Xinhua
    Han, Hongmu
    Yan, Zhongzhen
    Ye, Kangze
    Li, Chaojun
    Zheng, Zhiqiang
    Wang, Haitao
    Zhang, Jiaxi
    [J]. INTERNATIONAL JOURNAL OF DATA WAREHOUSING AND MINING, 2023, 19 (02)
  • [5] Compliance Checking for Transactive Energy Contracts using Smart Contracts
    Parvizimosaed, Alireza
    Bashari, Masoud
    Kian, Ashkan R.
    Amyot, Daniel
    Mylopoulos, John
    [J]. 2020 IEEE PES TRANSACTIVE ENERGY SYSTEMS CONFERENCE (TESC), 2020,
  • [6] SmartCoCo: Checking Comment-code Inconsistency in Smart Contracts via Constraint Propagation and Binding
    Hao, Sicheng
    Nan, Yuhong
    Zheng, Zibin
    Liu, Xiaohui
    [J]. 2023 38TH IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING, ASE, 2023, : 294 - 306
  • [7] On Verification of Smart Contracts via Model Checking
    Bao, Yulong
    Zhu, Xue-Yang
    Zhang, Wenhui
    Shen, Wuwei
    Sun, Pengfei
    Zhao, Yingqi
    [J]. THEORETICAL ASPECTS OF SOFTWARE ENGINEERING, TASE 2022, 2022, 13299 : 92 - 112
  • [8] Understanding Code Reuse in Smart Contracts
    Chen, Xiangping
    Liao, Peiyong
    Zhang, Yixin
    Huang, Yuan
    Zheng, Zibin
    [J]. 2021 IEEE INTERNATIONAL CONFERENCE ON SOFTWARE ANALYSIS, EVOLUTION AND REENGINEERING (SANER 2021), 2021, : 470 - 479
  • [9] LEGALREGIMEOF SMART CONTRACTS: A CODE OR A CONTRACT
    Krytsula, A. A.
    [J]. VESTNIK PERMSKOGO UNIVERSITETA-JURIDICHESKIE NAUKI, 2022, (56): : 239 - 267
  • [10] Smart Contracts in View of the Civil Code
    di Angelo, Monika
    Soare, Alfred
    Salzer, Gernot
    [J]. SAC '19: PROCEEDINGS OF THE 34TH ACM/SIGAPP SYMPOSIUM ON APPLIED COMPUTING, 2019, : 392 - 399