Abstract
JavaScript (JS) is a popular, platform-independent programming language. To ensure the interoperability of JS programs across different platforms, the implementation of a JS engine should conform to the ECMAScript standard. However, doing so is challenging as there are many subtle definitions of API behaviors, and the definitions keep evolving. We present COMFORT, a new compiler fuzzing framework for detecting JS engine bugs and behaviors that deviate from the ECMAScript standard. COMFORT leverages the recent advance in deep learning-based language models to automatically generate JS test code. As a departure from prior fuzzers, COMFORT utilizes the well-structured ECMAScript specifications to automatically generate test data along with the test programs to expose bugs that could be overlooked by the developers or manually written test cases. COMFORT then applies differential testing methodologies on the generated test cases to expose standard conformance bugs. We apply COMFORT to ten mainstream JS engines. In 200 hours of automated concurrent testing runs, we discover bugs in all tested JS engines. We had identified 158 unique JS engine bugs, of which 129 have been verified, and 115 have already been fixed by the developers. Furthermore, 21 of the Comfort-generated test cases have been added to Test262, the official ECMAScript conformance test suite.
Introduction
The JavaScript ecosystem relies on the ECMA-262 specification to ensure interoperability across diverse environments. However, modern JS engines—such as Google’s V8, Apple’s JavaScriptCore, and Mozilla’s SpiderMonkey—are immensely complex. This complexity, combined with the evolving nature of the ECMAScript standard, leads to "conformance bugs": logic errors where an engine executes code without crashing but produces results that deviate from the standard. Such bugs are difficult to detect using traditional fuzzing techniques, which typically focus on memory safety or crashes.
Methodology: The COMFORT Framework
COMFORT addresses these challenges by combining deep learning-based program generation with specification-guided data generation. The framework operates through a multi-stage pipeline designed to maximize both syntactic validity and semantic depth.
The process begins with Spec Extraction, where a custom parser scrapes the ECMA-262 specification to extract boundary conditions and pseudo-code rules for over 750 APIs. Simultaneously, a Deep Program Generation module uses a fine-tuned GPT-2 model to generate syntactically valid JS code. Unlike older RNN-based models, the Transformer architecture allows COMFORT to maintain long-range dependencies, achieving an 80% syntax validity rate.
The "secret sauce" of COMFORT is Spec-Guided Data Generation. The framework identifies API calls within generated programs and injects specific boundary values (e.g., NaN, undefined, or negative indices) derived from the spec database. Finally, Differential Testing is applied across multiple engines using a majority voting scheme to identify outliers, followed by a tree-based filter to group similar behaviors and reduce redundant bug reports.
Evaluation and Results
COMFORT was evaluated using 300,000 synthetic test cases generated from a training set of 140,000 GitHub-sourced JS programs. The framework was tested against ten mainstream engines, ranging from high-performance browser engines to lightweight embedded systems like JerryScript and Hermes.
In 200 hours of testing, COMFORT identified 158 unique bugs. As shown in the results table, 129 of these were verified by developers, and 115 have already been fixed. Notably, 21 generated test cases were integrated into Test262, the official industry-standard conformance suite. The efficiency of COMFORT was also marked: it found over twice as many unique bugs as other state-of-the-art fuzzers like Fuzzilli and Montage in head-to-head comparisons.
Key Insights
- Transformers for Fuzzing: Moving to GPT-2 significantly improved the quality of generated code, providing a 2.6x improvement in syntax validity over previous deep-learning fuzzers.
- Specification Guidance: Random input generation is inefficient for weakly-typed languages. Using the formal specification to narrow the search space to known edge cases allows the fuzzer to hit buggy logic paths much faster.
- Regression and Evolution: Many bugs were found in engines transitioning to newer versions of the ECMAScript spec (e.g., moving from ES5 to ES6), suggesting that conformance logic often remains latent until targeted by sophisticated tools.
Limitations and Future Work
While effective, COMFORT has limitations. Its spec parser currently struggles with rules described purely in natural language prose rather than pseudo-code. Additionally, it does not yet handle non-deterministic behaviors like floating-point rounding errors. Future research will focus on improving natural language rule extraction and expanding the framework to other languages like WebAssembly and C.
Conclusion
COMFORT demonstrates that combining large language models with formal specifications can significantly enhance the detection of subtle logic errors in complex software like JS engines. By bridging the gap between "creative" program generation and "rigorous" spec adherence, COMFORT has made a tangible impact on the reliability of the JavaScript ecosystem.
Summary updated