Skip to main content
QUICK REVIEW

[Paper Review] Do Users Write More Insecure Code with AI Assistants?

Neil Perry, Megha Srivastava|arXiv (Cornell University)|Nov 7, 2022
Software Engineering ResearchComputer Science24 references18 citations
TL;DR

This study investigates whether AI code assistants lead users to write more insecure code, finding that participants using such tools produced significantly more security vulnerabilities than those without access. Despite this, users with AI assistance were more confident in their code's security, highlighting a dangerous overconfidence effect in real-world development contexts.

ABSTRACT

We conduct the first large-scale user study examining how users interact with an AI Code assistant to solve a variety of security related tasks across different programming languages. Overall, we find that participants who had access to an AI assistant based on OpenAI's codex-davinci-002 model wrote significantly less secure code than those without access. Additionally, participants with access to an AI assistant were more likely to believe they wrote secure code than those without access to the AI assistant. Furthermore, we find that participants who trusted the AI less and engaged more with the language and format of their prompts (e.g. re-phrasing, adjusting temperature) provided code with fewer security vulnerabilities. Finally, in order to better inform the design of future AI-based Code assistants, we provide an in-depth analysis of participants' language and interaction behavior, as well as release our user interface as an instrument to conduct similar studies in the future.

Motivation & Objective

  • To examine whether AI code assistants lead developers to write more insecure code in real-world programming tasks.
  • To assess whether users develop overconfidence in the security of code generated with AI assistance.
  • To analyze how user interaction patterns—such as prompt design and parameter tuning—affect code security outcomes.
  • To provide a reproducible user study framework and anonymized data for future research on AI-assisted software security.

Proposed method

  • Conducted a controlled user study with 47 participants solving five security-related programming tasks across Python, JavaScript, and C.
  • Compared code quality and security outcomes between participants using an AI assistant (based on OpenAI’s Codex) and a control group without access.
  • Collected and analyzed user prompts, interaction logs, model parameter adjustments (e.g., temperature), and self-assessment of code security.
  • Used statistical modeling to control for confounding factors such as prior programming experience, exposure to security concepts, and student status.
  • Performed qualitative and quantitative analysis of prompt structures, including use of helper functions and iterative refinement of prompts.
  • Released a custom UI framework and anonymized interaction data to enable replication and future research on AI-assistant interactions.

Experimental results

Research questions

  • RQ1RQ1: Do users write more insecure code when given access to an AI programming assistant?
  • RQ2RQ2: Do users trust AI assistants to write secure code?
  • RQ3RQ3: How do users’ language and behavior when interacting with an AI assistant affect the degree of security vulnerabilities in their code?

Key findings

  • Participants with access to an AI assistant wrote significantly less secure code than the control group for four out of five security tasks.
  • Users with AI assistance were more than twice as likely to rate their insecure code as secure, indicating a significant overconfidence effect.
  • Participants who included function declarations, specified task instructions, or asked the AI to generate helper functions produced more secure code.
  • Iterative use of AI outputs as new prompts led to replication or magnification of security vulnerabilities in subsequent generations.
  • Users who generated more secure code were more likely to adjust temperature settings and provide richer contextual prompts, indicating that prompt refinement improves outcomes.
  • The study found that AI assistants may reduce user proactivity in consulting documentation, especially for secure library usage, increasing the risk of insecure dependencies.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.