Augmenting Smart Contract Decompiler Output Through Fine-Grained Dependency Analysis and LLM-Facilitated Semantic Recovery

Zeqin Liao, Yuhong Nan, Zixu Gao, Henglong Liang, Sicheng Hao, Peifan Reng, Zibin Zheng

Introduction

The security of decentralized applications (DApps) relies heavily on the ability to audit smart contract bytecode. Decompilers are essential tools for this task, translating machine-executable bytecode back into human-readable Solidity. However, the compilation process is inherently "lossy," stripping away critical semantic information such as variable names, specific data types, and function boundaries. Current state-of-the-art decompilers often produce generic output where complex types are reduced to 256-bit integers, and distinct functions are incorrectly merged. This degradation significantly hinders both manual audits and automated vulnerability detection.

Comparison between source and decompiled code highlighting type errors and mapping mismatches.

The SmartHalo Framework

To address these limitations, we present SmartHalo, a novel framework that augments decompiler output by combining static analysis with the semantic reasoning capabilities of Large Language Models (LLMs). The pipeline consists of three primary stages:

  1. Dependency-based Semantic Extraction: SmartHalo constructs a Dependency Graph (DG) to track control-flow, data-flow, and type dependencies. This structural representation captures how data moves through the contract, providing a foundation for semantic recovery.
  2. LLM-driven Semantic Enrichment: Utilizing the DG, SmartHalo performs "code slicing" to extract focused snippets relevant to specific variables or functions. These slices are processed by an LLM (e.g., GPT-4o) using Chain-of-Thought (CoT) prompting. This allows the model to infer types based on usage patterns—for instance, identifying an address type when a variable is compared against msg.sender.
  3. Correctness Verification: To mitigate the risk of AI hallucinations, SmartHalo employs symbolic execution and the Z3 formal verification solver. It ensures that the LLM-optimized code remains behaviorally identical to the original decompiled bytecode, rejecting any changes that alter the program's logic.

Evaluation and Results

SmartHalo was evaluated against a diverse dataset of 456 open-source contracts and 682 real-world DApps from audit reports. The framework demonstrated substantial improvements over existing tools like Gigahorse:

  • Type and Boundary Recovery: SmartHalo achieved 90.40% precision in recovering variable types and 91.32% precision in identifying function boundaries.
  • Semantic Attribute Identification: The tool successfully identified high-level attributes (e.g., "Asset" or "Identity") with 91.78% recall, which is critical for understanding contract logic.
  • Vulnerability Detection: By providing cleaner, semantically richer code, SmartHalo improved the precision of reentrancy detection by approximately 8% and increased the recall of attack identification by 16.67%.
Decompiled code often lacks semantic attributes like 'Asset', making vulnerability detection difficult.

Discussion and Conclusion

A key insight from this work is the synergy between the "soundness" of static analysis and the "completeness" of LLMs. While static analysis provides a reliable structural backbone, LLMs excel at filling in the semantic gaps left by compilation. Furthermore, SmartHalo significantly improves the "recompilability" of decompiled code, achieving a rate of over 60%, a major milestone for automated reverse engineering.

Despite its successes, SmartHalo faces challenges with contracts utilizing extensive inline assembly or unconventional delegation structures. Future research will focus on deeper integration with the Ethereum Virtual Machine (EVM) lifting process to further enhance the fidelity of the recovered source code.

Summary updated

BibTeX
@article{liao2025augmenting,
  author = {Zeqin Liao and Yuhong Nan and Zixu Gao and Henglong Liang and Sicheng Hao and Peifan Reng and Zibin Zheng},
  title = {{Augmenting Smart Contract Decompiler Output Through Fine-Grained Dependency Analysis and LLM-Facilitated Semantic Recovery}},
  journal = {IEEE Trans. Software Eng.},
  year = {2025},
  doi = {10.1109/tse.2025.3623325},
}
Figure