Skip to main content
QUICK REVIEW

[论文解读] CONTRACTFIX: A Framework for Automatically Fixing Vulnerabilities in Smart Contracts

Pengcheng Fang, Peng|arXiv (Cornell University)|Jul 18, 2023
Security and Verification in ComputingComputer Science被引用 3
一句话总结

ContractFix 是一个端到端框架,通过集成静态分析、基于模板的修复模式和程序分析,自动检测、修补并验证智能合约中的安全漏洞。它在 144 个真实世界合约中成功修复了 601 个检测到的漏洞中的 94%,性能开销极低,平均修补时间仅为 3.75 秒。

ABSTRACT

The increased adoption of smart contracts in many industries has made them an attractive target for cybercriminals, leading to millions of dollars in losses. Thus, deploying smart contracts with detected vulnerabilities (known to developers) are not acceptable, and fixing all the detected vulnerabilities is needed, which incurs high manual labor cost without effective tool support. To fill this need, in this paper, we propose ContractFix, a novel framework that automatically generates security patches for vulnerable smart contracts. ContractFix is a general framework that can incorporate different fix patterns for different types of vulnerabilities. Users can use it as a security fix-it tool that automatically applies patches and verifies the patched contracts before deploying the contracts. To address the unique challenges in fixing smart contract vulnerabilities, given an input smart contract, ool conducts our proposed ensemble identification based on multiple static verification tools to identify vulnerabilities that are amenable for automatic fix. Then, ContractFix generates patches using template-based fix patterns and conducts program analysis (program dependency computation and pointer analysis) for smart contracts to accurately infer and populate the parameter values for the fix patterns. Finally, ContractFix performs static verification that guarantees the patched contract is free of vulnerabilities. Our evaluations on $144$ real vulnerable contracts demonstrate that ool can successfully fix $94\%$ of the detected vulnerabilities ($565$ out of $601$) and preserve the expected behaviors of the smart contracts.

研究动机与目标

  • 为解决智能合约漏洞修复中自动化工具支持的关键缺口,这些漏洞在部署后不可变,且需以高昂成本进行手动修补。
  • 实现无需依赖测试套件即可自动生成安全、行为保持不变的修补方案,适用于多种漏洞类型。
  • 支持复杂修复模式(如临时变量创建和语句重排),这些模式常用于修复如重入攻击等关键漏洞。
  • 通过静态验证确保修补后合约的正确性,正式证明原始漏洞已被消除。
  • 提供一种可泛化、高效且可扩展的框架,将检测、修补和验证整合为单一处理流水线。

提出的方法

  • ContractFix 使用三种静态验证工具的集成来检测漏洞,通过多数投票机制和后续处理过滤非可修复案例,从而降低误报率。
  • 针对特定漏洞类型(如重入攻击、输入验证缺失、被锁定的以太币)应用基于模板的修复模式。
  • 通过自定义程序分析(包括程序依赖分析和指针分析)准确推断并填充修复模式的参数。
  • 对修补后的合约执行静态验证,正式证明原始漏洞已不存在。
  • 将修补生成与检测过程解耦,支持与多种漏洞检测器集成,并可扩展至其他智能合约语言。
  • 通过轻量级分析和优化的模板应用实现运行时高效性,平均每个合约的修补时间为 3.75 秒。
Figure 1: Example patch for Reentrancy vulnerability
Figure 1: Example patch for Reentrancy vulnerability

实验结果

研究问题

  • RQ1是否能够通过自动化框架在无需测试套件的情况下,有效检测并修复智能合约中的多种漏洞?
  • RQ2是否能够通过静态分析与模板技术可靠地生成并应用复杂修复模式(如临时变量创建和语句重排)?
  • RQ3该框架能否确保生成的修补方案在消除漏洞的同时保持原始合约的行为不变?
  • RQ4与单一工具相比,该集成式静态验证方法在降低误报率方面有多大的有效性?
  • RQ5该完整流水线的性能开销如何?是否能够扩展至真实世界规模的合约?

主要发现

  • ContractFix 在 144 个真实世界智能合约中成功修复了 565 个检测到的漏洞(修复成功率 94%)。
  • 该框架实现了每个合约平均 3.75 秒的修补时间,表现出极高的效率。
  • 集成式静态验证方法通过结合三个工具的结果并应用后处理,显著降低了误报率。
  • 程序分析的使用使得修复模式参数的推断更加准确,支持如语句重排和临时变量引入等复杂修复。
  • 通过修补后的静态分析验证,确认了修复后合约的预期行为与原始合约保持一致。
  • ContractFix 具备可泛化性,可扩展至其他智能合约语言(如 Move),前提是满足类似的语言级约束。
Figure 2: An exploit of Reentrancy vulnerability
Figure 2: An exploit of Reentrancy vulnerability

更好的研究,从现在开始

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

无需绑定信用卡

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