Skip to main content
QUICK REVIEW

[Paper Review] Large Language Models are Zero-Shot Fuzzers: Fuzzing Deep-Learning Libraries via Large Language Models

Yinlin Deng, Chunqiu Steven Xia|arXiv (Cornell University)|Dec 30, 2022
Software Testing and Debugging TechniquesComputer Science13 citations
TL;DR

TitanFuzz is the first framework that leverages large language models (LLMs) as zero-shot fuzzers to automatically generate diverse, valid deep learning programs for testing TensorFlow and PyTorch libraries. By combining generative and infilling LLMs (e.g., Codex and InCoder) for seed generation and evolutionary mutation, TitanFuzz achieves 30.38% and 50.84% higher code coverage than state-of-the-art fuzzers on TensorFlow and PyTorch, respectively, and uncovers 65 bugs, 41 of which are previously unknown.

ABSTRACT

Detecting bugs in Deep Learning (DL) libraries (e.g., TensorFlow/PyTorch) is critical for almost all downstream DL systems in ensuring effectiveness/safety for end users. Meanwhile, traditional fuzzing techniques can be hardly effective for such a challenging domain since the input DL programs need to satisfy both the input language (e.g., Python) syntax/semantics and the DL API input/shape constraints for tensor computations. To address these limitations, we propose TitanFuzz - the first approach to directly leveraging Large Language Models (LLMs) to generate input programs for fuzzing DL libraries. LLMs are titanic models trained on billions of code snippets and can auto-regressively generate human-like code snippets. Our key insight is that modern LLMs can also include numerous code snippets invoking DL library APIs in their training corpora, and thus can implicitly learn both language syntax/semantics and intricate DL API constraints for valid DL program generation. More specifically, we use both generative and infilling LLMs (e.g., Codex/InCoder) to generate and mutate valid/diverse input DL programs for fuzzing. Our experimental results demonstrate that TitanFuzz can achieve 30.38%/50.84% higher code coverage than state-of-the-art fuzzers on TensorFlow/PyTorch. Furthermore, TitanFuzz is able to detect 65 bugs, with 41 already confirmed as previously unknown bugs. This paper demonstrates that modern titanic LLMs can be leveraged to directly perform both generation-based and mutation-based fuzzing studied for decades, while being fully automated, generalizable, and applicable to domains challenging for traditional approaches (such as DL systems). We hope TitanFuzz can stimulate more work in this promising direction of LLMs for fuzzing.

Motivation & Objective

  • To address the limitations of traditional fuzzing in deep learning libraries, where input programs must satisfy complex syntax, semantics, and tensor shape constraints.
  • To overcome the lack of diversity in API sequences and inability to generate arbitrary valid code in prior API-level and model-level fuzzers.
  • To explore whether modern large language models (LLMs) can directly serve as zero-shot fuzzers for deep learning libraries by leveraging their training on billions of code snippets.
  • To develop a fully automated, generalizable, and effective fuzzing framework that generates and mutates valid DL programs using LLMs.

Proposed method

  • Using a generative LLM (e.g., Codex) with prompt engineering to produce high-quality seed programs that are syntactically correct and semantically valid for DL libraries.
  • Employing an infilling LLM (e.g., InCoder) to perform evolutionary mutation on seed programs by inserting, replacing, or deleting code segments within the program.
  • Applying a differential testing oracle that compares outputs on CPU and GPU to detect inconsistencies indicating potential bugs.
  • Using a feedback-driven evolutionary algorithm to guide mutation toward higher code coverage and increased bug detection.
  • Validating generated programs via execution and monitoring for crashes, runtime errors, or semantic inconsistencies across hardware backends.

Experimental results

Research questions

  • RQ1Can large language models be effectively used as zero-shot fuzzers for deep learning libraries without task-specific training or seed databases?
  • RQ2How effective is LLM-based generation and mutation in achieving higher code coverage compared to state-of-the-art API-level and model-level fuzzers?
  • RQ3Can LLM-based fuzzing discover previously unknown bugs that traditional fuzzers miss, especially in rare or complex API sequences?
  • RQ4To what extent can LLMs generate valid, diverse, and complex DL programs that include Python-specific constructs like loops and control flow?
  • RQ5What is the impact of prompt engineering and model choice (e.g., Codex vs. InCoder) on the quality and diversity of generated test programs?

Key findings

  • TitanFuzz achieves 30.38% higher code coverage on TensorFlow and 50.84% higher coverage on PyTorch compared to state-of-the-art fuzzers.
  • The framework detects 65 unique bugs across PyTorch and TensorFlow, with 53 confirmed and 41 of them previously unknown.
  • Ten of the confirmed bugs were discovered directly from LLM-generated seeds without any mutation, demonstrating the high quality of initial program generation.
  • TitanFuzz successfully detects a GPU-specific synchronization bug in PyTorch that only triggers under a specific API sequence (log followed by matrix_exp), which prior tools missed.
  • The framework uncovers a critical security vulnerability in TensorFlow’s ParallelDynamicStitch API due to silent out-of-bound reads, which was missed by previous fuzzers due to low API popularity and lack of seed coverage.
  • One detected inconsistency was rejected by developers as intentional, due to differing low-level shift operators on CPU and GPU, highlighting the need for careful oracle design.

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.