mlsanityData to 14 Oct 2026

Leveraging GPT-4 for Vulnerability-Witnessing Unit Test Generation

arXiv 2506.11559 ↗First posted 13 Jun 2025cs.SE cs.AIcited by 0

Not on the map. Why?

Abstract (arXiv)

In the life-cycle of software development, testing plays a crucial role in quality assurance. Proper testing not only increases code coverage and prevents regressions but it can also ensure that any potential vulnerabilities in the software are identified and effectively fixed. However, creating such tests is a complex, resource-consuming manual process. To help developers and security experts, this paper explores the automatic unit test generation capability of one of the most widely used large language models, GPT-4, from the perspective of vulnerabilities. We examine a subset of the VUL4J dataset containing real vulnerabilities and their corresponding fixes to determine whether GPT-4 can generate syntactically and/or semantically correct unit tests based on the code before and after the fixes as evidence of vulnerability mitigation. We focus on the impact of code contexts, the effectiveness of GPT-4's self-correction ability, and the subjective usability of the generated test cases. Our results indicate that GPT-4 can generate syntactically correct test cases 66.5% of the time without domain-specific pre-training. Although the semantic correctness of the fixes could be automatically validated in only 7. 5% of the cases, our subjective evaluation shows that GPT-4 generally produces test templates that can be further developed into fully functional vulnerability-witnessing tests with relatively minimal manual effort. Therefore, despite the limited data, our initial findings suggest that GPT-4 can be effectively used in the generation of vulnerability-witnessing tests. It may not operate entirely autonomously, but it certainly plays a significant role in a partially automated process.

Key facts. No citing papers in the map yet (data through 14 Oct 2026). Builds on 10 of its 27 references that are in the map. First posted on arXiv 13 Jun 2025.

Builds on

10 of 27 references.

References · 10

  1. 2023Software Testing with Large Language Models: Survey, Landscape, and Visioncited by 166
  2. 2022Practical Program Repair in the Era of Large Pre-trained Language Modelscited by 133
  3. 2020Unit Test Case Generation with Transformers and Focal Contextcited by 118
  4. 2022Large Language Models are Few-shot Testers: Exploring LLM-based General Bug Reproductioncited by 111
  5. 2024Automated Unit Test Improvement using Large Language Models at Metacited by 75
  6. 2024Large Language Model for Vulnerability Detection: Emerging Results and Future Directionscited by 45
  7. 2023ChatGPT for Vulnerability Detection, Classification, and Repair: How Far Are We?cited by 44
  8. 2024Hybrid Automated Program Repair by Combining Large Language Models and Program Analysiscited by 22
  9. 2023Pre-trained Model-based Automated Software Vulnerability Repair: How Far are We?cited by 16
  10. 2023Exploiting Library Vulnerability via Migration Based Automating Test Generationcited by 3

Built on by

Not cited yet.