Introduction
Testing software that parses highly structured data, such as JavaScript engines or SQL databases, is notoriously difficult. Traditional concolic execution—combining concrete execution with symbolic analysis—often fails due to structure-agnostic path selection, a "syntactic validity" gap where solvers produce gibberish, and seed saturation. This paper presents COTTONTAIL, a novel engine that integrates Large Language Models (LLMs) to bridge the gap between symbolic logic and linguistic structure.
Methodology
COTTONTAIL introduces three core components to enhance the testing process:
- Expressive Coverage Tree (ECT): Instead of raw binary bitmaps, COTTONTAIL builds a tree based on source-code locations and branch types, allowing it to prioritize "interesting" paths.
- Solve-Complete Paradigm: This two-step prompting strategy enables the LLM to act as a semantic solver. It first solves a specific Constraint Mask to satisfy symbolic logic and then completes the rest of the input using a Flexible Mask to ensure syntactic validity.
- History-Guided Seed Acquisition: To overcome plateaus, the engine feeds the LLM historical coverage data, prompting it to "dream up" new, valid seeds that target unexplored features.
To maintain robustness, a Test Case Validator ensures that LLM outputs satisfy required path constraints, falling back to traditional solvers like Z3 to "fix" specific bytes while preserving the LLM's structural improvements.
Evaluation and Results
The researchers evaluated COTTONTAIL against eight open-source libraries across XML, SQL, JavaScript, and JSON formats. COTTONTAIL significantly outperformed baselines like SYMCC and MARCO, achieving an average increase of 30.73% in line coverage and 41.32% in branch coverage.
A key metric was the "validity explosion" — the rate at which generated test cases passed initial parser checks. As shown in the figure below, the LLM-driven solver dramatically improved the generation of useful test cases compared to traditional SMT solvers.
Beyond coverage metrics, COTTONTAIL discovered six previously unknown vulnerabilities (all assigned CVEs) in MuJS, QuickJS, and UnQLite, including heap overflows and memory leaks. The system proved cost-effective, with an average operational cost of $0.78 per hour using gpt-4o-mini.
Conclusion and Future Work
COTTONTAIL demonstrates that LLMs can effectively serve as semantic solvers for complex software testing. While current limitations include the requirement for source code and potential scalability issues for massive systems, the engine's ability to generate syntactically valid and semantically rich inputs marks a significant step forward in automated vulnerability discovery. Future work will explore black-box testing and the automated generation of fuzzing drivers.
Summary updated