应用科学学报 ›› 2022, Vol. 40 ›› Issue (4): 695-712.doi: 10.3969/j.issn.0255-8297.2022.04.012

• 区块链 • 上一篇    

SlightDetection:一种以太坊智能合约安全漏洞的静态分析工具

陈霄汉1, 赵相福1, 张登记2, 费佳佳1   

  1. 1. 烟台大学 计算机与控制工程学院, 山东 烟台 264005;
    2. 浙江师范大学 数学与计算机科学学院, 浙江 金华 321004
  • 收稿日期:2021-11-12 发布日期:2022-08-03
  • 通信作者: 赵相福,教授,研究方向为区块链、人工智能。E-mail:xiangfuzhao@gmail.com E-mail:xiangfuzhao@gmail.com
  • 基金资助:
    国家自然科学基金(No.61972360,No.62072392)资助

SlightDetection: A Static Analysis Tool for Smart Contracts Security Vulnerabilities on Ethereum

CHEN Xiaohan1, ZHAO Xiangfu1, ZHANG Dengji2, FEI Jiajia1   

  1. 1. School of Computer and Control Engineering, Yantai University, Yantai 264005, Shandong, China;
    2. School of Mathematics and Computer Science, Zhejiang Normal University, Jinhua 321004, Zhejiang, China
  • Received:2021-11-12 Published:2022-08-03

摘要: 以太坊智能合约若存在安全漏洞,则会导致无可估量的损失。为缓解该问题,提出了一种以静态程序分析技术实现代码全覆盖的智能合约漏洞检测工具SlightDetection。该工具将智能合约源代码转化为对应的抽象语法树,并翻译为XML中间表示;以几个经典漏洞的特征为例,书写自定义的XPath规则库;将XML中间表示与XPath库作为输入不断遍历XPath规则库并进行匹配,最终得到漏洞检测的报告。该文测试了3个经典合约,充分展示了SlightDetection具有更快、更准确的检测特性;对Etherscan上提供的大量智能合约进行测试并对其中100多份合约进行了手动验证,进一步证明了该工具的有效性。

关键词: 智能合约, 漏洞检测, 静态分析, 以太坊

Abstract: Security vulnerabilities in Ethereum smart contracts may lead to immeasurable losses. To alleviate this problem, a smart contract vulnerability detection tool SlightDetection is proposed, which uses static program analysis technology to achieve full code coverage. The tool converts smart contract source codes into a corresponding abstract syntax tree, and translates it into an XML intermediate representation. Taking the characteristics of several classic vulnerabilities as an example, the tool writes a custom XPath rule library, and using the XML intermediate representation and the XPath library as inputs, the tool keeps traversing and matching the XPath rule base, till getting the report of vulnerability detection. This work tests 3 classic contracts, and fully demonstrates the faster and more accurate detection features of SlightDetection. The effectiveness of the tool is proved by testing a large number of smart contracts provided on Etherscan and manually verifying more than 100 of them.

Key words: smart contract, vulnerability detection, static analysis, Ethereum

中图分类号: