[Paper Review] LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarks
This paper evaluates the ability of state-of-the-art large language models (LLMs) to detect and reason about software security vulnerabilities using a novel, fully automated framework. Despite their advanced capabilities, LLMs show high false positive rates, non-deterministic outputs, unfaithful reasoning, and poor robustness—especially when faced with minor code changes—demonstrating they are not yet reliable for real-world vulnerability detection.
Large Language Models (LLMs) have been suggested for use in automated vulnerability repair, but benchmarks showing they can consistently identify security-related bugs are lacking. We thus develop SecLLMHolmes, a fully automated evaluation framework that performs the most detailed investigation to date on whether LLMs can reliably identify and reason about security-related bugs. We construct a set of 228 code scenarios and analyze eight of the most capable LLMs across eight different investigative dimensions using our framework. Our evaluation shows LLMs provide non-deterministic responses, incorrect and unfaithful reasoning, and perform poorly in real-world scenarios. Most importantly, our findings reveal significant non-robustness in even the most advanced models like `PaLM2' and `GPT-4': by merely changing function or variable names, or by the addition of library functions in the source code, these models can yield incorrect answers in 26% and 17% of cases, respectively. These findings demonstrate that further LLM advances are needed before LLMs can be used as general purpose security assistants.
Motivation & Objective
- To investigate whether current LLMs can reliably identify and reason about software security vulnerabilities in real-world code.
- To address the lack of standardized, automated benchmarks for evaluating LLMs in vulnerability detection tasks.
- To identify critical shortcomings in LLM behavior, such as non-determinism, unfaithful reasoning, and sensitivity to code perturbations.
- To provide a publicly available, scalable evaluation framework for future LLM development in cybersecurity.
- To establish a benchmark that enables systematic tracking of progress in LLMs' vulnerability detection capabilities.
Proposed method
- Developed a fully automated, scalable evaluation framework to test LLMs across eight distinct dimensions: determinism, parameter sensitivity, prompt diversity, reasoning faithfulness, vulnerability variety, code difficulty, robustness to code augmentations, and real-world applicability.
- Constructed 228 code scenarios covering eight critical vulnerabilities (e.g., buffer overflows, injection flaws) in C and Python, with ground-truth labels for each.
- Applied 17 distinct prompting techniques—including zero-shot, few-shot, and role-oriented prompts—across eight state-of-the-art LLMs (e.g., GPT-4, PaLM2, CodeLlama).
- Used GPT-4 to extract and validate answers and reasoning from LLM outputs, ensuring structured parsing for consistency and accuracy.
- Employed a multi-metric reasoning evaluation combining ROUGE, cosine similarity, and GPT-4 judgment to assess reasoning quality and reduce false positives.
- Evaluated models on real-world CVEs beyond their knowledge cutoff date to test generalization and robustness.
Experimental results
Research questions
- RQ1Can LLMs consistently and reliably identify security vulnerabilities in source code across diverse programming scenarios?
- RQ2How robust are LLMs to minor code modifications such as renaming functions, adding library imports, or changing whitespace?
- RQ3To what extent do LLMs provide faithful, logical reasoning when identifying vulnerabilities, and how often is this reasoning incorrect or hallucinated?
- RQ4How do different prompting strategies (e.g., zero-shot vs. few-shot, role-oriented) affect LLM performance in vulnerability detection?
- RQ5Can LLMs generalize to real-world vulnerabilities not seen during training, especially those released after their knowledge cutoff?
Key findings
- LLMs exhibit high false positive rates, flagging patched code as vulnerable in 26% of cases, indicating poor reliability for production use.
- Even top-tier models like PaLM2 and GPT-4 show non-deterministic behavior, changing answers across multiple runs for the same input.
- LLMs frequently provide unfaithful reasoning: when they correctly identify a vulnerability, the justification is often incorrect or logically flawed.
- Chain-of-thought reasoning is fragile—simple code augmentations like function name changes or library imports cause incorrect outputs in 26% and 17% of cases, respectively.
- LLMs fail to generalize to real-world CVEs released after their knowledge cutoff date, producing incorrect answers for several test cases.
- The zero-shot role-oriented prompt 'R2' yields the best performance among prompting strategies, but remains insufficient for reliable deployment in practice.
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.