Chain-of-Thought Prompting of Large Language Models for Discovering and Fixing Software Vulnerabilities
<|reference_start|>Chain-of-Thought Prompting of Large Language Models for Discovering and Fixing Software Vulnerabilities: Security vulnerabilities are increasingly prevalent in modern software and they are widely consequential to our society. Various approaches to defending against these vulnerabilities have been proposed, among which those leveraging deep learning (DL) avoid major barriers with other techniques hence attracting more attention in recent years. However, DL-based approaches face critical challenges including the lack of sizable and quality-labeled task-specific datasets and their inability to generalize well to unseen, real-world scenarios. Lately, large language models (LLMs) have demonstrated impressive potential in various domains by overcoming those challenges, especially through chain-of-thought (CoT) prompting. In this paper, we explore how to leverage LLMs and CoT to address three key software vulnerability analysis tasks: identifying a given type of vulnerabilities, discovering vulnerabilities of any type, and patching detected vulnerabilities. We instantiate the general CoT methodology in the context of these tasks through VSP , our unified, vulnerability-semantics-guided prompting approach, and conduct extensive experiments assessing VSP versus five baselines for the three tasks against three LLMs and two datasets. Results show substantial superiority of our CoT-inspired prompting (553.3%, 36.5%, and 30.8% higher F1 accuracy for vulnerability identification, discovery, and patching, respectively, on CVE datasets) over the baselines. Through in-depth case studies analyzing VSP failures, we also reveal current gaps in LLM/CoT for challenging vulnerability cases, while proposing and validating respective improvements.<|reference_end|>
@article{nong2024chain-of-thought,
    title={Chain-of-Thought Prompting of Large Language Models for Discovering and
  Fixing Software Vulnerabilities},
    author={Yu Nong, Mohammed Aldeen, Long Cheng, Hongxin Hu, Feng Chen, and
  Haipeng Cai},
    journal={arXiv preprint arXiv:2402.17230},
    year={2024},
    archivePrefix={arXiv},
    eprint={2402.17230},
    primaryClass={cs.CR}
}