Abstract
Testing Database Management Systems (DBMSs) is notoriously difficult due to the strict syntactic and semantic requirements of SQL. Traditional fuzzers often fail to penetrate the initial parsing and validation layers. This paper introduces SQUIRREL, a novel fuzzing framework that combines the structural awareness of grammar-based generation with the path-finding efficiency of coverage-guided mutation. By utilizing a custom intermediate representation (IR) and enforcing semantic dependencies, SQUIRREL effectively explores deep code paths, uncovering 63 unique bugs in major databases like SQLite and MySQL.
Introduction
Modern DBMSs act like high-security vaults protected by two strict "gatekeepers": the syntactic check (grammar) and the semantic check (logical consistency). Traditional mutation-based fuzzers (e.g., AFL) typically generate syntactically invalid strings that are rejected immediately. Conversely, generation-based tools (e.g., SQLsmith) produce valid SQL but lack feedback mechanisms to guide exploration toward interesting code paths.
SQUIRREL bridges this gap by maintaining language validity while leveraging code coverage to hunt for deep-seated memory errors and logic bugs.
Methodology
SQUIRREL employs a multi-stage pipeline to transform seed SQL queries into complex, bug-triggering test cases.
Intermediate Representation (IR)
Instead of mutating raw text, SQUIRREL lifts SQL into a structural IR using a Static Single Assignment (SSA) form. This representation facilitates tracking data flow and structural modifications without breaking the underlying logic.
Syntax-Preserving Mutation
The fuzzer separates the query's structure from its data. It performs mutations—such as insertion, deletion, or replacement—on the IR "skeleton" using a library of known-valid structures. This ensures the resulting query almost always passes the initial syntactic gatekeeper.
Semantics-Guided Instantiation
To pass semantic validation, SQUIRREL builds a Data Dependency Graph. It uses predefined rules, such as the "lifetime principle," to ensure that database objects (like tables or columns) are correctly defined before use. This approach achieves up to 243.9x higher semantic correctness than state-of-the-art tools.
Evaluation
The researchers evaluated SQUIRREL on four popular open-source DBMSs: SQLite, MySQL, PostgreSQL, and MariaDB. The initial seeds were drawn from the official unit tests of each project.
Key Results
- Bug Discovery: SQUIRREL identified 63 unique bugs, resulting in 52 fixes and 12 assigned CVEs. Notably, it discovered an 11-year-old SQLite vulnerability in just 14 minutes.
- Code Coverage: The tool explored 2.0x to 10.9x more new code edges than traditional mutation-based tools like AFL or Angora.
- Efficiency: SQUIRREL found 9 unique bugs in a 24-hour window where SQLsmith found none, proving the value of coverage-guided exploration.
Conclusion
SQUIRREL demonstrates that semantic awareness is critical for effective DBMS fuzzing. By ensuring queries are both syntactically and semantically valid, the fuzzer can bypass superficial validation layers and uncover deep-seated vulnerabilities. Future work includes automating semantic rule inference and improving coverage tracking in massive codebases.
Summary updated