Semantic Sleuth: Identifying Ponzi Contracts via Large Language Models

Cong Wu, Jing Chen, Ziwei Wang, Ruichao Liang, Ruiying Du

Abstract

Smart contracts in Decentralized Finance (DeFi) are increasingly being exploited to facilitate Ponzi schemes. Traditional detection methods rely on pattern matching and labeled data, often failing to generalize to new scam variants. This paper presents PonziSleuth, an LLM-driven framework that identifies Ponzi contracts through semantic reasoning. By integrating static taint analysis with a two-step zero-shot chain-of-thought prompting mechanism, PonziSleuth achieves high accuracy without requiring labeled training data.

Introduction

In the Decentralized Finance (DeFi) ecosystem, Ponzi schemes represent a significant threat. These fraudulent smart contracts promise high returns but operate by redistributing funds from new investors to earlier participants.

The fundamental mechanism of a Ponzi scheme involves using funds from new participants to pay returns to earlier investors.

Existing detection tools like PonziGuard or SADPonzi often struggle with a "generalization gap." Because they are trained on historical datasets, they frequently fail when scammers modify their code or adopt novel structures. Furthermore, these "black-box" models lack interpretability. PonziSleuth addresses these challenges by leveraging the natural language understanding of Large Language Models (LLMs) to analyze the behavioral semantics of contract code.

Methodology: The PonziSleuth Framework

PonziSleuth employs a three-phase pipeline designed to optimize the LLM's reasoning capabilities while minimizing computational overhead.

The PonziSleuth pipeline consists of AST/IR generation, static taint analysis and slicing, and LLM-driven detection.

1. AST and IR Generation

The process begins by compiling Solidity source code into an Abstract Syntax Tree (AST) and subsequently into an Intermediate Representation (IR). This transformation simplifies the complex code structure into a format more conducive to logical analysis.

2. Taint Analysis and Slicing

To prevent the LLM from being overwhelmed by irrelevant code, the framework performs static taint analysis. It tracks the flow of funds from the sender (msg.sender) and the value sent (msg.value). Through contract slicing, the system extracts only the specific functions and logic paths that interact with these financial flows.

3. LLM-Driven Detection

The core of the system is a two-step zero-shot Chain-of-Thought (CoT) prompting technique:

  • Logic Analysis: The LLM analyzes the contract's business model and fund flow based on the provided slices and a Taint Propagation Graph.
  • Verdict: The LLM compares its analysis against the formal definition of a Ponzi scheme to provide a final classification.

Evaluation and Results

The researchers evaluated PonziSleuth across three datasets: a standard benchmark of 1,451 contracts, a new balanced dataset covering Solidity versions from 2016 to 2024, and a real-world set of 4,597 Etherscan-verified contracts.

Key findings include:

  • High Accuracy: Utilizing GPT-3.5-turbo, PonziSleuth achieved a Balanced Accuracy (BAC) of 96.06%, outperforming state-of-the-art models that rely on extensive training.
  • Robust Generalization: Unlike traditional models whose performance degrades significantly with reduced training data, PonziSleuth maintains high accuracy in a zero-shot setting.
  • Real-World Efficacy: In a live test, the system successfully identified 15 previously unknown Ponzi schemes with a 0% false negative rate.

Discussion and Future Work

The success of PonziSleuth highlights the power of semantic reasoning over syntactic pattern matching. By focusing on the intent of the code—specifically how money moves between participants—LLMs can identify fraudulent logic that might evade traditional classifiers.

However, limitations remain. The current implementation requires Solidity source code, whereas many malicious contracts are only available as bytecode. Additionally, the system occasionally conflates Ponzi schemes with "honeypots," as both involve deceptive fund flows. Future research will explore multi-agent LLM architectures and the extension of this framework to bytecode analysis and other smart contract vulnerabilities.

Summary updated

BibTeX
@inproceedings{wu2024semantic,
  author = {Cong Wu and Jing Chen and Ziwei Wang and Ruichao Liang and Ruiying Du},
  title = {{Semantic Sleuth: Identifying Ponzi Contracts via Large Language Models}},
  booktitle = {ASE},
  year = {2024},
  doi = {10.1145/3691620.3695055},
}

Loading related content...

Figure