Study evaluates the functional and security gap of 32 LLMs: newer models are safer but none eliminate the gapNewer and Bigger, but Safer?
The authors track 32 models on CWEval: newer versions are absolutely safer, but no family closes the gap.
- Code generation leaderboards are ranked mostly by functional tests, and safety rarely enters the ranking. The functional-safety gap is the difference between being functionally plausible and also passing safety tests. Previous longitudinal studies covered only three families, open weights only Llama, and compact tiers and per-language weaknesses remain uncompared.
- On CWEval's 119 tasks, for seven families and 32 models, 100 samples each, estimate func@k, func-sec@k, and their difference, and use CVR to see which CWEs and languages weaknesses fall into. Use GEE with the first stage or flagship as baseline. Prompts contain no security instructions; evaluation uses dynamic tests.
- Each family's latest stage significantly narrows the gap at at least one k, but no one closes it. At k=1 the gap ranges from 0.13 (GPT-5.6 Sol) to 0.28 (Gemini 3.1 Pro). The compact tier is wider in 8 of 9 significant comparisons. CWE-117 and CWE-113 remain near the highest.
- The authors note that tasks may have entered the training data, some CWEs have only one or two tasks, and the single-function setting may not represent larger codebases, and they plan to additionally test safety prompts and programming agents with fixed models. The experiments cover 32 models across seven families, no safety instructions, dynamic testing, and k=1 and k=50.
- Evaluated models
- Gemini 1.5 ProGemini 2.5 ProGemini 3.1 ProGemini 3.7 FlashGPT-4oGPT-5GPT-5.6 SolGPT-5 miniGPT-5.6 LunaQwen 3 (235B A22B)Qwen 3 Coder (480B A35B)Qwen 3.5 (397B A17B)DeepSeek V3 (671B)DeepSeek V3.2 (671B)DeepSeek V4 Pro (1.6T)DeepSeek V4 Flash (284B)GLM 4.7 (355B)GLM 5.2 (744B)Kimi K2.7 Code (1T)MiniMax M3 (428B)
- Benchmarks
- CWEval
- Metrics
- func@kfunc-sec@kΔsec(k)CVR
A longitudinal study evaluated the functional and security gaps of 32 LLMs across seven model families over three consecutive generations, using CWEval's 119 tasks, five programming languages, and 31 CWE categories, comparing flagship and compact versions. Results show that newer models are indeed safer in absolute terms, but no family eliminates the gap; unlike prior work, openness does not distinguish families—all examined open-weight families significantly narrowed the gap, while Gemini 3.1 Pro's gap is as wide as previously reported for Llama. Compact models generally generate less secure code than flagship versions, with notable exceptions like Gemini 3.7 Flash. At the CWE level, weaknesses such as log injection (CWE-117) and HTTP response splitting (CWE-113) persist, the latest closed-source models show regressions in memory and integer weaknesses, and the risk of the same CWE varies greatly across languages. The authors therefore advise developers not to assume that upgrades improve security or that closed-source models are safer, to rerun security checks after each model change, and to provide secure APIs in the model context.
Related events and news
1 events · 0 news mentions
- This event's paper
论文纵向评测32个模型代码安全
Paper analysis
What problem does this paper attempt to solve?
Whether newer versions and smaller tiers narrow the gap between functional pass and safety failure.
Generated code can pass functional tests but fail security tests; does this gap narrow with version, tier, and language.
- Context: The authors state that code generation is the most studied use of LLMs in software engineering, with assistants writing and modifying code for developers. When choosing models, people look at leaderboards; coding leaderboards rank primarily by functional test pass rates, and security rarely enters the ranking. Early studies reported that about 40% of programs generated by GitHub Copilot had vulnerabilities, and only 5 of 21 programs written by ChatGPT were secure without further prompting. Such defects enter public projects; people using AI assistants write less secure code yet trust it more.
- Limitations of prior work: The authors state that a snapshot at one point in time cannot answer whether new versions are safer or bring back weaknesses avoided by previous versions. Cannavale et al. tracked four versions each of GPT, Claude Sonnet, and Llama on CWEval, concluding "smarter, but not safer": two proprietary families narrowed the gap, Llama did not. The authors note that this design evaluates only one tier per family, open weights include only Llama, languages are only a robustness check, and all weaknesses are averaged into one gap per language.
- What this paper distinguishes: Whether open-weight or proprietary, flagship or compact models become safer overall across successive versions, or only improve on some weaknesses and some languages. The authors state the community lacks methods to track such trajectories.
- What this paper does: Seven families, 32 models, three stages per family, with compact tiers compared to flagship when available. Using CWEval's 119 tasks, five languages, 31 CWEs, 100 samples per task, totaling 380,800 programs, it answers gap trajectories, tiers, CWE evolution, and language differences, and writes implications for vendors, developers, and researchers.
What related research exists?
Compare with static and dynamic safety benchmarks, version-change studies, and the gap trajectories of Cannavale et al.
Section 2 of the paper divides related work into safety evaluation of generated code and model changes across versions, and separately discusses recent longitudinal gap studies.
Safety evaluation of generated code
- Single-time-point measurements: Tihanyi et al. (2025) formally verify 331,000 compilable C programs from nine models, claiming at least 62.07% are vulnerable, with little difference among models. Kharma et al. (2026) claim weaknesses vary by language, with memory management issues most common in C and C++, and cryptographic and XML weaknesses most common in Java and Python. Tóth et al. (2024) claim that at least 11.16% of 2,500 PHP websites generated by GPT-4 have exploitable vulnerabilities.
- Static benchmarks: SecurityEval, LLMSecEval, and CodeLMSec use CodeQL, while CyberSecEval uses its own detectors. The paper notes that static detection misses unsafe code that does not match rules: on Copilot-generated code, SecurityEval authors found the target weakness with CodeQL in 18.46% of cases, while manual inspection found 73.84%; CyberSecEval's detector recall relative to human labels is 79%. These benchmarks do not check whether code works, so models can avoid weaknesses with solutions that do nothing.
- Dynamic benchmarks: BaxBench performs end-to-end exploitation on backends that pass functional tests; the paper reports the success rate as about half of that. SeCodePLT splits samples into failed, works but unsafe, and works and safe, covering 44 risk categories. SEC-bench builds tasks from real CVEs and scores agents' exploitation and repair. This paper chooses CWEval because it evaluates single-model function completion and its safety oracle is dynamic.
Model changes across versions
- Chen et al. (2023): Compares GPT-3.5 and GPT-4 from March and June 2023, finding both improvements and declines across seven task types. The paper states this work does not evaluate the safety of generated code.
- Liu et al. (2026): Updates to GPT, Llama, and Qwen do not consistently improve adversarial robustness, and larger models are not necessarily more robust. The paper states it does not evaluate generated code safety.
- Elgedawy et al. (2024): Three versions from November 2023 to March 2025, collecting 450 samples from nine platforms across GPT, Gemini, and DeepSeek, covering nine online shopping tasks, tested with and without safety instructions, using CodeQL and manual review against OWASP Top 10. After revision, the final stage produces functional code for every task on every platform, but vulnerability counts do not consistently decline. The paper notes they test platforms, not just models, and use only static analysis.
Functionality-security gap
- Cannavale et al. (2026): Tracks 12 models across GPT, Claude Sonnet, and Llama on CWEval, four versions per family. Defines the functionality-security gap and conditional vulnerability rate (CVR), fits the gap with GEE, and categorizes categories into persistent blind spots, evolutionary divergence, and regression anomalies. The paper's named limitations: only one tier per family; only Llama among open weights; 10 samples per task, mainly reporting k=10; language only as a robustness check with one average score per language. The authors state they adopt its metrics, statistics, and categorization but evaluate two tiers, five open-weight families, 100 samples per task, and report k=1 and k=50.
Baselines and benchmarks
- Benchmark: CWEval (Peng et al., 2025), 119 tasks, 31 CWEs, languages C, C++, Go, JavaScript, Python.
- Comparisons: Not another generation method. The trajectory GEE uses each family's first stage as baseline, and tier comparisons use flagship as baseline; discussion compares numbers with Cannavale et al. on the same benchmark.
The authors position this paper as: a larger evaluation reveals previously overlooked facts; open weights do not separate families; the cost of compact tiers varies by stage; the same CWE poses different risks across languages.
How does the paper address this problem?
Estimate on CWEval the difference between functional pass rate and functional-and-safe pass rate, and compare stages and tiers with GEE.
The authors do not train new models but track how the functionality-security gap changes across stages and tiers on the same set of dynamic tests.
Problem setup
- Operational definition of safety: Code is safe only if it passes CWEval's set of targeted security tests. The gap is the difference between "functionally plausible" and "also passing security tests."
- Four questions: RQ1 asks whether the gap narrows across a family's three stages or only becomes better at writing functional code. RQ2 asks whether compact models are less safe than flagships and whether the difference is just lower capability. RQ3 asks which CWEs concentrate unsafety, whether persistent, divergent across families, or regressive. RQ4 asks whether the risk of a given weakness type depends on language.
Models and stages
- 32 models, seven families (Table 1): proprietary are Google and OpenAI; open-weight are Qwen, DeepSeek, Z.ai, Moonshot, MiniMax. Three consecutive public versions per family, called stages. Compact tiers are publicly smaller-parameter checkpoints on the open-weight side and cheaper API tiers on the proprietary side, with parameters undisclosed.
- Tier coverage: Both proprietary families have flagship and compact tiers at each stage. Qwen has compact tiers across all three stages; Z.ai is GLM 4.7 Flash; DeepSeek is DeepSeek V4 Flash. MiniMax and Moonshot have no compact tiers. The authors state that the latest GPT-5.6 Sol, GPT-5.6 Luna, Gemini 3.1 Pro, and Gemini 3.7 Flash drive their respective vendors' programming agents.
- Differences not separated: The table marks whether reasoning precedes answering. Two Qwen 3 Coder and Kimi K2.7 Code are code-oriented, but the authors treat them as ordinary stages and refer to Kimi K2.7 Code simply as Kimi K2.7. Kimi K2 uses the thinking variant, so all three Moonshot stages reason. The authors state that at selection time, these open-weight flagships were among the stronger open-weight models on SWE-bench, LiveCodeBench, or HumanEval.
Tasks, sampling, and judgment
- CWEval: 119 tasks, 31 CWEs, five languages. Models receive a function signature, behavior comments, and available imports, and complete the function body. Descriptions involve security-relevant operations but do not mention safety. Functional tests and security tests on attack inputs are recorded separately; samples can be functionally plausible but unsafe, or safe but functionally implausible. The authors use only prompts without safety instructions, stating this corresponds to everyday use. Passing functional tests only indicates functional plausibility, not correctness.
- Selection rationale: It evaluates a single model, not a repository-level agent with extra layers; security failures occur only when unsafe behavior is exhibited on attack inputs, not because source code resembles a pattern. Apart from completion length, batch interface, and three minor test fixes, the authors state they did not modify prompts, oracles, or the task set.
- Collection: GPT-4o, GPT-4o mini, Gemini 1.5 Pro, and Gemini 1.5 Flash reuse existing CWEval results. The other eight proprietary models are queried via OpenRouter batch, with an API budget of $600. The 20 open-weight models use vLLM 0.28.0 on a single node with 8 GPUs, using vendors' official quantized checkpoints (mostly FP8, three Kimi as INT4, BF16 when no official quantized version exists). The authors state that existing work shows official low-bit quantization maintains functional benchmark performance comparable to unquantized baselines. Completion budget is 65,536 tokens; Qwen 3 (235B) and Qwen 3 (30B) are 32,768. The four non-reasoning reused models still use the original budget of 2,048.
- Sampling: n=100 per task, temperature 0.8; GPT-5 and GPT-5 mini APIs only accept temperature 1. Total 380,800 programs.
Metrics and statistics
- Two core quantities: On pass@k estimates, func@k is the probability that at least one of k samples is functionally plausible, func-sec@k is the probability that at least one is both plausible and passes security tests, averaged over T=119 tasks. The gap and conditional vulnerability rate are
Δsec(k)=func@k−func\text{-}sec@k
CVR=(p−b)/p
The former is the difference between two pass rates; the latter is the proportion of unsafe samples among functionally plausible samples in a set of tasks (a CWE or a language).
- k: Computed for k=1, 10, 50; the main text reports 1 and 50. k=1 corresponds to the typically accepted single completion; k=50 estimates whether at least one plausible and safe solution can be produced with enough attempts. At k=1, the gap is the proportion of functionally plausible but unsafe samples.
- GEE: For RQ1, compute the gap per flagship per task. Fit a Gaussian GEE per family and per k, identity link, stage as the only predictor, first stage as baseline, clustered by task. β is the difference in gap between that stage and the first stage; negative indicates narrowing. p<0.05 is considered significant. For RQ2, replace the predictor with tier, flagship as baseline; positive β indicates a wider gap for the compact tier.
- Categorization: RQ3 looks at the 16 categories with highest average CVR. Persistent blind spots are high across all stages; evolutionary divergence is some families declining, others stagnant; regression anomalies are later stages worse. Manual review is done for blind spots and regressions. RQ4 aggregates CVR by language and examines samples from each family's first and latest flagships to explain the largest differences.
What experiments did the paper conduct?
The authors state that each family's latest stage narrows the gap, but no family closes it.
Experimental Setup
- Models tested: The 32 in Table 1, all as evaluation subjects. The 12 proprietary are Gemini 1.5/2.5/3.1 Pro, Gemini 1.5/2.5 Flash, Gemini 3.7 Flash, and GPT-4o, GPT-5, GPT-5.6 Sol, GPT-4o mini, GPT-5 mini, GPT-5.6 Luna. The 20 open-weight are Qwen 3 (235B, 30B), Qwen 3 Coder (480B, 30B), Qwen 3.5 (397B, 27B); DeepSeek V3, V3.2, V4 Pro, V4 Flash; GLM 4.5, 4.7, 5.2 and GLM 4.7 Flash; Kimi K2 (thinking), Kimi K2.5, Kimi K2.7 Code; MiniMax M2.1, M2.5, M3.
- Tasks: CWEval, 119 tasks, 31 CWEs, languages C, C++, Go, JavaScript, Python. There are also C (mem) tasks that do not share categories with the core languages. 100 samples per model per task.
- Metrics: func@k, func-sec@k, Δsec(k), CVR. The paper reports k=1 and k=50 in the main text.
- Evaluation: Functional test suites and dynamic security tests on attack inputs, not LLM scoring. Prompts contain no security instructions.
- Statistics: One GEE per family and per k, significance threshold p<0.05. The paper does not report independent repetitions beyond the 100 samples.
- Configuration: Temperature 0.8, GPT-5 and GPT-5 mini at 1. Four first-stage proprietary models reuse existing CWEval results. Open weights use official quantized checkpoints.
Main Results
At the latest stage, k=1 gaps range from 0.13 for GPT-5.6 Sol to 0.28 for Gemini 3.1 Pro (§4.1, Figure 1). Google's func@1 rises from 0.69 for Gemini 1.5 Pro to 0.94 for Gemini 3.1 Pro. The table below shows β for flagship relative to the first stage (Table 2); negative values indicate a narrowing gap.
Swipe horizontally to read the table
Family k=1 stage 2 k=1 stage 3 k=50 stage 2 k=50 stage 3 Google -0.065 (p=0.033) -0.027 (p=0.486) -0.114 (p=0.002) -0.107 (p=0.006) OpenAI -0.205 (p<0.001) -0.175 (p<0.001) -0.181 (p<0.001) -0.148 (p<0.001) Qwen +0.005 (p=0.841) -0.050 (p=0.006) +0.074 (p=0.005) -0.033 (p=0.167) DeepSeek -0.011 (p=0.587) -0.094 (p<0.001) -0.114 (p<0.001) -0.160 (p<0.001) Z.ai -0.014 (p=0.316) -0.046 (p=0.024) +0.042 (p=0.028) -0.077 (p<0.001) Moonshot +0.005 (p=0.663) -0.037 (p=0.015) +0.036 (p=0.016) -0.004 (p=0.753) MiniMax +0.010 (p=0.401) -0.056 (p=0.023) -0.002 (p=0.921) -0.085 (p=0.001) - The authors state that each family significantly narrows the gap at least at one k by the latest stage, but no family closes it. Evolution is not monotonic: Google at k=1 only significantly narrows at the intermediate stage, and the latest stage is not significant for single attempts; at k=50 it significantly narrows relative to the first stage. The authors argue that security gains only narrow the gap when they exceed functional gains, and state that OpenAI's func-sec@1 increase is several times its func@1 increase.
- OpenAI is the only family where both subsequent stages differ significantly from the first stage at both k values. The authors state its latest stage does not further narrow the gap. DeepSeek, Z.ai, and MiniMax significantly narrow at both k values in the latest stage.
- The authors state that at k=50, Qwen, Z.ai, and Moonshot significantly widen at the intermediate stage, with no corresponding change at k=1; the authors believe intermediate models completely lose secure solutions on some tasks, while single attempts remain at least as safe as before. All three families recover at the latest stage. Qwen and Moonshot's latest stages only significantly narrow relative to the first stage at k=1.
Flagship vs. Compact Tiers
- Compare the two tiers within the same stage (Table 3, Figure 1). MiniMax and Moonshot have no compact tier and are excluded. Google, OpenAI, and Qwen have both at every stage; DeepSeek only at the latest stage, Z.ai only at the intermediate stage.
- Of 22 comparisons, 13 are not significant, with directions both positive and negative, including Qwen at every k=1. When differences are significant, 8 of 9 times the compact tier is wider. The exception is Gemini 3.7 Flash: β at k=1 is -0.048 (p=0.022); the authors state that in Figure 1 its func-sec@k is the same as Gemini 3.1 Pro. The authors state the penalty shrinks with evolution: at k=50, compact tiers of three families are significantly wider at the first stage, and only OpenAI remains at the latest stage.
- The families still wider at the latest stage are the two with the most consistent narrowing in RQ1. GPT-5.6 Luna is significantly wider than GPT-5.6 Sol at both k values (β=+0.063 at k=1, β=+0.040 at k=50), because the compact tier loses security from GPT-5 mini to GPT-5.6 Luna while the flagship holds. DeepSeek V4 Flash is significantly wider at k=1 (β=+0.059). The authors distinguish two penalties: V4 Flash's functional plausibility is close to V4 Pro, but it has fewer secure solutions; GLM 4.7 Flash's gap is nearly identical to the flagship because both functionality and security are lower together.
CWE Persistence, Divergence, and Regression
- Figure 2 shows the 16 CWEs with the highest average CVR. Diagonal cells have no functionally plausible samples, so CVR is undefined. The authors state many categories improve with evolution, and CWE-918 is below the starting point across all families and tiers.
- Persistence: CWE-117 and CWE-113 are near the highest in almost every family, tier, and stage. The exception is OpenAI's CWE-113: both tiers decline at the intermediate stage, and the authors state GPT-5 makes more than half of functionally plausible samples pass security tests, with the latest stage partially losing this gain. Manual inspection states Python samples write messages verbatim to logs without removing newlines that could forge new entries; CWE-113 samples check header types and then assign directly without removing CRLF. The authors believe this points to a domain-wide blind spot.
- Divergence and regression: On CWE-79, OpenAI's flagship drops to 0, Google, DeepSeek, and MiniMax flagships also decline, Qwen maintains the highest in both tiers, and Moonshot worsens. On CWE-22, except for OpenAI and DeepSeek flagships, the latest models stop at half or more. On CWE-643, OpenAI resolves in both tiers, while DeepSeek and Google flagships still leave most plausible samples insecure. The authors state these splits do not follow the proprietary/open-weight divide; CWE-347 improves across all proprietary trajectories with no comparable gain for open weights. CWE-400 regresses on Google, OpenAI, and DeepSeek flagships, and manual inspection states the latest models treat the caller's search pattern as a regular expression. On CWE-125, only OpenAI's latest models are worse than the first stage, rising from 0 for GPT-4o and GPT-4o mini. On CWE-190, Gemini 3.1 Pro rises from near 0 for Gemini 2.5 Pro to the highest among all latest models. GPT-5.6 Luna is worse than GPT-5 mini on most of the 16 categories, with at least four categories differing greatly. Gemini 3.1 Pro reintroduces CWE-95 that Gemini 2.5 Pro had nearly eliminated. Qwen 3 Coder (480B) is the least secure flagship in its family on six categories, all recovering at the latest stage. On CWE-502, the latest DeepSeek tiers are insecure on almost every plausible sample.
Language Differences
- Aggregating 32 models, average CVR for core languages from high to low is C, Go, C++, then JavaScript and Python (Figure 3). C is highest on 27/32 models; when comparing only the 15/31 CWEs covered by all five core languages, C still ranks first. C (mem) is lowest on every model, and the authors do not discuss it further.
- CWE-117 and CWE-113 are near the highest in every language. CWE-347's CVR is 0.73 in Go, 0.71 in C, and 0.04 in Python. Manual inspection states insecure C, Go, and JavaScript samples accept arbitrary HMAC algorithms, while Python libraries require explicit algorithms. CWE-22 is notably lower in Go. CWE-643 is lowest in C++. CWE-502 is tested only in Python and JavaScript, at 0.80 and 0.00 respectively; the authors state Python samples often reuse the unsafe YAML loader imported by the prompt, while JavaScript loaders are safe by default. CWE-95 has the opposite order. Among Google, Qwen, Z.ai, and MiniMax, C is the core language with the smallest decline from the first to the latest stage; OpenAI is the opposite. Gemini 3.7 Flash leaves every functionally plausible C sample insecure on CWE-79, while the same family's Flash models reduce Go and Python to near 0. The authors believe models take the shortest path suggested by the language or prompt, regardless of whether that path is safe.
Other Ablations and Analyses
- Compared to Cannavale et al.'s GPT: their k=1 gap goes from 0.360 to 0.144, while this paper's OpenAI goes from 0.30 to 0.13 (§5.4).
- Gemini 3.1 Pro's k=1 gap is 0.28; the authors state it is close to the 0.296 they reported for Llama 4 Scout (§5.4).
- DeepSeek V3 and V3.2, with the same parameter count, still show a significant narrowing at k=50 (§6).
- Version intervals for each trajectory range from 5 to 27 months; the authors describe changes by version rather than by time (§6).
- The paper does not give k=10 values in the main text, stating they are in the reproduction materials (§3.4).
- Several CWEs have only one or two tasks; the authors state they make no claims relying on cells with very few functionally plausible samples (§6).
What are some points that can be further explored?
The authors plan to additionally test prompts with safety instructions and fix models to compare programming agents.
Limitations and future directions noted by the authors
- Data contamination: CWEval predates most tested models, so tasks may have entered training data, potentially inflating cross-stage improvements; the authors argue this does not explain persistent weaknesses and regressions (§6 Internal Validity).
- Prompts: The authors did not modify CWEval prompts. Safety-aware prompts might yield smaller gaps, left for future work; conclusions plan to use CWEval's safe mode with "write safe code" instructions, comparing stages and tiers (§6, §7).
- Per-CWE task counts: Several CWEs have only one or two tasks, so results may reflect task characteristics; the authors treat them as observations on benchmark tasks, not general claims about CWEs (§6 Conclusion Validity).
- Extrapolation: Findings may not generalize to other model families, CWEs, or languages. The authors did not evaluate Claude and Llama because existing work covers their trajectories on CWEval (§6 External Validity).
- Code context: Tasks are isolated single functions; whether larger contexts avoid these weaknesses is left for future work (§6).
- Regression causes and agents: The authors believe why safety is lost between versions remains to be studied, including whether new models' training prefers more general constructs and how to prevent resulting regressions (§5.3). They plan to study the safety of code generated by successive versions of programming agents while fixing the underlying model (§7).
Experimental coverage
- Tested are the 32 models in Table 1, seven families, three stages; Google, OpenAI, and Qwen have compact tiers at each stage, DeepSeek only at the latest stage, Z.ai only at the middle stage, MiniMax and Moonshot have none (§3.1).
- Tasks are CWEval's 119, 31 CWEs, five languages; 100 samples per task, totaling 380,800 programs; the main text reports k=1 and k=50 (§3.2–3.4).
- Only prompts without safety instructions are used; functionality and safety are both judged by dynamic tests, not LLM review. Four first-stage proprietary models reuse existing CWEval results (§3.2–3.3).
- Trajectories and tiers use Gaussian GEE clustered by task, threshold p<0.05; CWE analysis focuses on the 16 categories with highest average CVR. Manual inspection by two co-authors is used only to explain identified patterns (§3.5, §6).
- Open weights use official quantized checkpoints; completion budget is 65,536 tokens, 32,768 for two Qwen 3 checkpoints; temperature is 0.8 except GPT-5 and GPT-5 mini (temperature 1). The paper does not report k=10 values in the main text, nor inter-rater agreement numbers for manual inspection (§3.3–3.4, §6).
Summarize the main content of the paper
Absolute safety rises and the gap persists; open weights do not separate the trajectories of families.
The authors longitudinally evaluate the functionality-security gap in code generated by 32 LLMs across seven families, to see whether new versions are only better at writing code that passes functional tests.
- Problem: Coding leaderboards mainly focus on functional tests. The authors want to distinguish whether safety test pass rates improve together across successive versions, flagship vs. compact tiers, open-weight vs. proprietary models, and different languages.
- Approach: On CWEval's 119 tasks, three stages per family, with compact tiers compared to flagship when available. 100 samples per task. The gap is the difference between func@k and func-sec@k, the unsafe proportion among functionally plausible samples is the CVR, and GEE is used to compare stages and tiers. Prompts contain no safety instructions; judgment relies on dynamic tests.
- Trajectory: At the latest stage, k=1, the gap ranges from 0.13 for GPT-5.6 Sol to 0.28 for Gemini 3.1 Pro. The authors state that each family significantly narrows the gap at at least one k by the latest stage, but no family closes it. Google's func@1 rises from 0.69 to 0.94, with a similar rise in safety, so the single-attempt gap is nearly unchanged. OpenAI's β for the middle stage relative to the first stage at k=1 is -0.205, the largest narrowing in Table 2, with no further narrowing at the latest stage.
- Tiers, weaknesses, and languages: When differences are significant, the compact tier is less safe in 8 of 9 cases; Gemini 3.7 Flash is significantly narrower at k=1. CWE-117 and CWE-113 have near-highest CVR on almost all models. Splits in categories like CWE-79 do not align with the open-weight divide; CWE-347 shows improvement across all proprietary families. C is the core language with the highest CVR in 27 of 32 models. The latest proprietary models regress on categories like CWE-125 and CWE-190 that previous generations had already addressed.
- Authors' conclusions: Developers should not assume that upgrading is safer, nor that proprietary models are safer; after switching models, they should rerun safety checks and put safety APIs in the prompt context. Vendors should report safety scores alongside functionality scores and compare by weakness type with the previous version. Researchers should report multiple attempts and more than two versions. The authors argue that open weights do not determine the trajectory, and cheaper tiers are not a fixed safety cost.