← Lab /Software

Newer LLMs generate safer code but the functionality-security gap remains

Newer and larger LLMs produce more secure code overall, yet no model family eliminates the functionality-security gap

Software arXiv 6 Oct 2026 Measurement Simulation evidence

Published as “Newer and Bigger, but Safer? A Longitudinal Study of the Functionality-Security Gap in LLM-Generated Code”

Why it matters

Developers should not assume newer or cheaper LLMs are automatically more secure; security scores need to be tracked per version and per model tier.

Summary

Newer models generate more code that is both functionally plausible and secure, but the functionality-security gap never disappears. Every family narrows the gap significantly by its newest stage for at least one attempt count, yet none closes it, and compact models often remain less secure.

What they found 3

  1. Newer models produce more secure and functional code than their earliest versions.

    “Our results show that newer models do become safer in absolute terms: in every family, the newest stage produces more code that is both functionally plausible and secure1 than the first.”

  2. All families narrow the functionality-security gap at their newest stage for at least one attempt count, but no family eliminates the gap.

    “Every family also narrows the gap significantly by its newest stage for at least one number of attempts per task, but none closes it.”

  3. Compact models are generally less secure than their flagship counterparts, though the penalty shrinks over time.

    “When the tiers differ significantly, the compact model is less secure in eight of nine cases.”

Caveats 4

  • Google’s newest stage does not narrow the gap significantly when models get a single attempt (RQ1).
  • Some families widen the gap at their middle stage (e.g., Qwen, Z.ai, Moonshot at k=50).
  • Compact models of OpenAI and DeepSeek retain a wider gap even at the newest stage.
  • CWEval offers prompts with and without an instruction to write secure code, and we use only those without it, which reflect ordinary use.

What’s new here 4

  • Longitudinal analysis of 32 models across three successive stages, rather than a single snapshot.
  • Comparison of flagship and compact tiers within each family.
  • Per-CWE and per-language vulnerability analysis, revealing blind spots like CWE-117 and CWE-113.
  • Use of 100 samples per task (380,800 programs) and reporting both k=1 and k=50 pass@k results.