Do LLMs Consider Security? An Empirical Study on Responses to Programming Questions
Not on the map. Why?
Abstract (arXiv)
The widespread adoption of conversational LLMs for software development has raised new security concerns regarding the safety of LLM-generated content. Our motivational study outlines ChatGPT's potential in volunteering context-specific information to the developers, promoting safe coding practices. Motivated by this finding, we conduct a study to evaluate the degree of security awareness exhibited by three prominent LLMs: Claude 3, GPT-4, and Llama 3. We prompt these LLMs with Stack Overflow questions that contain vulnerable code to evaluate whether they merely provide answers to the questions or if they also warn users about the insecure code, thereby demonstrating a degree of security awareness. Further, we assess whether LLM responses provide information about the causes, exploits, and the potential fixes of the vulnerability, to help raise users' awareness. Our findings show that all three models struggle to accurately detect and warn users about vulnerabilities, achieving a detection rate of only 12.6% to 40% across our datasets. We also observe that the LLMs tend to identify certain types of vulnerabilities related to sensitive information exposure and improper input neutralization much more frequently than other types, such as those involving external control of file names or paths. Furthermore, when LLMs do issue security warnings, they often provide more information on the causes, exploits, and fixes of vulnerabilities compared to Stack Overflow responses. Finally, we provide an in-depth discussion on the implications of our findings and present a CLI-based prompting tool that can be used to generate significantly more secure LLM responses.
Key facts. Cited by 9 papers in the map (data through 14 Oct 2026). Builds on 35 of its 83 references that are in the map. First posted on arXiv 20 Feb 2025.
Builds on
35 of 83 references.
References · 35
- 2021Asleep at the Keyboard? Assessing the Security of GitHub Copilot's Code Contributionscited by 431
- 2023Large Language Models for Software Engineering: A Systematic Literature Reviewcited by 399
- 2023A Survey on Large Language Model (LLM) Security and Privacy: The Good, the Bad, and the Uglycited by 387
- 2023Using an LLM to Help With Code Understandingcited by 228
- 2022Do Users Write More Insecure Code with AI Assistants?cited by 192
- 2023LLM Lies: Hallucinations are not Bugs, but Features as Adversarial Examplescited by 177
- 2023InferFix: End-to-End Program Repair with LLMscited by 114
- 2023LLMs Cannot Reliably Identify and Reason About Security Vulnerabilities (Yet?): A Comprehensive Evaluation, Framework, and Benchmarkscited by 97
- 2023Getting pwn'd by AI: Penetration Testing with Large Language Modelscited by 83
- 2023How Secure is Code Generated by ChatGPT?cited by 81
- 2023Towards an Understanding of Large Language Models in Software Engineering Taskscited by 68
- 2022Is GitHub's Copilot as Bad as Humans at Introducing Vulnerabilities in Code?cited by 67
23 more
- 2022NatGen: Generative pre-training by "Naturalizing" source codecited by 54
- 2023Using Large Language Models to Generate JUnit Tests: An Empirical Studycited by 53
- 2024Large Language Model for Vulnerability Detection: Emerging Results and Future Directionscited by 45
- 2023Is Stack Overflow Obsolete? An Empirical Study of the Characteristics of ChatGPT Answers to Stack Overflow Questionscited by 42
- 2022Transformer-Based Language Models for Software Vulnerability Detectioncited by 39
- 2023Evaluation of ChatGPT Model for Vulnerability Detectioncited by 33
- 2023Can GPT-4 Support Analysis of Textual Data in Tasks Requiring Highly Specialized Domain Expertise?cited by 31
- 2023Decoding the Threat Landscape : ChatGPT, FraudGPT, and WormGPT in Social Engineering Attackscited by 23
- 2023How Can ChatGPT Support Human Security Testers to Help Mitigate Supply Chain Attacks?cited by 20
- 2023Can Large Language Models Find And Fix Vulnerable Software?cited by 15
- 2023DefectHunter: A Novel LLM-Driven Boosted-Conformer-based Code Vulnerability Detection Mechanismcited by 14
- 2017Stack Overflow Considered Harmful? The Impact of Copy&Paste on Android Application Securitycited by 12
- 2023DevGPT: Studying Developer-ChatGPT Conversationscited by 12
- 2024Are Large Language Models Memorizing Bug Benchmarks?cited by 12
- 2024Software Vulnerability and Functionality Assessment using LLMscited by 11
- 2023Conversational Challenges in AI-Powered Data Science: Obstacles, Needs, and Design Opportunitiescited by 9
- 2024An Empirical Study on Developers Shared Conversations with ChatGPT in GitHub Pull Requests and Issuescited by 9
- 2023Using ChatGPT as a Static Application Security Testing Toolcited by 8
- 2018Recommending Insightful Comments for Source Code using Crowdsourced Knowledgecited by 4
- 2023Evaluating Privacy Questions From Stack Overflow: Can ChatGPT Compete?cited by 2
- 2022Using clarification questions to improve software developers' Web searchcited by 1
- 2023Which is a better programming assistant? A comparative study between chatgpt and stack overflowcited by 1
- 2024Investigating the Utility of ChatGPT in the Issue Tracking System: An Exploratory Studycited by 1
Built on by
Citing papers per year: 2025: 4; 2026: 5.
9 papers.
- 2026Where Do AI Coding Agents Fail? An Empirical Study of Failed Agentic Pull Requests in GitHubcited by 13
- 2025LLMs' Reshaping of People, Processes, Products, and Society in Software Development: A Comprehensive Exploration with Early Adopterscited by 8
- 2026Are AI-assisted Development Tools Immune to Prompt Injection?cited by 4
- 2025Can LLMs Find Bugs in Code? An Evaluation from Beginner Errors to Security Vulnerabilities in Python and C++cited by 3
- 2025A Blueprint for AI-Driven Software Quality: Integrating LLMs with Established Standardscited by 1
- 2025HiLDe: Intentional Code Generation via Human-in-the-Loop Decodingcited by 1
- 2026Correct Code, Vulnerable Dependencies: A Large Scale Measurement Study of LLM-Specified Library Versionscited by 1
- 2026Understanding the Impact of AI Code Assistants on Security API Usage: An Empirical Studycited by 0
- 2026The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Repromptingcited by 0
- 2026The Illusion of Secure LLM Code: Closing the Security Gap via Iterative Reprompting26 Jul 2026
- 2026Understanding the Impact of AI Code Assistants on Security API Usage: An Empirical Study13 Jul 2026
- 2026Correct Code, Vulnerable Dependencies: A Large Scale Measurement Study of LLM-Specified Library Versions7 May 2026
- 2026Are AI-assisted Development Tools Immune to Prompt Injection?23 Mar 2026
- 2026Where Do AI Coding Agents Fail? An Empirical Study of Failed Agentic Pull Requests in GitHub21 Jan 2026
- 2025Can LLMs Find Bugs in Code? An Evaluation from Beginner Errors to Security Vulnerabilities in Python and C++22 Aug 2025
- 2025HiLDe: Intentional Code Generation via Human-in-the-Loop Decoding28 May 2025
- 2025A Blueprint for AI-Driven Software Quality: Integrating LLMs with Established Standards19 May 2025
- 2025LLMs' Reshaping of People, Processes, Products, and Society in Software Development: A Comprehensive Exploration with Early Adopters6 Mar 2025