Decentralized Finance (DeFi) incidents stemming from the exploitation of smart contract vulnerabilities have culminated in financial damages exceeding 3 billion US dollars. Existing defense mechanisms typically focus on detecting and reacting to malicious transactions executed by attackers that target victim contracts. However, with the emergence of private transaction pools where transactions are sent directly to miners without first appearing in public mempools, current detection tools face significant challenges in identifying attack activities effectively. Based on the fact that most attack logic rely on deploying one or more intermediate smart contracts as supporting components to the exploitation of victim contracts, detection methods have been proposed that focus on identifying these adversarial contracts instead of adversarial transactions. However, previous state-of-the-art approaches in this direction have failed to produce results satisfactory enough for real-world deployment. In this paper, we propose a new framework for effectively detecting DeFi attacks via unveiling adversarial contracts. Our approach allows us to leverage common attack patterns, code semantics and intrinsic characteristics found in malicious smart contracts to build the LookAhead system based on Machine Learning (ML) classifiers and a transformer model that is able to effectively distinguish adversarial contracts from benign ones, and make timely predictions of different types of potential attacks. Experiments show that LookAhead achieves an F1-score as high as 0.8966, which represents an improvement of over 44.4% compared to the previous state-of-the-art solution Forta, with a False Positive Rate (FPR) at only 0.16%.
翻译:去中心化金融(DeFi)因智能合约漏洞被利用而导致的安全事件已造成超过30亿美元的经济损失。现有的防御机制通常侧重于检测和响应攻击者针对受害者合约执行的恶意交易。然而,随着私有交易池的出现——交易直接发送给矿工而无需先出现在公共内存池中,当前的检测工具在有效识别攻击活动方面面临重大挑战。基于大多数攻击逻辑依赖于部署一个或多个中间智能合约作为利用受害者合约的支撑组件这一事实,已有研究提出通过识别这些对抗性合约而非对抗性交易的检测方法。然而,该方向上现有的最先进方法尚未能产生足以满足实际部署需求的满意结果。本文提出一种通过揭示对抗性合约来有效检测DeFi攻击的新框架。我们的方法能够利用恶意智能合约中常见的攻击模式、代码语义和内在特征,构建基于机器学习分类器和Transformer模型的LookAhead系统。该系统能有效区分对抗性合约与良性合约,并及时预测不同类型的潜在攻击。实验表明,LookAhead的F1分数高达0.8966,相比现有最优解决方案Forta提升了超过44.4%,同时误报率仅为0.16%。