Skip to main content
QUICK REVIEW

[论文解读] Smart Learning to Find Dumb Contracts (Extended Version)

Tamer Abdelaziz, Aquinas Hobor|ArXiv.org|Apr 21, 2023
Imbalanced Data Classification TechniquesComputer Science被引用 3
一句话总结

DLVA 是一种基于深度学习的以太坊智能合约漏洞分析工具,可直接分析字节码而无需源代码。它采用一种新颖的智能合约向量表示(SC2V)嵌入方法,结合同源合约检测器(Sibling Detector)与基于神经网络的核心分类器,实现了对 29 种漏洞的 92.7% 准确率检测,优于 Slither 及其他 9 种工具,分析时间仅 0.2 秒,较形式化方法提速 10 至 1000 倍。

ABSTRACT

We introduce the Deep Learning Vulnerability Analyzer (DLVA) for Ethereum smart contracts based on neural networks. We train DLVA to judge bytecode even though the supervising oracle can only judge source. DLVA's training algorithm is general: we extend a source code analysis to bytecode without any manual feature engineering, predefined patterns, or expert rules. DLVA's training algorithm is also robust: it overcame a 1.25% error rate mislabeled contracts, and--the student surpassing the teacher--found vulnerable contracts that Slither mislabeled. DLVA is much faster than other smart contract vulnerability detectors: DLVA checks contracts for 29 vulnerabilities in 0.2 seconds, a 10-1,000x speedup. DLVA has three key components. First, Smart Contract to Vector (SC2V) uses neural networks to map smart contract bytecode to a high-dimensional floating-point vector. We benchmark SC2V against 4 state-of-the-art graph neural networks and show that it improves model differentiation by 2.2%. Second, Sibling Detector (SD) classifies contracts when a target contract's vector is Euclidian-close to a labeled contract's vector in a training set; although only able to judge 55.7% of the contracts in our test set, it has a Slither-predictive accuracy of 97.4% with a false positive rate of only 0.1%. Third, Core Classifier (CC) uses neural networks to infer vulnerable contracts regardless of vector distance. We benchmark DLVA's CC with 10 ML techniques and show that the CC improves accuracy by 11.3%. Overall, DLVA predicts Slither's labels with an overall accuracy of 92.7% and associated false positive rate of 7.2%. Lastly, we benchmark DLVA against nine well-known smart contract analysis tools. Despite using much less analysis time, DLVA completed every query, leading the pack with an average accuracy of 99.7%, pleasingly balancing high true positive rates with low false positive rates.

研究动机与目标

  • 开发一种直接在字节码上运行的以太坊智能合约漏洞检测工具,无需依赖源代码。
  • 将仅支持源代码的分析工具(如 Slither)的能力扩展至字节码,利用深度学习实现。
  • 在漏洞检测中实现高准确率与高效率,尤其针对无源代码可获取的合约。
  • 通过将分析时间从数分钟缩短至 0.2 秒以内,克服传统形式化方法的局限性。

提出的方法

  • SC2V 使用混合的无监督与有监督神经网络,将以太坊字节码映射为高维浮点向量,训练数据来自 Slither 标注的源代码。
  • 同源合约检测器(Sibling Detector)基于向量空间中的欧几里得距离对合约进行分类,将与训练集中已标注合约相近的合约归类。
  • 核心分类器(Core Classifier)使用独立的神经网络对同源检测器未覆盖的合约进行分类,训练数据与前述一致。
  • DLVA 将 SC2V、同源检测器与核心分类器组合为集成模型,结合相似性匹配与深度学习,实现稳健的漏洞检测。
  • 模型通过端到端训练,仅使用 Slither 对源代码的标签,实现从源代码到字节码的知识迁移,无需人工特征工程。
  • DLVA 与 10 种现成的机器学习模型及 9 种现有工具进行基准对比,性能指标包括准确率、误报率与分析时间。

实验结果

研究问题

  • RQ1在无源代码访问的前提下,基于源代码标签训练的深度学习模型能否准确检测字节码中的漏洞?
  • RQ2基于神经网络的字节码向量化方法在捕捉漏洞相关模式方面,与最先进的图神经网络相比表现如何?
  • RQ3结合向量相似性(同源检测器)与深度学习(核心分类器)的混合方法,是否优于单一模型的漏洞检测性能?
  • RQ4在仅使用有限标注源代码进行训练的情况下,模型在更广泛范围的字节码合约上(尤其是无源代码的合约)的泛化能力如何?
  • RQ5基于深度学习的分析工具是否在速度与准确率上均优于传统形式化方法与现有静态分析工具?

主要发现

  • DLVA 在预测 29 种漏洞的 Slither 标签时,整体准确率达到 92.7%,误报率为 7.2%。
  • 核心分类器(CC)在同源检测器未覆盖的 44.3% 难度较高的合约上达到 80.0% 的准确率,较 10 种现成机器学习模型的平均值高出 11.3%。
  • 与单个机器学习模型相比,DLVA 的 CC 将错误集合(误分类合约)规模平均减少 36%;与投票元竞争模型相比,减少 30%。
  • DLVA 成功处理了 100% 的合约,跨九个基准工具的平均准确率达 99.7%,误报率 0.6%,平均分析时间仅 0.2 秒。
  • 尽管 DLVA 仅基于字节码运行,而 Slither 需要源代码,DLVA 在除真正例率(+0.7%)外的所有指标上均优于 Slither。
  • 与四种最先进的图神经网络相比,SC2V 模型在平均上使模型区分能力提升 2.2%,在最佳基线上提升 1.2%。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。