一句话:首次系统研究比特币脚本缺陷,定义六类缺陷,并用符号执行检测和虚拟机插桩追踪其利用。
本文首次系统研究比特币脚本缺陷,指出脚本缺陷会导致用户损失比特币。作者首先在比特币历史中定义六类典型缺陷:unbinded-txid、simple-key、useless-sig、uncertain-sig、impossible-key 和 never-true,其中三类来自社区,三类为新提出。其次,开发基于符号执行并以历史精确脚本增强的检测工具,扫描 2009 年 10 月至 2022 年 8 月的全部比特币交易,发现 383,544 个输出支付给缺陷脚本,金额合计 3,115.43 BTC(目前约 6000 万美元)。最后,插桩 Bitcoin VM 记录真实花费交易轨迹,发现 84,130 个输出脚本被利用。实现与无害数据集已发布。
Supporting the most popular cryptocurrency, the Bitcoin platform allows its transactions to be programmable via its scripts. Defects in Bitcoin scripts will make users lose their bitcoins. However, there are few studies on the defects of Bitcoin scripts. In this paper, we conduct the first systematic investigation on the defects of Bitcoin scripts through three steps, including defect definition, defect detection, and exploitation tracing. First, we define six typical defects of scripts in Bitcoin history, namely unbinded-txid, simple-key, useless-sig, uncertain-sig, impossible-key, and never-true. Three are inspired by the community, and three are new from us. Second, we develop a tool to discover Bitcoin scripts with any of typical defects based on symbolic execution and enhanced by historical exact scripts. By analyzing all Bitcoin transactions from Oct. 2009 to Aug. 2022, we find that 383,544 transaction outputs are paid to the Bitcoin scripts with defects. The total amount of them is 3,115.43 BTC, which is around 60 million dollars at present. Third, in order to trace the exploitation of the defects, we instrument the Bitcoin VM to record the traces of the real-world spending transactions of the buggy scripts. We find that 84,130 output scripts are exploited. The implementation and non-harmful datasets are released.