ExDoS: Expert-Guided Dual-Focus Cross-Modal Distillation for Smart Contract Vulnerability Detection

Yifan Jia, Ye Tian, Yanbin Wang, Jianguo Sun, Haitao XuarXiv 2025 · DOI · arXiv

Abstract

The success of smart contracts has made them a target for attacks, but their closed-source nature often forces vulnerability detection to work on bytecode, which is inherently more challenging than source-code-based analysis. While recent studies try to align source and bytecode embeddings during training to transfer knowledge, current methods rely on graph-level alignment that obscures fine-grained structural and semantic correlations between the two modalities. Moreover, the absence of precise vulnerability patterns and granular annotations in bytecode leads to depriving the model of crucial supervisory signals for learning discriminant features. We propose ExDoS to transfer rich semantic knowledge from source code to bytecode, effectively supplementing the source code prior in practical settings. Specifically, we construct semantic graphs from source code and control-flow graphs from bytecode. To address obscured local signals in graph-level contract embeddings, we propose a Dual-Attention Graph Network introducing a novel node attention aggregation module to enhance local pattern capture in graph embeddings. Furthermore, by summarizing existing source code vulnerability patterns and designing a corresponding set of bytecode-level patterns for each, we construct the first dataset of vulnerability pattern annotations aligned with source code definitions to facilitate fine-grained cross-modal alignment and the capture of function-level vulnerability signals. Finally, we propose a dual-focus objective for our cross-modal distillation framework, comprising: a Global Semantic Distillation Loss for transferring graph-level knowledge and a Local Semantic Distillation Loss enabling expert-guided, fine-grained vulnerability-specific distillation. Experiments on real-world contracts demonstrate that our method achieves consistent F1-score improvements (3%--6%) over strong baselines.

Introduction

Smart contracts handle billions of dollars in decentralized ecosystems, making them prime targets for exploits like reentrancy attacks or infinite loops. While many security tools analyze Solidity source code to find these bugs, real-world deployed contracts are usually closed-source. Security analysts are often left with raw Ethereum Virtual Machine (EVM) bytecode, which is notoriously opaque and strips away high-level logic, variable names, and data types.

Recent machine learning approaches have tried to bridge this gap by training models on source code and transferring that knowledge to bytecode models. However, they typically align the code at a coarse "macro" or graph level. Because vulnerabilities often hide in tiny, localized snippets of code, this coarse alignment washes out critical signals. ExDoS addresses this by introducing a dual-focus distillation framework that aligns both global context and fine-grained, expert-annotated vulnerability patterns.

Methodology

System Architecture

The ExDoS framework utilizes a teacher-student architecture to transfer knowledge from a source-code model to a bytecode model. The process begins with contract processing and graph construction, followed by a dual-focus knowledge distillation phase.

The ExDoS architecture: from contract processing and graph construction to dual-focus knowledge distillation and final prediction.

Graph Representation and Expert Alignment

Source code is converted into a Code Semantic Graph (CSG), while bytecode is transformed into a Control Flow Graph (CFG). Unlike standard graph neural networks that use simple pooling, ExDoS introduces a Dual-Attention Graph Network (DAGN) with an Attention-Based Graph Pooling (AGP) module. This allows the model to assign higher weights to critical nodes, preserving local patterns that might otherwise be diluted.

Construction of a Code Semantic Graph (CSG) from source code, mapping operations and variables to graph nodes to facilitate fine-grained alignment.

To bridge the semantic gap, the authors manually translated known source-code vulnerability patterns into exact bytecode/opcode equivalents. This expert-guided alignment allows for a Local Semantic Distillation Loss, which forces the student model to align specific, expert-annotated vulnerable nodes (e.g., a specific CALL opcode block) with their corresponding source-code nodes. This is complemented by a Global Semantic Distillation Loss that aligns the overall graph-level embeddings.

Experimental Results

ExDoS was evaluated against traditional static analysis tools (like Slither and Mythril) and state-of-the-art deep learning baselines. The framework achieved significant performance gains across multiple vulnerability types:

  • Reentrancy: 90.86% F1-score (vs. 71.23% for Slither).
  • Timestamp Dependence: 90.23% F1-score.
  • Infinite Loop: 83.94% F1-score.

These results represent absolute F1 improvements of 2.7% to 6.2% over the next best deep learning models. Ablation studies confirmed that removing either the global or local distillation components leads to a noticeable drop in performance, validating the dual-focus approach.

Conclusion

ExDoS demonstrates that fine-grained, expert-guided alignment is crucial for transferring semantic knowledge from source code to bytecode. By focusing on both global context and local vulnerability patterns, the model achieves high accuracy on deployed contracts using only bytecode at inference time. Future work will involve expanding the expert pattern dictionary to cover a wider array of vulnerability types and automating the discovery of cross-modal patterns without manual human mapping.

Summary updated

Abstract

The success of smart contracts has made them a target for attacks, but their closed-source nature often forces vulnerability detection to work on bytecode, which is inherently more challenging than source-code-based analysis. While recent studies try to align source and bytecode embeddings during training to transfer knowledge, current methods rely on graph-level alignment that obscures fine-grained structural and semantic correlations between the two modalities. Moreover, the absence of precise vulnerability patterns and granular annotations in bytecode leads to depriving the model of crucial supervisory signals for learning discriminant features. We propose ExDoS to transfer rich semantic knowledge from source code to bytecode, effectively supplementing the source code prior in practical settings. Specifically, we construct semantic graphs from source code and control-flow graphs from bytecode. To address obscured local signals in graph-level contract embeddings, we propose a Dual-Attention Graph Network introducing a novel node attention aggregation module to enhance local pattern capture in graph embeddings. Furthermore, by summarizing existing source code vulnerability patterns and designing a corresponding set of bytecode-level patterns for each, we construct the first dataset of vulnerability pattern annotations aligned with source code definitions to facilitate fine-grained cross-modal alignment and the capture of function-level vulnerability signals. Finally, we propose a dual-focus objective for our cross-modal distillation framework, comprising: a Global Semantic Distillation Loss for transferring graph-level knowledge and a Local Semantic Distillation Loss enabling expert-guided, fine-grained vulnerability-specific distillation. Experiments on real-world contracts demonstrate that our method achieves consistent F1-score improvements (3\%--6\%) over strong baselines.
BibTeX
@misc{jia2025exdos,
  author = {Yifan Jia and Ye Tian and Yanbin Wang and Jianguo Sun and Haitao Xu},
  title = {{ExDoS: Expert-Guided Dual-Focus Cross-Modal Distillation for Smart Contract Vulnerability Detection}},
  year = {2025},
  eprint = {2509.10252},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.10252},
  howpublished = {arXiv},
}
Figure