Skip to main content
QUICK REVIEW

[论文解读] TokenHook: Secure ERC-20 smart contract

Reza Rahimian, Jeremy Clark|arXiv (Cornell University)|Jul 7, 2021
Blockchain Technology Applications and Security参考文献 16被引用 6
一句话总结

本文介绍了 TokenHook,一种安全、开源的 ERC-20 智能合约实现,支持 Vyper 和 Solidity 两种语言,旨在缓解已知漏洞并提升对安全最佳实践的合规性。其在审计精度方面优于现有实现,在七款行业级工具中报告的缺陷数量最少——主要为误报——展现出其强大的稳健性,适合作为第二参考实现,以增强软件多样性与审计可靠性。

ABSTRACT

ERC-20 is the most prominent Ethereum standard for fungible tokens. Tokens implementing the ERC-20 interface can interoperate with a large number of already deployed internet-based services and Ethereum-based smart contracts. In recent years, security vulnerabilities in ERC-20 have received special attention due to their widespread use and increased value. We systemize these vulnerabilities and their applicability to ERC-20 tokens, which has not been done before. Next, we use our domain expertise to provide a new implementation of the ERC-20 interface that is freely available in Vyper and Solidity, and has enhanced security properties and stronger compliance with best practices compared to the sole surviving reference implementation (from OpenZeppelin) in the ERC-20 specification. Finally, we use our implementation to study the effectiveness of seven static analysis tools, designed for general smart contracts, for identifying ERC-20 specific vulnerabilities. We find large inconsistencies across the tools and a high number of false positives which shows there is room for further improvement of these tools.

研究动机与目标

  • 系统化并分析 82 种与 ERC-20 代币相关的特定漏洞及最佳实践,填补先前研究的空白。
  • 开发一种新型、安全的 ERC-20 实现——TokenHook,其安全性与合规性超越当前的 OpenZeppelin 参考实现。
  • 评估七款广泛使用的静态分析工具在检测 ERC-20 特定漏洞方面的有效性、精确性与完整性。
  • 通过提供原生 Vyper 的 ERC-20 实现,促进软件多样性,因为目前尚无此类参考实现。
  • 以 TokenHook 作为黄金标准实现,对审计工具的性能进行基准测试,揭示其中关键的不一致性和误报率。

提出的方法

  • 作者对已知的 ERC-20 漏洞进行了全面调查,并将其映射到特定攻击向量与缓解策略。
  • 他们设计并实现了 TokenHook 的 Vyper 和 Solidity 版本,融入防御性编程模式,并利用 Vyper 内置的溢出保护机制。
  • 在标准化条件下,使用七款静态分析工具——Securify、MythX、ContractGuard、Slither、Odin 等——对实现进行了审计。
  • 通过人工复核排除了误报,计算出 TokenHook 在所有工具上的精炼成功率高达 99.5%。
  • 将审计结果与市值排名前十的 ERC-20 代币进行对比,以评估其相对安全报告能力。
  • 本研究使用 TokenHook 作为基准,评估工具在检测重入、溢出和前端交易攻击等问题上的局限性。

实验结果

研究问题

  • RQ1哪些是 ERC-20 代币合约中最常见且最具影响的漏洞?它们能否被系统性地分类?
  • RQ2现有静态分析工具在检测 ERC-20 特定漏洞方面的准确度如何?误报率在多大程度上影响其可靠性?
  • RQ3新型 ERC-20 实现能否在安全性与最佳实践合规性方面超越当前的 OpenZeppelin 参考实现?
  • RQ4编程语言的选择(Vyper 与 Solidity)如何影响 ERC-20 合约的安全性与可审计性?
  • RQ5TokenHook 是否可作为评估智能合约审计工具精确性与完整性的可靠基准?

主要发现

  • 在所有评估的 ERC-20 代币中,包括 USDT 和 USDC 等市值领先的代币,TokenHook 报告的检测到的安全缺陷最少,仅 40 个。
  • 尽管在其他代币中检测到的缺陷数量较高(如 USDT 为 197 个,LEO 为 252 个),但 TokenHook 中所有缺陷均为误报,表明其代码质量极高。
  • 在人工排除误报后,审计工具在 TokenHook 上的平均成功率提升至 99.5%,充分证明其稳健性与可靠性。
  • 研究揭示了各工具之间存在显著不一致性,部分工具将非问题(如气体限制或合约钱包交互)错误标记为漏洞。
  • Vyper 实现原生防止整数溢出,而 Solidity 需依赖 SafeMath 或版本 0.8.4 才能实现同等保护,凸显了语言级别的安全差异。
  • 审计结果表明,尽管现有工具具有辅助作用,但无法替代专家代码审查,而 TokenHook 的设计显著减少了误报噪声。

更好的研究,从现在开始

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

无需绑定信用卡

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