信息网络安全 ›› 2025, Vol. 25 ›› Issue (4): 664-673.doi: 10.3969/j.issn.1671-1122.2025.04.014

• 理论研究 • 上一篇    下一篇

结合提示词微调的智能合约漏洞检测方法

张雨轩1, 黄诚1, 柳蓉1, 冷涛2()   

  1. 1.四川大学网络空间安全学院,成都 610207
    2.四川警察学院智能警务四川省重点实验室,泸州 646000
  • 收稿日期:2025-01-15 出版日期:2025-04-10 发布日期:2025-04-25
  • 通讯作者: 冷涛 lengtao@scpolicec.edu.cn
  • 作者简介:张雨轩(1999—),男,四川,硕士研究生,主要研究方向为漏洞检测、大语言模型安全|黄诚(1987—),男,四川,副教授,博士,CCF高级会员,主要研究方向为攻击检测、威胁溯源|柳蓉(2000—),女,四川,硕士研究生,主要研究方向为模糊测试、区块链安全|冷涛(1986—),男,四川,副教授,博士,主要研究方向为威胁狩猎、高级威胁检测、取证分析。
  • 基金资助:
    国家自然科学基金(62472296);智能警务四川省重点实验室开放课题(ZNJW2024KFZD003);四川省科技厅聚源兴川项目(2024ZHCG0175)

Smart Contract Vulnerability Detection Method Combining Prompt Tuning

ZHANG Yuxuan1, HUANG Cheng1, LIU Rong1, LENG Tao2()   

  1. 1. School of Cyber Science and Engineering, Sichuan University, Chengdu 610207, China
    2. Intelligent Policing Key Laboratory of Sichuan Province, Sichuan Police College, Luzhou 646000, China
  • Received:2025-01-15 Online:2025-04-10 Published:2025-04-25

摘要:

随着区块链交易平台的飞速发展,智能合约的部署数量显著增加,而近年来不断爆出的智能合约漏洞致使区块链交易平台蒙受了巨大的经济损失。因此,智能合约安全领域的研究引起了研究者的广泛关注。然而,现有的漏洞检测方法要么严重依赖于专家规则或复杂的数据处理步骤,要么采用与该领域目标不符的模型或学习策略,导致检测效果不佳。基于此,文章提出一种利用进行提示词微调的智能合约漏洞检测方法PC-Detector,该方法通过引入特定于任务的提示词知识,确保目标任务与模型预训练阶段任务的一致性,从而增强模型适应,提高检测效果。具体来说,文章提出4种针对智能合约漏洞检测的提示词设计方法,并验证了代码嵌入提示词不同位置对检测性能的影响。此外,文章利用代码嵌入提示词对CodeT5系列模型进行提示词微调,从而检测出智能合约中的漏洞。实验结果表明,该方法可以显著提高检测性能。

关键词: 智能合约, 区块链, 漏洞检测, 提示词微调

Abstract:

With the rapid development of blockchain trading platforms, the deployment of smart contracts has increased significantly. However, in recent years, vulnerabilities in smart contracts have led to substantial economic losses for block-chain transaction platforms, drawing considerable attention from researchers to the field of smart contract security. Existing methods either heavily rely on expert rules or complex data processing steps, or employ models or learning strategies that are misaligned with the objectives of this field, resulting in poor detection performance. Therefore, this paper proposed PC-Detector, a vulnerability detection method for smart contracts utilizing prompt fine-tuning of large language models. By introducing task-specific prompt knowledge, this method ensured consistency between the target task and the model’s pretraining tasks, thereby enhancing model adaptability and improving detection performance. Specifically, the paper proposed four prompt design strategies tailored to smart contract vulnerability detection and examined the impact of embedding prompts at different positions on detection performance. Furthermore, the paper prompt-tuning on the CodeT5 series models using code-embedded prompts to detect vulnerabilities in smart contracts. Extensive experiments demonstrate that this method significantly improved detection performance.

Key words: smart contract, blockchain, vulnerability detection, prompt tuning

中图分类号: