[论文解读] G-Scan: Graph Neural Networks for Line-Level Vulnerability Identification in Smart Contracts
G-Scan 是首个用于以太坊智能合约中细粒度、行级漏洞检测的端到端图神经网络系统。它从 Solidity 源代码构建保留依赖关系和层次结构的代码图,使用 GCN 预测漏洞节点,并将预测结果映射回源代码行,在一个新型真实世界重入漏洞数据集上实现了 93.69% 的 F1 分数。
Due to the immutable and decentralized nature of Ethereum (ETH) platform, smart contracts are prone to security risks that can result in financial loss. While existing machine learning-based vulnerability detection algorithms achieve high accuracy at the contract level, they require developers to manually inspect source code to locate bugs. To this end, we present G-Scan, the first end-to-end fine-grained line-level vulnerability detection system evaluated on the first-of-its-kind real world dataset. G-Scan first converts smart contracts to code graphs in a dependency and hierarchy preserving manner. Next, we train a graph neural network to identify vulnerable nodes and assess security risks. Finally, the code graphs with node vulnerability predictions are mapped back to the smart contracts for line-level localization. We train and evaluate G-Scan on a collected real world smart contracts dataset with line-level annotations on reentrancy vulnerability, one of the most common and severe types of smart contract vulnerabilities. With the well-designed graph representation and high-quality dataset, G-Scan achieves 93.02% F1-score in contract-level vulnerability detection and 93.69% F1-score in line-level vulnerability localization. Additionally, the lightweight graph neural network enables G-Scan to localize vulnerabilities in 6.1k lines of code smart contract within 1.2 seconds.
研究动机与目标
- 为解决现有工具在智能合约中无法准确进行细粒度、行级漏洞定位的问题。
- 克服先前基于 GNN 的方法无法将节点级预测结果回映射到源代码行的局限性。
- 创建并评估首个真实世界、行级标注的智能合约重入漏洞数据集。
- 设计一种保留数据依赖关系和代码层次结构的图表示方法,以提升漏洞检测效果。
- 实现高效、低开销的推理过程,适用于大型合约,从而减少开发者调试时间。
提出的方法
- 利用抽象语法树(AST)将 Solidity 智能合约转换为代码图,并添加数据依赖边和控制层次边。
- 为节点分配特征,包括函数类型(如 While、For)、变量属性(可见性、存储)以及成员访问(send、transfer)。
- 使用图卷积网络(GCN)学习隐藏表示,以编码图中跨节点的漏洞模式。
- 对 GCN 进行节点级分类训练,以预测每个代码图节点是否对应于一个漏洞行。
- 通过在 AST 构建过程中存储的 'src' 属性,将预测的漏洞节点回映射到其原始源代码行。
- 在新收集的真实世界数据集(包含 13,773 个智能合约及其行级重入漏洞标注)上评估模型。
实验结果
研究问题
- RQ1图神经网络能否在真实世界的智能合约中有效实现行级重入漏洞检测?
- RQ2在图表示中保留代码依赖关系和层次结构对检测性能有何影响?
- RQ3G-Scan 是否能在大型合约中实现高效漏洞定位,且推理开销低?
- RQ4与现有合约级和节点级检测系统相比,G-Scan 在细粒度定位方面的表现如何?
- RQ5与以往研究中使用的合成注入方法相比,使用真实世界标注数据集在多大程度上提升了检测准确率?
主要发现
- G-Scan 在真实世界数据集上的合约级漏洞检测中实现了 93.02% 的 F1 分数,表明其具有很高的分类准确率。
- 该系统在行级漏洞定位中达到 93.69% 的 F1 分数,显著优于缺乏回映射能力的先前方法。
- G-Scan 在 6.1k 行代码内实现漏洞定位仅耗时 1.2 秒,表明其推理开销低,适合实际应用。
- 使用真实世界标注数据集进行训练可获得比以往研究中使用的合成注入方法更高的检测准确率。
- 在图构建过程中保留代码依赖关系和层次结构可提升模型性能,从而捕捉关键的漏洞模式。
- 通过 'src' 属性集成源代码行映射,使漏洞定位更加准确且对开发者具有实际可操作性。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。