arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2305.07067cs.CRcs.SE
收藏

SigRec:智能合约中函数签名的自动恢复

SigRec: Automatic Recovery of Function Signatures in Smart Contracts

Ting Chen, Zihao Li, Xiapu Luo, Xiaofeng Wang, Ting Wang, Zheyuan He, Kezhao Fang, Yufei Zhang, Hang Zhu, Hongwei Li, Yan Cheng, Xiaosong Zhang

AI总结:

本文提出SigRec工具,利用EVM处理函数的机制自动从智能合约字节码中恢复函数签名,无需源码或数据库,在0.074秒内达到98.7%准确率,并验证了其在攻击检测、模糊测试和逆向工程中的实用性。

摘要:

数百万个智能合约已被部署到以太坊上以提供各种服务,这些合约的函数可以被调用。为此,调用者需要知道被调用者的函数签名,其中包括函数标识符和参数类型。此类签名对于许多专注于智能合约的应用(如逆向工程、模糊测试、攻击检测和性能分析)至关重要。不幸的是,从合约字节码中恢复函数签名具有挑战性,因为字节码中既没有调试信息也没有类型信息。为解决此问题,先前的方法依赖于源代码,或从不完整的数据库或不完整的启发式规则中收集已知签名,但这些方法远远不够,且无法应对新合约的快速增长。在本文中,我们提出了一种新颖的解决方案,利用以太坊虚拟机(EVM)处理函数的方式来自动恢复函数签名。具体而言,我们利用智能合约确定要调用的函数的方式来定位和提取函数标识符,并提出了一种名为类型感知符号执行(TASE)的新方法,该方法利用EVM对参数操作的语义来确定参数的数量和类型。此外,我们开发了SigRec,一种无需源代码和函数签名数据库即可从合约字节码中恢复函数签名的新工具。广泛的实验结果表明,SigRec优于所有现有工具,在0.074秒内实现了前所未有的98.7%的准确率。我们进一步证明了恢复的函数签名在EVM字节码的攻击检测、模糊测试和逆向工程中是有用的。

英文摘要:

Millions of smart contracts have been deployed onto Ethereum for providing various services, whose functions can be invoked. For this purpose, the caller needs to know the function signature of a callee, which includes its function id and parameter types. Such signatures are critical to many applications focusing on smart contracts, e.g., reverse engineering, fuzzing, attack detection, and profiling. Unfortunately, it is challenging to recover the function signatures from contract bytecode, since neither debug information nor type information is present in the bytecode. To address this issue, prior approaches rely on source code, or a collection of known signatures from incomplete databases or incomplete heuristic rules, which, however, are far from adequate and cannot cope with the rapid growth of new contracts. In this paper, we propose a novel solution that leverages how functions are handled by Ethereum virtual machine (EVM) to automatically recover function signatures. In particular, we exploit how smart contracts determine the functions to be invoked to locate and extract function ids, and propose a new approach named type-aware symbolic execution (TASE) that utilizes the semantics of EVM operations on parameters to identify the number and the types of parameters. Moreover, we develop SigRec, a new tool for recovering function signatures from contract bytecode without the need of source code and function signature databases. The extensive experimental results show that SigRec outperforms all existing tools, achieving an unprecedented 98.7 percent accuracy within 0.074 seconds. We further demonstrate that the recovered function signatures are useful in attack detection, fuzzing and reverse engineering of EVM bytecode.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑