Decentralized finance (DeFi) protocols are crypto projects developed on the blockchain to manage digital assets. Attacks on DeFi have been frequent and have resulted in losses exceeding $80 billion. Current tools detect and locate possible vulnerabilities in contracts by analyzing the state changes that may occur during malicious events. However, this victim-only approaches seldom possess the capability to cover the attacker's interaction intention logic. Furthermore, only a minuscule percentage of DeFi protocols experience attacks in real-world scenarios, which poses a significant challenge for these detection tools to demonstrate practical effectiveness. In this paper, we propose DeFiTail, the first framework that utilizes deep learning technology for access control and flash loan exploit detection. Through feeding the cross-contract static data flow, DeFiTail automatically learns the attack logic in real-world malicious events that occur on DeFi protocols, capturing the threat patterns between attacker and victim contracts. Since the DeFi protocol events involve interactions with multi-account transactions, the execution path with external and internal transactions requires to be unified. Moreover, to mitigate the impact of mistakes in Control Flow Graph (CFG) connections, DeFiTail validates the data path by employing the symbolic execution stack. Furthermore, we feed the data paths through our model to achieve the inspection of DeFi protocols. Comparative experiment results indicate that DeFiTail achieves the highest accuracy, with 98.39% in access control and 97.43% in flash loan exploits. DeFiTail also demonstrates an enhanced capability to detect malicious contracts, identifying 86.67% accuracy from the CVE dataset.
翻译:去中心化金融(DeFi)协议是基于区块链开发的用于管理数字资产的加密项目。针对DeFi的攻击频发,已导致超过800亿美元的损失。现有工具通过分析恶意事件中可能发生的状态变化来检测和定位合约中的潜在漏洞。然而,这种仅关注受害者的方法通常难以覆盖攻击者的交互意图逻辑。此外,实际场景中仅极少数DeFi协议遭受攻击,这对检测工具的实际有效性验证构成了重大挑战。本文提出DeFiTail,首个利用深度学习技术进行访问控制和闪电贷漏洞检测的框架。通过输入跨合约静态数据流,DeFiTail能自动学习DeFi协议真实恶意事件中的攻击逻辑,捕捉攻击者与受害者合约间的威胁模式。由于DeFi协议事件涉及多账户交易交互,需统一包含外部与内部交易的执行路径。为降低控制流图(CFG)连接错误的影响,DeFiTail采用符号执行栈验证数据路径。进一步,我们将数据路径输入模型以实现对DeFi协议的检测。对比实验结果表明,DeFiTail在访问控制检测中达到98.39%的准确率,在闪电贷漏洞检测中达到97.43%的准确率。DeFiTail还展现出更强的恶意合约检测能力,在CVE数据集中实现86.67%的准确率。