arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2407.06348cs.CRcs.PL
收藏

FORAY:面向 DeFi 协议深层逻辑漏洞的有效攻击合成

FORAY: Towards Effective Attack Synthesis against Deep Logical Vulnerabilities in DeFi Protocols

Hongbo Wen, Hanzhi Liu, Jiaxin Song, Yanju Chen, Wenbo Guo, Yu Feng

AI总结:

针对 DeFi 协议跨合约深层逻辑漏洞检测效率低的问题,本文提出 Foray 框架,通过领域特定语言将智能合约提升为金融操作并构建代币流图,结合高效草图生成与符号编译,实现可扩展的攻击合成。

摘要:

随着去中心化金融(DeFi)应用的兴起,区块链的采用率急剧上升。然而,DeFi 协议所管理的数字资产具有巨大价值,使其成为攻击的主要目标。当前的智能合约漏洞检测工具在应对 DeFi 协议时面临困难,原因在于多个智能合约之间复杂的金融交互会产生深层逻辑漏洞。这些工具主要分析单个合约,对于跨越众多智能合约的 DeFi 协议则采用暴力搜索方法,导致效率低下。我们提出了 Foray,一个针对 DeFi 协议深层逻辑漏洞的高效攻击合成框架。Foray 提出了一种新颖的攻击草图生成与补全框架。具体而言,我们不将 DeFi 协议视为普通程序,而是设计了一种领域特定语言(DSL),将底层智能合约提升为高层金融操作。基于我们的 DSL,我们首先将给定的 DeFi 协议编译为代币流图(token flow graph),这是我们对 DeFi 协议的图形化表示。然后,我们设计了一种高效的草图生成方法,针对特定攻击目标(例如价格操纵、套利等)合成攻击草图。该算法通过在 TFG 中寻找可达路径来策略性地识别候选草图,其效率远高于随机枚举。对于用我们的 DSL 编写的每个候选草图,Foray 设计了一种领域特定的符号编译方法,将其编译为 SMT 约束。我们的编译通过移除冗余的智能合约语义来简化约束。它在保持符号编译可用性的同时,能够扩展到规模大出数个数量级的问题。最后,候选草图通过现有求解器完成,并通过直接的语法转换转化为具体攻击。

英文摘要:

Blockchain adoption has surged with the rise of Decentralized Finance (DeFi) applications. However, the significant value of digital assets managed by DeFi protocols makes them prime targets for attacks. Current smart contract vulnerability detection tools struggle with DeFi protocols due to deep logical bugs arising from complex financial interactions between multiple smart contracts. These tools primarily analyze individual contracts and resort to brute-force methods for DeFi protocols crossing numerous smart contracts, leading to inefficiency. We introduce Foray, a highly effective attack synthesis framework against deep logical bugs in DeFi protocols. Foray proposes a novel attack sketch generation and completion framework. Specifically, instead of treating DeFis as regular programs, we design a domain-specific language (DSL) to lift the low-level smart contracts into their high-level financial operations. Based on our DSL, we first compile a given DeFi protocol into a token flow graph, our graphical representation of DeFi protocols. Then, we design an efficient sketch generation method to synthesize attack sketches for a certain attack goal (e.g., price manipulation, arbitrage, etc.). This algorithm strategically identifies candidate sketches by finding reachable paths in TFG, which is much more efficient than random enumeration. For each candidate sketch written in our DSL, Foray designs a domain-specific symbolic compilation to compile it into SMT constraints. Our compilation simplifies the constraints by removing redundant smart contract semantics. It maintains the usability of symbolic compilation, yet scales to problems orders of magnitude larger. Finally, the candidates are completed via existing solvers and are transformed into concrete attacks via direct syntax transformation.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑