Journal of Computer Applications ›› 2025, Vol. 45 ›› Issue (11): 3493-3501.DOI: 10.11772/j.issn.1001-9081.2024121858

• The 7th CCF China Conference on Blockchain Technology • Previous Articles    

Deep learning-based vulnerability detection tool for C/C++ smart contracts at function-body slice level

Yushu LI1,2, Ying XING1,2, Siqi LU3, Heng PAN1,2(), Senchun CHAI4, Xueming SI1,2   

  1. 1.School of Cyberspace Security,Zhongyuan University of Technology,Zhengzhou Henan 450007,China
    2.Henan International Joint Laboratory of Blockchain and Data Sharing (Zhongyuan University of Technology),Zhengzhou Henan 450007,China
    3.Henan Key Laboratory of Network Cryptography Technology (Information Engineering University of PLA Strategic Support Force),Zhengzhou Henan 450001,China
    4.School of Automation,Beijing Institute of Technology,Beijing 100081,China
  • Received:2025-01-02 Revised:2025-03-06 Accepted:2025-03-13 Online:2025-04-18 Published:2025-11-10
  • Contact: Heng PAN
  • About author:LI Yushu, born in 1998, M. S. candidate. His research interests include cybersecurity, blockchain.
    XING Ying, born in 1985, Ph. D., lecturer. Her research interests include malicious code detection, smart contract vulnerability detection.
    LU Siqi, born in 1990, Ph. D., lecturer. His research interests include smart contract security, cryptographic protocol analysis and design, formal methods.
    CHAI Senchun, born in 1978, Ph. D., professor. His research interests include intelligent information processing and control.
    SI Xueming, born in 1966, Ph. D., professor. His research interests include blockchain, cryptography.
  • Supported by:
    Key Scientific Research Project of Higher Education Institutions in Henan Province(24A520059);Henan Province Science and Technology Research Project in 2024(242102210136);Discipline Strength Enhancement Program of Zhongyuan Institute of Technology(GG202425);Graduate Research Innovation Program of Zhongyuan University of Technology(YKY2024ZK27)

基于深度学习的函数体切片级C/C++智能合约漏洞检测工具

李浴淑1,2, 邢颖1,2, 陆思奇3, 潘恒1,2(), 柴森春4, 斯雪明1,2   

  1. 1.中原工学院 网络空间安全学院,郑州 450007
    2.河南省区块链与数据共享国际联合实验室(中原工学院),郑州 450007
    3.河南省网络密码技术重点实验室(中国人民解放军战略支援部队信息工程大学),郑州 450001
    4.北京理工大学 自动化学院,北京 100081
  • 通讯作者: 潘恒
  • 作者简介:李浴淑(1998—),男,河南开封人,硕士研究生,主要研究方向:网络安全、区块链
    邢颖(1985—),女,河南沈丘人,讲师,博士,主要研究方向:恶意代码检测、智能合约漏洞检测
    陆思奇(1990—),男,山东济宁人,讲师,博士,主要研究方向:智能合约安全、密码协议分析与设计、形式化方法
    柴森春(1978—),北京人,教授,博士,主要研究方向:智能信息处理与控制
    斯雪明(1966—),男,浙江诸暨人,教授,博士,主要研究方向:区块链、密码学。
  • 基金资助:
    河南省高等学校重点科研项目(24A520059);2024年度河南省科技攻关计划项目(242102210136);中原工学院优势学科实力提升计划项目(GG202425);中原工学院研究生科研创新计划项目(YKY2024ZK27)

Abstract:

With the frequent occurrence of security incidents caused by smart contract vulnerabilities, existing detection tools lack sufficient support for multiple programming languages, particularly in terms of their inability to detect vulnerabilities at the source code level in C/C++ smart contracts. To address this issue, a deep learning-based vulnerability detection method for C/C++ smart contracts was proposed and a function-body slicing-level detection tool CDFSentry was designed. Starting from the perspective of source code, the concept of target regions in deep learning applications within the field of image processing was applied to smart contract vulnerability detection. The implementation of the tool involved four steps: first, extracting function-body slices related to vulnerabilities to obtain complete function-body information; second, annotating the extracted slices; third, encoding the slices into vectors to convert them into input formats suitable for deep learning; four, completing vector labeling and model training. Besides, by analyzing the causes of vulnerabilities in C/C++ smart contracts, five types of vulnerabilities were defined: integer overflow, permission control, token transfer, memory management, and transaction delay, and a dataset containing 5 024 source codes was constructed to solve the problems of insufficient open-source datasets and inconsistent definitions of vulnerability types in this field. Experimental results on this dataset demonstrate that while the comparable deep learning tool GNNSCVulDetector can only detect one type of vulnerability, CDFSentry detects five types with 12.68 percentage points higher accuracy. By leveraging deep learning to detect vulnerabilities in C/C++ smart contract source code, CDFSentry reduces reliance on experts while offering higher detection accuracy and broader coverage than similar tools. In addition, through continuous learning and training, its detection ability can be improved continuously.

Key words: smart contract, deep learning, function-body, vulnerability detection, integer overflow, transaction delay

摘要:

智能合约漏洞引发的安全事件频发,而现有检测工具对多语言支持不足,特别是缺乏对C/C++智能合约源码级别的漏洞检测能力。针对上述问题,提出基于深度学习的C/C++智能合约漏洞检测方法,并设计了函数体切片级检测工具CDFSentry。该工具从源码角度出发,借鉴深度学习在图像处理领域中的目标区域概念应用于智能合约漏洞检测。工具实现分为4步:一是提取漏洞函数体切片,获取完整函数体信息;二是对提取的切片进行标注;三是将切片编码为向量,转化为深度学习输入格式;四是完成向量标记与模型训练。此外,通过分析C/C++智能合约漏洞产生的原因,定义了5种类型的漏洞:整数溢出、权限控制、代币转移、内存管理和交易延迟,并构建了包含5 024个源码的数据集,解决了该领域开源数据集匮乏与漏洞类型不统一的问题。在该数据集上的实验结果表明,同类型的深度学习工具GNNSCVulDetector仅能检测1种漏洞,而CDFSentry可检测5种漏洞,且准确率提高了12.68个百分点。CDFSentry基于深度学习检测C/C++智能合约源码漏洞,可减少对专家依赖,且相比同类工具检测精度更高、范围更广;通过持续学习训练,它的检测能力可不断提升。

关键词: 智能合约, 深度学习, 函数体, 漏洞检测, 整数溢出, 交易延迟

CLC Number: