Towards Generic Database Management System Fuzzing

Yupeng Yang, Yongheng Chen, Rui Zhong, Jizhou Chen, Wenke LeeUSENIX Security 2024

TL;DR

Database Management Systems (DBMSs) are critical, but existing fuzzing tools struggle to test the diverse interfaces of non-relational DBMSs. This paper introduces BUZZBEE, a novel fuzzing framework that addresses this by abstracting DBMS semantics, enabling context-aware constraint resolution, and employing dependency-guided mutation, leading to significantly improved bug detection and code coverage.

What Problem Does This Paper Address?

Database Management Systems (DBMSs) are the backbone of modern data infrastructure, handling everything from financial transactions to user data. While relational (SQL) DBMSs have been extensively tested using various fuzzing techniques, non-relational (NoSQL) DBMSs (like key-value, document, and graph databases) have lagged behind in security scrutiny. This gap exists because:

  1. Diverse Interfaces: NoSQL DBMSs have vastly different ways of accepting input (e.g., command sequences, JSON, graph patterns), making it hard to create a single fuzzer that works for all.
  2. Context-Dependent Semantics: The meaning of commands or data can change based on the surrounding context, which simple fuzzers often miss. For example, a variable might be defined in one part of a query but used in another, and understanding this relationship is crucial.
  3. Loose Data Dependencies: Randomly generated inputs often fail to create meaningful data dependencies, leading to ineffective testing that doesn't reach deep into the DBMS logic.

These challenges mean that generic fuzzers struggle to generate semantically correct and effective test cases for the wide array of DBMS interfaces, leaving many vulnerabilities undiscovered.

Methods

BUZZBEE tackles these challenges with three core innovations:

  • Semantics Abstraction: Instead of dealing with the specific syntax of each DBMS, BUZZBEE abstracts operations into three fundamental actions: Define (create data), Use (access/modify data), and Invalidate (delete data). This allows for a unified way to represent and reason about DBMS behavior across different types.
  • Context-Sensitive Constraint Resolution: To overcome the limitations of static constraints, BUZZBEE uses an annotation system that allows users to define semantic rules. These rules can dynamically adapt based on the context of the input (e.g., where a node appears in the Abstract Syntax Tree). This is achieved through a lightweight query language (CQL) and custom resolvers for complex logic.
  • Dependency-Guided Mutation: Instead of random mutations, BUZZBEE prioritizes mutations that create or leverage data dependencies. This means it favors generating test cases where new commands logically follow from or interact with previously defined data, leading to more effective exploration of the DBMS's internal logic.

BUZZBEE integrates these solutions into an end-to-end fuzzing framework. It first "lifts" the input into an intermediate representation (IR), performs semantic analysis and mutation guided by the defined constraints and dependencies, validates the semantics, and then compiles the mutated IR back into a test case for the DBMS.

Datasets

The paper evaluates BUZZBEE on eight real-world DBMSs across four data models:

  • Key-Value: redis, KeyDB
  • Document: MongoDB, ArangoDB
  • Graph: RedisGraph, AgensGraph
  • Relational (SQL): PostgreSQL, MySQL

The authors collected grammars and test suites from public sources (documentation, GitHub) and manually created annotations for each DBMS. No new benchmark datasets were introduced; instead, existing DBMSs and their typical interfaces were used for evaluation.

Key Insights and Ideas

  • The "Generic" Challenge is Real: The diversity of NoSQL interfaces is a significant hurdle for fuzzing, and existing tools often fail to generalize effectively.
  • Semantics Matter, Context Even More: Simply checking syntax isn't enough. Understanding how operations relate to each other and how their meaning changes based on context is crucial for effective DBMS fuzzing.
  • Data Dependencies are Key to Depth: Random mutations are inefficient because they often produce inputs that don't interact meaningfully with the database state. Guiding mutations to create data dependencies unlocks deeper logic and more bugs.
  • Abstraction is Powerful: By abstracting DBMS operations to "Define, Use, Invalidate," BUZZBEE achieves a level of generality that allows it to tackle diverse systems with a unified approach.

Key Results

  • Bug Discovery: BUZZBEE discovered 40 vulnerabilities in the eight tested DBMSs. Of these, 38 were confirmed by vendors, 25 have been fixed, and 4 new CVEs were assigned.
  • Code Coverage: BUZZBEE achieved up to 177% higher code coverage compared to state-of-the-art generic fuzzers.
  • Efficiency: It found 30x more bugs than the second-best generic fuzzer for non-relational DBMSs.
  • Generalizability: The adoption effort for new DBMSs was minimal, requiring an average of only 123 lines of annotation.
  • Semantic Correctness: BUZZBEE significantly improved semantic correctness rates (up to 626x higher than variants) by enforcing its semantic model.

Limitations and Future Work

  • Semantic Completeness: BUZZBEE does not claim to model all semantics of a DBMS perfectly, but rather focuses on the "basic but vital" ones that impact fuzzing performance. It achieved high semantic correctness rates but not 100% across all targets.
  • PostgreSQL Fuzzing: BUZZBEE, like other fuzzers tested, struggled to find bugs in the latest version of PostgreSQL. However, it did find a known bug in a legacy version.
  • Future Work: The authors suggest introducing a new mode to BUZZBEE that automatically modifies certain annotations to find bugs related to violations of data dependency rules (e.g., use-after-invalidate). They also note that BUZZBEE could benefit from advancements in feedback mechanisms used by other fuzzers.

Summary updated

BibTeX
@inproceedings{yang2024towards,
  author = {Yupeng Yang and Yongheng Chen and Rui Zhong and Jizhou Chen and Wenke Lee},
  title = {{Towards Generic Database Management System Fuzzing}},
  booktitle = {USENIX Security},
  year = {2024},
  url = {https://openreview.net/forum?id=bcXTFkrJLs},
}
Figure