[Paper Review] White-Box and Black-Box Fuzzing for GraphQL APIs
This paper presents a novel framework for automated testing of GraphQL APIs using both white-box and black-box fuzzing. It integrates evolutionary algorithms for white-box testing to maximize code coverage and fault detection, and random search for black-box testing, demonstrating significant improvements in test effectiveness on 7 open-source and 31 online GraphQL APIs using the EvoMaster tool.
The Graph Query Language (GraphQL) is a powerful language for APIs manipulation in web services. It has been recently introduced as an alternative solution for addressing the limitations of RESTful APIs. This paper introduces an automated solution for GraphQL APIs testing. We present a full framework for automated APIs testing, from the schema extraction to test case generation. In addition, we consider two kinds of testing: white-box and black-box testing. The white-box testing is performed when the source code of the GraphQL API is available. Our approach is based on evolutionary search. Test cases are evolved to intelligently explore the solution space while maximizing code coverage and fault-finding criteria. The black-box testing does not require access to the source code of the GraphQL API. It is therefore of more general applicability, albeit it has worse performance. In this context, we use a random search to generate GraphQL data. The proposed framework is implemented and integrated into the open-source EvoMaster tool. With enabled white-box heuristics, i.e., white-box mode, experiments on 7 open-source GraphQL APIs show statistically significant improvement of the evolutionary approach compared to the baseline random search. In addition, experiments on 31 online GraphQL APIs reveal the ability of the black-box mode to detect real faults.
Motivation & Objective
- To address the lack of automated testing solutions for GraphQL APIs, especially in white-box and black-box contexts.
- To develop a full-stack framework that extracts schemas and generates executable test cases in JUnit and Jest formats.
- To evaluate the effectiveness of evolutionary algorithms in white-box testing and random search in black-box testing for GraphQL APIs.
- To validate the framework on real-world open-source and online GraphQL APIs for fault detection and coverage improvement.
- To extend the EvoMaster tool with GraphQL-specific test generation capabilities for both source-accessible and remote APIs.
Proposed method
- The framework extracts GraphQL schemas and models them as testable structures using genetic representation with multiple gene types.
- For white-box testing, an evolutionary algorithm uses internal and structure mutation operators to evolve test cases that maximize code coverage and fault detection.
- For black-box testing, random search generates valid GraphQL queries based solely on the schema, without source code access.
- The approach is implemented as an extension to the open-source EvoMaster tool, supporting test output in JUnit and Jest formats.
- The framework supports complex schema features such as nested function calls and recursive data structures.
- Statistical analysis and 30 repeated runs with different random seeds ensure robustness of results in white-box evaluation.
Experimental results
Research questions
- RQ1Can evolutionary search outperform random search in white-box testing of GraphQL APIs in terms of code coverage and fault detection?
- RQ2Can black-box random testing effectively discover real faults in production-grade GraphQL APIs without source code access?
- RQ3How does the proposed framework scale across diverse GraphQL API implementations, including open-source and online services?
- RQ4What is the impact of schema decomposition and genetic operators on test case generation quality in GraphQL testing?
- RQ5To what extent can the EvoMaster framework be extended to support both white-box and black-box testing for GraphQL APIs?
Key findings
- In white-box testing, the evolutionary approach improved average line coverage by 6% (up to 26.9%) compared to random search across 7 open-source APIs.
- The white-box mode detected 77 additional faults across the 7 tested APIs, demonstrating superior fault-finding capability.
- In black-box testing, the random search approach detected errors in up to 641 out of 825 endpoints across 31 online GraphQL APIs.
- The framework successfully generated executable test suites in JUnit and Jest formats, enabling integration into CI/CD pipelines.
- The results were statistically significant, with 30 repeated runs per API to ensure reliability and reduce variance from random initialization.
- The framework is publicly available as an extension to EvoMaster, with all experimental scripts and datasets hosted on GitHub and Zenodo for reproducibility.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.