GO TO A SECTION

↑ ↓ to navigate · Enter to openExplore all sections →
FDEInterviews logo
CCS 2023

Do Users Write More Insecure Code with AI Assistants?

People given an AI assistant wrote less secure code on four of five tasks and felt more sure of it. Across 47 participants the direction holds; the paper's adjusted tests stop short of proof.

Breakdown by FDE Interviews · 11 min read · Updated

About the original · 2022
AUTHORS
Perry, Srivastava, Kumar, Boneh
FROM
Stanford University
PUBLISHED
Nov 2022 · CCS 2023
CITED BY
521Semantic Scholar · Nov 2026
IN THIS BREAKDOWN · 10 SECTIONS

You can read 24% of this breakdown.

01

The paper in one minute

Earlier work, including the Copilot study on this site, showed that code assistants often suggest insecure code. But people do not paste every suggestion unchanged: they edit, test and sometimes reject them. This Stanford study asks the question that matters for teams: do people who use an assistant end up with less secure code than people who do not?

The authors built a study app with a code editor and, for the experiment group, a panel for querying an assistant based on OpenAI's codex-davinci-002 with adjustable settings such as temperature. Participants had two hours for five tasks: encrypt and decrypt a string with a symmetric key in Python, sign a message with an ECDSA key in Python, open a file only inside a given directory in Python, insert a row into a SQL table from JavaScript, and format an integer with commas in C. After screening, 47 people remained, 33 with the assistant and 14 without, mostly students with some professionals. Two authors graded every answer for correctness and security, with agreement scores reported.

With the assistant, fewer participants wrote secure answers on four of the five tasks. On encryption, more used trivial ciphers or insecure modes. On signing, 3% wrote a secure solution against 21% without the assistant, mostly because of unsafe randomness from the library the assistant chose. On the directory task, assistant code checked the path's prefix but did not resolve ".." or symbolic links. On SQL, 36% with the assistant wrote code open to injection against 7% without. The C task showed no clear difference.

Participants with the assistant also rated their answers as more secure on every question, and those whose answers were secure tended to trust the assistant less. The authors' prompt analysis found that participants who gave specific instructions, supplied function signatures and edited outputs heavily produced more secure code. The headline claim rests on per-task chi-squared tests; the paper's own logistic regression, corrected for testing five tasks, does not reach significance, a point this page returns to.

THE IDEA, VISUALLY
WROTE A SECURE ANSWER (TABLE 4) Q1 encrypt / decrypt (Python) 21% with assistant 43% without Q2 sign a message (Python) 3% with assistant 21% without Q3 sandboxed path (Python) 12% with assistant 29% without Q4 SQL insert (JavaScript) 36% with assistant 50% without Q4, vulnerable to SQL injection: 36% with, 7% without. 33 participants had the assistant (codex-davinci-002), 14 did not; mostly university students; 2 hours. Q5 (C strings) showed no clear difference. arXiv 2211.03622 v3, Stanford, CCS 2023 ASSISTANT EFFECT, ADJUSTED (TABLE 3) p-value for the assistant, and the Benjamini-Hochberg bar it must clear Q1 0.018 needs < 0.010 Q2 0.166 needs < 0.020 Q5 0.254 needs < 0.030 Q4 0.279 needs < 0.040 Q3 0.562 needs < 0.050 0.0 0.2 0.4 0.6 None clears its threshold. Pooled across all five questions, p = 0.056. POWER AT 33 VS 14 (OUR SIMULATION) A true gap of 30% vs 50% secure is detected (p < 0.05) in 22% of such studies; 20% vs 50% in 49%. Small samples cannot rule an effect in or out.
Left: share of participants who wrote a secure answer, with the assistant (33 people) and without it (14), per task (Table 4). Right: the paper's regression p-values for the assistant's effect on each task, each against the Benjamini-Hochberg threshold the paper itself lists; none clears it, and the pooled p is 0.056.
Research notes: the problem, approach and results
36% vs 7%

participants whose SQL insert was open to injection, with vs without the assistant (Section 4.4)

3% vs 21%

participants who signed a message securely with ECDSA, with vs without the assistant (Section 4.2)

p = 0.056

pooled effect of having the assistant on writing a secure answer, from the paper's logistic regression (Table 3)

THE PROBLEM

Lab studies showed code assistants often suggest insecure code, but developers choose what to accept, edit and test. Whether people end up shipping less secure code with an assistant than without one had not been measured.

THE IDEA

Give 47 participants five security-related programming tasks in Python, JavaScript and C under a two-hour limit; let 33 use an assistant built on codex-davinci-002 and 14 work without it; grade correctness and security by hand and survey their confidence.

THE RESULT

With the assistant, fewer participants wrote secure answers on four of five tasks (for example, 36% vs 7% wrote SQL open to injection), and they rated their answers as more secure. Per-task chi-squared tests reach p < 0.05; the paper's adjusted regression does not after correction.

02

Why it matters to an FDE

The risk is confident acceptance, not just bad suggestions. People with the assistant wrote less secure code and believed it was more secure. When a customer rolls out a coding assistant, plan for that gap: review and scanning have to catch what developers now accept without checking.

The mistakes are specific and predictable. Unsafe randomness and weak cryptography modes, path checks that skip canonicalization, SQL built by string concatenation. These are the patterns to put in linters, code-review checklists and secure helper libraries before rollout.

Experience changed how people used it. Participants with secure answers edited the assistant's output heavily and trusted it less. Pairing assistant rollout with short secure-coding guidance for the specific stack is cheap and aimed at the right people.

Do not overclaim the evidence. With 33 and 14 participants, the paper's adjusted analysis does not reach statistical significance, and our simulation shows a study this size would miss a real 30-versus-50% difference most of the time. The direction is consistent across four tasks, which is worth acting on; it is not a measured effect size to quote in a business case.

Measure it in the customer's setting. Compare scanner findings per change for code written with and without the assistant, by weakness class. That turns a lab result into the customer's own evidence.

THE FULL BREAKDOWN

Understand the mechanism. Try it on a real problem.

Unlock this breakdown and 290 more papers.

Premium opens every paper in full, plus every answer, concept, course and guide on the site. One payment for six months of access.

6 months · One payment · No auto-renewal

Get Premium · ₹2,000 / $25
  • ◇1 architecture diagram
  • </>1 runnable code experiment
  • ▦2 results tables
  • ?5 interview questions with answers
  1. 03Key takeaways

    The design, the five tasks, the mistakes, the confidence gap, the prompt analysis and the statistics

    Free account
  2. 04How it works

    Recruitment and screening, the study app, the five tasks, grading rules, and the statistical tests

    Premium
  3. 05The numbers that matter

    Table 4 as percentages and counts, the text's p-values, the regression, and the trust ratings

    Premium
  4. 06Try it yourself

    Turn Table 4 into counts, retest with Fisher, apply the correction, simulate the power

    Premium
  5. 07Where it breaks

    Small unbalanced groups, students on a clock, one 2022 model, and tests that fail correction

    Premium
  6. 08Using it on a deployment

    Pair rollout with scanning, secure helpers, short guidance and your own measurement

    Premium
  7. 09Interview angles

    Five questions this paper prepares you for, with answer hints

    Premium
Back to the paper library →