Elysium:上下文感知字节码级修补,自动修复易受攻击的智能合约
Elysium: Context-Aware Bytecode-Level Patching to Automatically Heal Vulnerable Smart Contracts
摘要:
修复bug最简单的方法是修补源代码。然而,源代码并不总是可用的:目前部署在以太坊上的约4900万智能合约中只有0.3%的源代码是公开的。此外,由于合约可以调用其他合约的函数,因此闭源合约中的安全缺陷也可能影响开源合约。然而,目前最先进的方法,在封闭源合同(即,EVM字节码),如EVMPatch和SmartShield,使用利用修复修补模式的纯硬编码模板。因此,它们不能动态地适应正在修补的字节码,这严重限制了它们的灵活性和可伸缩性。例如,当使用硬编码模板修补整数溢出时,需要采用特定的修补模板,因为要检查的边界对于每个整数大小是不同的。在本文中,我们提出了Elysium,这是一种在字节码级别实现自动智能合约修复的可扩展方法。Elysium通过从字节码中推断上下文信息,结合了基于模板和基于语义的修补。Elysium目前能够自动修补智能合约中的7种不同类型的漏洞,并且可以轻松地使用新模板和新的错误查找工具进行扩展。我们使用3个不同的数据集,通过在补丁合同上回放超过50万笔交易来评估其有效性和正确性。我们发现Elysium比现有工具的性能更好,至少可以正确修补30%以上的合同。最后,我们还比较了Elysium在部署和交易成本方面的开销。与其他工具相比,我们发现Elysium通常最大限度地减少了运行时成本(即,交易成本)高达1.7倍,部署成本仅略高,其中部署成本是与运行时成本相比的一次性成本。
英文摘要:
Fixing bugs is easiest by patching source code. However, source code is not always available: only 0.3% of the ~49M smart contracts that are currently deployed on Ethereum have their source code publicly available. Moreover, since contracts may call functions from other contracts, security flaws in closed-source contracts may affect open-source contracts as well. However, current state-of-the-art approaches that operate on closed-source contracts (i.e., EVM bytecode), such as EVMPatch and SmartShield, make use of purely hard-coded templates that leverage fix patching patterns. As a result, they cannot dynamically adapt to the bytecode that is being patched, which severely limits their flexibility and scalability. For instance, when patching integer overflows using hard-coded templates, a particular patch template needs to be employed as the bounds to be checked are different for each integer size. In this paper, we propose Elysium, a scalable approach towards automatic smart contract repair at the bytecode level. Elysium combines template-based and semantic-based patching by inferring context information from bytecode. Elysium is currently able to patch 7 different types of vulnerabilities in smart contracts automatically and can easily be extended with new templates and new bug-finding tools. We evaluate its effectiveness and correctness using 3 different datasets by replaying more than 500K transactions on patched contracts. We find that Elysium outperforms existing tools by patching at least 30% more contracts correctly. Finally, we also compare the overhead of Elysium in terms of deployment and transaction cost. In comparison to other tools, we find that generally Elysium minimizes the runtime cost (i.e., transaction cost) up to a factor of 1.7, for only a marginally higher deployment cost, where deployment cost is a one-time cost as compared to the runtime cost.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。