信息网络安全 ›› 2025, Vol. 25 ›› Issue (5): 732-746.doi: 10.3969/j.issn.1671-1122.2025.05.006

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

基于静态分析的价格预言机操纵源代码检测方法研究

叶佳骏, 高翠凤, 薛吟兴()   

  1. 中国科学技术大学计算机科学与技术学院,合肥 230026
  • 收稿日期:2024-04-29 出版日期:2025-05-10 发布日期:2025-06-10
  • 通讯作者: 薛吟兴 yxxue@ustc.edu.cn
  • 作者简介:叶佳骏(1999—),男,广东,硕士研究生,主要研究方向为区块链智能合约安全|高翠凤(1997—),女,河北,博士研究生,CCF会员,主要研究方向为区块链智能合约安全|薛吟兴(1982—),男,江苏,研究员,博士,CCF会员,主要研究方向为软件工程、网络安全、软件安全
  • 基金资助:
    国家自然科学基金(61972373);江苏省基础研究计划(自然科学基金)面上项目(BK20201192)

Research on Price Oracle Manipulation Source Code Detection Method Based on Static Analysis

YE Jiajun, GAO Cuifeng, XUE Yinxing()   

  1. Department of Computer Science and Technology, University of Science and Technology of China, Hefei 230026, China
  • Received:2024-04-29 Online:2025-05-10 Published:2025-06-10

摘要:

针对智能合约的价格预言机操纵攻击问题,文章提出一种基于静态分析的价格预言机操纵源代码检测方法。该方法首先根据用户输入的函数调用关系,建立调用者函数的变量和被调函数的参数之间的对应关系,以及被调函数返回值和调用者函数的变量之间的对应关系。其次,对被测函数的源代码及其实际运行时涉及的其他合约源代码进行静态分析,获取每个合约的数据流和控制流信息。然后,通过整合单个合约的数据流信息、控制流信息以及函数调用关系,构建跨合约的数据流图和控制流图,从而获取变量的数据依赖和控制依赖关系。最后,通过检测转账操作中的转账金额以及转账操作中存在控制依赖的控制语句是否使用少量容易被操纵的信息,来判断被测合约是否存在价格预言机操纵风险。实验结果表明,该方法能有效检测智能合约中的价格预言机操纵攻击,具有较高的精确率和召回率。

关键词: 智能合约, 静态分析, 价格预言机操纵攻击, 区块链安全

Abstract:

Aiming at the problem of price oracle manipulation attacks on smart contracts, this paper proposed a price oracle manipulation source code detection method based on static analysis. This approach first established correspondences between caller function variables and called function parameters, as well as between callee function return values and caller variables based on user-input function call relationships. Subsequently, static analysis was applied to the source code of the tested function and other contracts involved during runtime to obtain data flow and controled flow information for each contract. Then, utilized the data flow and controled flow information for individual contracts, along with function call relationships, cross-contract data flow graphs and control flow graphs were constructed to ascertain variable data dependencies and controled dependencies. Finally, the method detected whether the transfer amount in transfer operations and controled statements which the transfer operations controled depend involve manipulation-prone information to determine the existence of price oracle manipulation risk in the tested contract. Experimental results demonstrate that this method effectively detects price oracle manipulation attacks in smart contracts with high precision and recall rates.

Key words: smart contract, static analysis, price oracle manipulation attack, blockchain security

中图分类号: