Skip to main content
QUICK REVIEW

[论文解读] Rethinking Smart Contract Fuzzing: Fuzzing With Invocation Ordering and Important Branch Revisiting

Zhenguang Liu, Qian Peng|arXiv (Cornell University)|Jan 10, 2023
Adversarial Robustness in Machine Learning被引用 4
一句话总结

该论文提出 IR-Fuzz,一种新型智能合约模糊测试工具,通过基于数据依赖性的函数调用序列排序与延长,提升漏洞检测能力,以探索深层合约状态;同时利用基于分支距离的演化机制与目标化能效分配,优先处理罕见且高风险的分支。IR-Fuzz 在分支覆盖度上比现有最先进工具高出 28%,漏洞检测准确率提升 7%,每秒可处理 350 个测试用例。

ABSTRACT

Blockchain smart contracts have given rise to a variety of interesting and compelling applications and emerged as a revolutionary force for the Internet. Quite a few practitioners have devoted themselves to developing tools for detecting bugs in smart contracts. One line of efforts revolve around static analysis techniques, which heavily suffer from high false-positive rates. Another line of works concentrate on fuzzing techniques. Unfortunately, current fuzzing approaches for smart contracts tend to conduct fuzzing starting from the initial state of the contract, which expends too much energy revolving around the initial state and thus is usually unable to unearth bugs triggered by other states. Moreover, most existing methods treat each branch equally, failing to take care of the branches that are rare or more likely to possess bugs. This might lead to resources wasted on normal branches. In this paper, we try to tackle these challenges from three aspects: (1) In generating function invocation sequences, we explicitly consider data dependencies between functions to facilitate exploring richer states. We further prolong a function invocation sequence S1 by appending a new sequence S2, so that S2 can start fuzzing from states that are different from the initial state. (2) We incorporate a branch distance-based measure to evolve test cases iteratively towards a target branch. (3) We engage a branch search algorithm to discover rare and vulnerable branches, and design an energy allocation mechanism to take care of exercising these crucial branches. We implement IR-Fuzz and extensively evaluate it over 12K real-world contracts. Empirical results show that: (i) IR-Fuzz achieves 28% higher branch coverage than state-of-the-art fuzzing approaches, and (ii) IR-Fuzz detects more vulnerabilities and increases the average accuracy of vulnerability detection by 7% over current methods.

研究动机与目标

  • 为解决当前智能合约模糊测试工具仅从初始合约状态启动的局限性,避免遗漏可能隐藏漏洞的深层或复杂状态。
  • 克服对所有分支一视同仁的低效策略,识别并优先处理更可能包含漏洞的罕见或高风险分支。
  • 通过生成尊重数据依赖关系的函数调用序列,实现对初始状态之外的合约状态转换,提升模糊测试效率与覆盖范围。
  • 通过基于距离的度量引导测试用例演化至特定目标分支,减少随机性,降低误报率,提升漏洞检测精度。
  • 通过动态分配更多模糊测试资源至关键且难以触及的分支,优化资源分配,提升整体测试有效性。

提出的方法

  • IR-Fuzz 通过函数间的数据依赖分析生成函数调用序列,确保序列遵守对全局变量的读写依赖关系,从而支持对更丰富合约状态的探索。
  • 通过在非初始状态启动的第二段序列附加至初始序列,实现对初始状态之外复杂深层合约状态的探索。
  • 采用基于分支距离的度量,迭代演化测试用例以逼近目标分支,减少随机性,提升对特定代码路径的收敛效率。
  • 通过分支搜索算法识别罕见且易受攻击的分支,并借助动态能效分配机制优先处理这些分支,提升其被触发的频率。
  • 框架集成 AFL 启发的变异策略,但通过避免对关键输入部分进行变异,提升触发深层或受保护分支的可能性。
  • IR-Fuzz 通过监控 EVM 指令(如 BALANCE、compare、jump)的执行模式,检测与漏洞相关的特征,例如危险的 Ether 严格相等比较。

实验结果

研究问题

  • RQ1如何通过生成探索初始状态之外合约状态的调用序列,提升智能合约模糊测试的效果?
  • RQ2基于分支距离的测试用例演化在多大程度上能提升模糊测试在目标分支上的收敛性与覆盖度?
  • RQ3对罕见或易受攻击分支实施动态能效分配,如何影响整体模糊测试效率与漏洞检测准确率?
  • RQ4所提方法能否检测到现有工具未能发现的新型漏洞,如危险的 Ether 严格相等比较?
  • RQ5在真实智能合约中,调用顺序、序列延长与能效分配的组合相较于现有最先进模糊测试技术表现如何?

主要发现

  • 在 12,000 个真实世界智能合约中,IR-Fuzz 的分支覆盖度比现有最先进模糊测试工具高出 28%。
  • 漏洞检测的平均准确率相比现有方法提升 7%,表明在识别真实漏洞方面具有更高的精度。
  • IR-Fuzz 平均每秒可处理 350 个测试用例,展现出优异的性能与可扩展性。
  • 移除能效分配机制(IR-Fuzz-WEA)后,分支覆盖度下降 43.02%,检测准确率下降 4.87%,证明该机制具有显著贡献。
  • IR-Fuzz 首次成功检测到一种新型漏洞模式——危险的 Ether 严格相等比较,该漏洞此前未被现有工具发现,其成因是合约余额因预先存在的 Ether 而始终不等于用户预期贡献。
  • 通过在博彩合约上的案例研究,验证了框架检测危险 Ether 严格相等漏洞的能力,IR-Fuzz 识别出因余额不匹配导致的不可达获胜条件。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。