Detecting Functional Bugs in Smart Contracts through LLM-Powered and Bug-Oriented Composite Analysis

Binbin Zhao, Xingshuang Lin, Yuan Tian, Saman A. Zonouz, Na Ruan, Jiliang Li, Raheem Beyah, Shouling Ji · DOI

Introduction

Smart contracts are the foundational layer of decentralized finance (DeFi), managing billions of dollars in assets. While traditional security tools like static analyzers and standard fuzzers effectively identify implementation-level bugs (e.g., integer overflows or reentrancy), they frequently fail to detect functional bugs. These flaws reside in high-level business logic—such as price oracle manipulation, incorrect fee calculations, or unauthorized token transfers.

Functional bugs are particularly insidious because they do not typically cause program crashes; instead, they execute "incorrect" logic that remains syntactically valid. Recent studies indicate that over 80% of exploitable vulnerabilities in smart contracts are functional in nature. Detecting them requires an understanding of the developer's abstract intent and the translation of that intent into low-level code assertions, a process that has historically necessitated manual auditing.

The PROMFUZZ Framework

To address this gap, we present PROMFUZZ, a novel security framework that bridges the divide between high-level business logic and low-level code execution. PROMFUZZ integrates the reasoning capabilities of Large Language Models (LLMs) with dynamic fuzzing through a three-phase pipeline.

The PROMFUZZ architecture consists of four primary stages: multi-perspective analysis, invariant checker generation, bug-oriented analysis, and functional bug detection.

1. LLM-Driven Multi-Perspective Analysis

Rather than relying on a single prompt, PROMFUZZ employs a dual-agent strategy using GPT-4-turbo. The Auditor Agent performs a fine-grained inspection of code semantics and business scenarios, while the Attacker Agent adopts an adversarial, coarse-grained perspective focused on exploitability. This "schizophrenic" approach forces the model to evaluate the contract from both defensive and offensive mindsets, significantly improving recall.

The Attacker Agent prompt focuses on ethical hacking and identifying potential attack models like Price Oracle Manipulation.

2. Dual-Stage Invariant Checker Generation

To mitigate LLM hallucinations, PROMFUZZ does not ask the model to write testing code directly. Instead, the LLM is used strictly for information extraction—identifying critical variables and principal statements. These extracted elements are then inserted into six predefined, deterministic templates (e.g., PriceChange_Checker) to generate robust invariant checkers (assertions).

3. Bug-Oriented Fuzzing

Traditional fuzzers often search blindly for crashes. PROMFUZZ strategically injects the generated invariant checkers into the smart contract and utilizes a customized fuzzer directed specifically to trigger these logic violations. This turns a broad search into a guided, bug-oriented analysis.

Evaluation and Real-World Impact

PROMFUZZ was evaluated against a comprehensive ground-truth dataset of 261 contracts, including real-world exploits, audit cases, and synthetic bugs. The framework achieved an 86.96% recall and a 93.02% F1-score, outperforming existing LLM-based tools and fuzzers by over 50%.

In real-world testing across 10 active DeFi projects, PROMFUZZ identified 30 zero-day functional bugs, 24 of which have been assigned CVEs. These discoveries helped secure projects with a combined Total Value Locked (TVL) of $18.2 billion. Remarkably, the system is also highly efficient, with an average analysis time of 43.8 seconds per project at a cost of approximately $0.15 in API fees.

Conclusion and Future Directions

The success of PROMFUZZ demonstrates that combining LLM-driven logic extraction with template-based code generation and guided fuzzing is a powerful strategy for securing decentralized systems. While the system currently focuses on four major bug categories, future work will involve fine-tuning open-source LLMs to reduce API dependency and expanding the template library to cover a broader range of complex functional vulnerabilities. By providing a "map" for fuzzers through LLM-derived invariants, PROMFUZZ sets a new standard for automated smart contract auditing.

Summary updated

BibTeX
@misc{zhao2025detecting,
  author = {Binbin Zhao and Xingshuang Lin and Yuan Tian and Saman A. Zonouz and Na Ruan and Jiliang Li and Raheem Beyah and Shouling Ji},
  title = {{Detecting Functional Bugs in Smart Contracts through LLM-Powered and Bug-Oriented Composite Analysis}},
  year = {2025},
  eprint = {2503.23718},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2503.23718},
}
Figure