Skip to main content
QUICK REVIEW

[Paper Review] LLM4Fuzz: Guided Fuzzing of Smart Contracts with Large Language Models

Chaofan Shou, Jing Liu|arXiv (Cornell University)|Jan 20, 2024
Advanced Malware Detection TechniquesComputer Science7 citations
TL;DR

Llm4Fuzz uses large language models to guide and prioritize fuzzing of Ethereum smart contracts, improving test coverage and vulnerability detection over baselines, and uncovering critical vulnerabilities in real-world projects.

ABSTRACT

As blockchain platforms grow exponentially, millions of lines of smart contract code are being deployed to manage extensive digital assets. However, vulnerabilities in this mission-critical code have led to significant exploitations and asset losses. Thorough automated security analysis of smart contracts is thus imperative. This paper introduces LLM4Fuzz to optimize automated smart contract security analysis by leveraging large language models (LLMs) to intelligently guide and prioritize fuzzing campaigns. While traditional fuzzing suffers from low efficiency in exploring the vast state space, LLM4Fuzz employs LLMs to direct fuzzers towards high-value code regions and input sequences more likely to trigger vulnerabilities. Additionally, LLM4Fuzz can leverage LLMs to guide fuzzers based on user-defined invariants, reducing blind exploration overhead. Evaluations of LLM4Fuzz on real-world DeFi projects show substantial gains in efficiency, coverage, and vulnerability detection compared to baseline fuzzing. LLM4Fuzz also uncovered five critical vulnerabilities that can lead to a loss of more than $247k.

Motivation & Objective

  • Motivate automated security analysis of smart contracts due to growing codebases and asset value.
  • Develop a fuzzing framework that leverages LLM-derived metrics to prioritize exploration of high-value code regions and input sequences.
  • Integrate static analysis, AST-based representations, and LLM prompts to produce per-function and per-block metrics guiding fuzzing.
  • Demonstrate efficiency gains and vulnerability discovery on real-world DeFi projects compared to state-of-the-art fuzzers.

Proposed method

  • Convert each smart contract to an AST and perform static analysis to gather context (complexity, dependencies, external calls, control flow).
  • Generate function-level prompts containing related functions, dependencies, and static analysis results to obtain LLM-derived metrics.
  • Define four producers (complexity, sequential likelihood, vulnerability likelihood, invariant dependencies) that produce energy scores for fuzzing test cases from LLM outputs.
  • Compute and apply a hierarchical representation (source, CFG, data dependencies, metrics) to guide fuzzing via energy-based scheduling.
  • Use power scheduling with energies derived from LLM-produced metrics to prioritize promising test cases.
  • Evaluate on real-world contracts using a baseline fuzzing tool (ItyFuzz) and analyze instruction coverage and vulnerability discovery.
Figure 1: Workflow of Llm4Fuzz
Figure 1: Workflow of Llm4Fuzz

Experimental results

Research questions

  • RQ1RQ1: Can Llm4Fuzz achieve higher instruction coverage on real-world projects than the baseline?
  • RQ2RQ2: Can Llm4Fuzz find more vulnerabilities and uncover new ones in real-world projects?
  • RQ3RQ3: Can Llm4Fuzz make invariant testing more efficient than existing property testing tools?
  • RQ4RQ4: Do different LLM producers provide unique and useful insights for guiding fuzzing?

Key findings

  • Llm4Fuzz achieved higher instruction coverage (1.6M instructions) across 117 projects versus the baseline (1.1M).
  • On a subset of 12 projects, Llm4Fuzz’s performance exceeded the baseline by more than twofold for certain contracts (e.g., Bitpaidio and Sheep).
  • Across 600 live on-chain contracts, Llm4Fuzz identified five critical vulnerabilities leading to potential losses over $247k.
  • LLMs provided meaningful metrics (complexity, vulnerability likelihood, invariant dependencies, and sequential interestingness) that effectively guided fuzzing priorities.
  • The authors implemented Llm4Fuzz on top of ItyFuzz with 244 lines of Rust and used Llama 2 70B for LLM queries, averaging three prompts per decision.
Figure 2: Total Instruction Coverage Over Time for Onchain Projects
Figure 2: Total Instruction Coverage Over Time for Onchain Projects

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.