MTVHunter: Smart Contracts Vulnerability Detection Based on Multi-Teacher Knowledge Translation

Guokai Sun, Yuan Zhuang, Shuo Zhang, Xiaoyu Feng, Zhenguang Liu, Liguo ZhangAAAI 2025 · DOI

TL;DR

This paper introduces MTVHunter, a novel framework for detecting vulnerabilities in smart contract bytecode. By employing a multi-teacher approach with an instruction denoising teacher and a semantic complementary teacher, MTVHunter effectively addresses the challenges of noisy bytecode and missing semantic information, achieving state-of-the-art performance.

What Problem Does This Paper Address?

The increasing reliance on smart contracts for managing digital assets on blockchains has led to significant financial losses due to security vulnerabilities. While many tools exist for detecting these vulnerabilities, they struggle with the inherent complexities of smart contract bytecode. Specifically, bytecode often contains a large amount of irrelevant instructions (noise) that obscure critical vulnerability-related code. Furthermore, the process of compiling source code to bytecode can result in the loss of crucial semantic information, making it difficult to fully understand the contract's logic and identify potential flaws. Existing methods often fail to effectively handle both noise and missing semantics simultaneously, leading to suboptimal detection accuracy.

Methods

MTVHunter employs a multi-teacher framework with a "student" network that learns from two specialized "teachers":

  • Instruction Denoising Teacher (IDT): This teacher aims to filter out irrelevant instructions from the bytecode. It utilizes Abstract Vulnerability Patterns (AVPs), which are fine-grained patterns designed to identify critical instructions related to specific vulnerability types (e.g., State-Loading, State-Operation, State-Storage). A Node Scoring Mechanism (NSM) then assigns scores to nodes in the control flow graph (CFG) based on whether their instructions match these AVPs, effectively highlighting important parts of the code and downplaying noise.
  • Semantic Complementary Teacher (SCT): This teacher focuses on restoring the missing semantic information lost during bytecode compilation. It leverages Neuron Distillation (ND), a novel technique that maps extracted semantic features from the original source code to the bytecode. ND uses a set of neurons, each with learnable weights and biases, to approximate an optimal hyperplane for knowledge transfer, effectively filling in the semantic gaps in the bytecode.

The Two-Stage Student network then integrates the knowledge from both teachers. It consists of:

  • An Instruction Sequence Extractor (ISEor) that processes the denoised bytecode sequence.
  • A Graph Feature Extractor (GFEor) that uses a Graph Attention Network (GAT) to capture global graph features and incorporates the semantic knowledge from SCT.

The entire framework is trained using a Multi-Knowledge Loss function, which combines label learning loss (predicting vulnerability) and semantic learning loss (ensuring accurate semantic transfer).

Datasets

The paper uses a large dataset of 229,178 public smart contracts from the Ethereum website. After cleaning and filtering, they retained 10,356 contracts with valid compilations. They then identified and labeled contracts for four specific vulnerability types: Reentrancy, Timestamp dependence, TX.Origin, and Delegatecall. The dataset was split into 1627 positive (vulnerable) and 5860 negative (benign) contracts for evaluation.

Key Insights and Ideas

  • Bytecode is inherently noisy and semantically incomplete: The paper clearly articulates the dual challenges of dealing with extraneous instructions and lost semantic meaning when analyzing smart contract bytecode.
  • Abstract Vulnerability Patterns (AVPs) are crucial for denoising: Instead of treating all instructions equally, defining specific patterns related to vulnerability types allows for a more targeted approach to noise reduction.
  • Neuron Distillation (ND) effectively bridges the source-to-bytecode semantic gap: The proposed ND method, by framing knowledge transfer as a regression task, proves more effective than traditional distillation techniques in recovering lost semantic information.
  • Multi-teacher learning is a powerful paradigm for complex tasks: By separating concerns into specialized teachers (denoising and semantic completion), the student network can learn more effectively.
  • Complete denoising is key for IDT: Ablation studies suggest that partial denoising can sometimes be detrimental, highlighting the importance of thoroughly removing noise.

Key Results

MTVHunter achieved state-of-the-art performance on smart contract vulnerability detection.

  • Overall Accuracy: MTVHunter achieved an accuracy of 95.10% on Reentrancy vulnerability detection, a significant improvement over existing methods.
  • Comparison with Traditional Methods: It significantly outperformed traditional tools like Slither, achieving a 24.71% improvement in accuracy.
  • Comparison with Neural Network-Based Methods: MTVHunter showed substantial gains over sequence-based methods (e.g., 26.14% accuracy gap on Timestamp vulnerability) and improved upon GNN-based methods like DMT by 8.24% on TX.Origin vulnerability.
  • Ablation Studies:
    • IDT-CD (complete denoising) significantly outperformed IDT-w/o (without IDT) by 11.18% accuracy on Reentrancy.
  • The SCT with 3-Neuron distillation achieved the highest F1 score of 90.91%.

Limitations and Future Work

  • Limitations:
    • The paper notes that partial denoising (IDT-PD) did not always perform better than no denoising, indicating a need for careful tuning of the denoising process.
  • The effectiveness of the AVP approach for TX.Origin vulnerability was noted to require less semantic information, suggesting that different vulnerabilities might have varying demands for semantic completeness.
  • Future Work:
    • The authors believe their work is a step towards integrating deep learning with vulnerability detection and suggest further exploration in this area.
  • The paper's methodology could be extended to cover a wider range of smart contract vulnerabilities.
  • Further research into optimizing the neuron distillation process and the multi-knowledge loss function could yield even better results.

Summary updated

BibTeX
@inproceedings{sun2025mtvhunter,
  author = {Guokai Sun and Yuan Zhuang and Shuo Zhang and Xiaoyu Feng and Zhenguang Liu and Liguo Zhang},
  title = {{MTVHunter: Smart Contracts Vulnerability Detection Based on Multi-Teacher Knowledge Translation}},
  booktitle = {AAAI Conference on Artificial Intelligence},
  year = {2025},
  doi = {10.1609/aaai.v39i14.33664},
}
Figure