摘要与解读
DualGauge 论文后半部分给出安全通过率置信区间、CWE 分组与判定提示词细节。
六维情报分析
6 个维度 · 原文可溯源影响范围
-
来源报告指出,LLM 与基于 LLM 的 coding agents 已用于从自然语言规格生成代码,而保证生成代码同时具备功能正确性与安全性仍是挑战;DUALGAUGE 被定位为首个对 specification-only 代码生成联合评估正确性与安全性的全自动框架。受影响对象是采用此类生成流程的代码产出及其下游使用者;风险被放大,因为开发者可能接受不安全建议却仍对其安全性保持信心。
原文依据 · 2
中文译文
*,Keyan Guo∗、Suvadra Barua、Jiawei Guo、Abhijeet Pathak、Dinesh Gudimetla、Hongxin Hu、Haipeng Cai† 纽约州立大学布法罗分校 {rupampat,keyanguo,apathak4,dineshgu,jiaweigu,hongxinh,haipengc}@buffalo.edu suvadra.barua21@gmail.com 摘要 大型语言模型(LLM)及基于 LLM 的编程智能体如今被用于根据自然语言规格生成代码,但确保此类代码既功能正确又安全仍是一项挑战。我们提出 DUALGAUGE,这是首个联合评估仅依据规格生成的代码之正确性与安全性的全自动框架,
原文引文
*, Keyan Guo∗, Suvadra Barua, Jiawei Guo, Abhijeet Pathak, Dinesh Gudimetla, Hongxin Hu, Haipeng Cai† University at Buffalo, SUNY {rupampat,keyanguo,apathak4,dineshgu,jiaweigu,hongxinh,haipengc}@buffalo.edu suvadra.barua21@gmail.com Abstract Large language models (LLMs) and LLM- based coding agents are now used to generate code from natural-language specifications, yet ensuring such code is both functionally correct and secure remains a challenge. We present DUALGAUGE, the first fully automated frame- work for jointly evaluating correctness and se- curity of specification-only code generation,
查看原文 · v1中文译文
不安全代码(Pearce 等,2022;Majdinasab 等,2024;Tihanyi 等,2025)。有证据表明,开发者可能接受不安全的建议,同时仍相信其安全性,这进一步加剧了这一风险(Perry 等,2023;Asare 等,2024;Sandoval 等,2023)。 现有评估通常分别衡量正确性与安全性。功能性基准侧重于通过单元测试(Chen 等,2021;Hendrycks 等,2021;White 等,2025;Arora 等,2025),而安全性基准侧重于检测漏洞,却不验证生成的代码是否满足……
原文引文
nsecure code (Pearce et al., 2022; Majdi- nasab et al., 2024; Tihanyi et al., 2025). This risk is amplified by evidence that developers may accept insecure suggestions while remaining confident in their safety (Perry et al., 2023; Asare et al., 2024; Sandoval et al., 2023). Existing evaluations often measure correctness and security in isolation. Functional benchmarks emphasize passing unit tests (Chen et al., 2021; Hendrycks et al., 2021; White et al., 2025; Arora et al., 2025), while security benchmarks focus on vulnerability detection without verifying whether the generated code satisfies t
查看原文 · v1 -
信任边界在于:specification-only 提示不携带部署上下文,因此每个安全测试自带威胁模型,固定一个具体攻击及该攻击必须达不到的结果,程序通过需满足整套测试。这意味着评估结论的适用范围是基准内定义的攻击与功能域,而非任意部署环境;实际影响取决于生成代码是否进入真实部署并暴露于基准未覆盖的攻击面。
原文依据 · 2
中文译文
类别)。 DUALGAUGE-BENCH 强调可跨语言泛化的语义缺陷——输入验证、访问控制、数据泄露以及对不可信数据的不安全处理——涵盖七个功能领域、90 个 CWE 类别,以及过程内和过程间任务。附录 C.2 提供了一个删节版示例条目;详细统计数据见附录 C.3。 威胁模型。仅包含规格说明的提示不提供部署背景,因此每项安全测试都有自己的威胁模型:它规定一种具体攻击及该攻击不得造成的结果;如果程序阻止了该结果,则通过测试……
原文引文
ategory). DUALGAUGE-BENCHemphasizes semantic flaws that generalize across languages—input validation, ac- cess control, data leakage, and unsafe handling of untrusted data—and spans seven functionality do- mains and 90 CWE categories across intraprocedu- ral and interprocedural tasks. An abridged example item is in Appendix C.2; detailed statistics are in Appendix C.3. Threat model.Specification-only prompts carry no deployment context, so each security test car- ries its own threat model: it fixes a concrete attack and the outcome that attack mustnotachieve, and the program passes if the forb
查看原文 · v1中文译文
……只有满足整套测试的实现。 5 评估 我们旨在回答三个研究问题: RQ1 DUALGAUGE-BENCH 和 DUALGAUGE 在评估仅包含规格说明的编程任务时是否都可靠? RQ2 当前的大语言模型和编程智能体在安全性与功能性联合评估中的表现如何? RQ3 哪些机制导致失败? 5.1 RQ1:可靠性验证 我们依据经人工审查的真实标注,验证基准测试材料和自动化评估流程;表 3 总结了结果。对于 DUALGAUGE-BENCH,字段级一致性较高,反映出标注人员的一致性……
原文引文
nly an implementation that satisfies its whole suite. 5 Evaluation We aim to answer three research questions: RQ1 AreDUALGAUGE-BENCHandDUALGAUGEboth reliable for evaluating specification-only coding? RQ2 How do current LLMs and coding agents per- form under joint security-functionality evaluation? RQ3What mechanisms drive failures? 5.1 RQ1: Reliability Validation We validate both the benchmark artifacts and the automated evaluation pipeline against human- reviewed ground truth; Table 3 summarizes the re- sults. ForDUALGAUGE-BENCH, field-level agreement is strong, reflecting consistent annotato
查看原文 · v1
关联资产
-
原文明确关联的资产与组件:DUALGAUGE 框架与 DUALGAUGE-BENCH 基准;提示来源数据集 CodeGuard+、SecurityEval、Purple Llama CyberSecEval;被评估对象为 LLM 与 coding agents 生成的代码;评估依赖 LLM 运行时 oracle、覆盖率轨迹、执行输出与基准安全期望,以及具备网络搜索能力的 resolver 模型。被评估模型在材料中出现的有 GPT-5 medium、Claude Opus 4.7、Codestral-22B,以及 Qwen2.5-7B、Llama-3.1-8B、Mistral-7B-v0.3、Gemma-3-4B 的 base 与 instruct 变体。
原文依据 · 5
中文译文
*,Keyan Guo∗、Suvadra Barua、Jiawei Guo、Abhijeet Pathak、Dinesh Gudimetla、Hongxin Hu、Haipeng Cai† 纽约州立大学布法罗分校 {rupampat,keyanguo,apathak4,dineshgu,jiaweigu,hongxinh,haipengc}@buffalo.edu suvadra.barua21@gmail.com 摘要 大型语言模型(LLM)及基于 LLM 的编程智能体如今被用于根据自然语言规格生成代码,但确保此类代码既功能正确又安全仍是一项挑战。我们提出 DUALGAUGE,这是首个联合评估仅依据规格生成的代码之正确性与安全性的全自动框架,
原文引文
*, Keyan Guo∗, Suvadra Barua, Jiawei Guo, Abhijeet Pathak, Dinesh Gudimetla, Hongxin Hu, Haipeng Cai† University at Buffalo, SUNY {rupampat,keyanguo,apathak4,dineshgu,jiaweigu,hongxinh,haipengc}@buffalo.edu suvadra.barua21@gmail.com Abstract Large language models (LLMs) and LLM- based coding agents are now used to generate code from natural-language specifications, yet ensuring such code is both functionally correct and secure remains a challenge. We present DUALGAUGE, the first fully automated frame- work for jointly evaluating correctness and se- curity of specification-only code generation,
查看原文 · v1原文引文
curity- functionality benchmarking of specification-only code generation. C Additional Details of DUALGAUGE-BENCH C.1 Benchmark Construction Details Prompt sourcing and preprocessing.We source prompts from existing relevant datasets, including CodeGuard+ (Fu et al., 2024), SecurityEval (Siddiq and Santos, 2022), and Purple Llama CyberSecE- val (Bhatt et al., 2023). These datasets provide diverse coding requirements and security-relevant task templates that have been used in prior evalu- ations, supporting comparability, reproducibility, and alignment with established benchmarks. Be- cause exis
查看原文 · v1原文引文
urce it should not have, whether the execution path reflects a gen- uine defense (Fu and Cai, 2019, 2021).DUALGAUGE meets this requirement with an LLM-based runtime oracle that reasons over the candidate code, execu- tion outputs, coverage traces (Cai and Santelices, 2015b), and benchmark-provided security expecta- tions. To address knowledge gaps about unfamiliar libraries or APIs, a stronger resolver model with web-search capability retrieves relevant documenta- tion when needed—a lighter model handles routine evaluations, and the resolver is invoked only when external knowledge is required.
查看原文 · v1原文引文
ples, benchmarks as the unit of resampling) for secure-pass@1 per (model, language) pair, using the same eligible-sample logic as the main results. The confidence intervals for the strongest model (GPT-5 medium, Python: 14.8% [10.6, 19.3]) and the weakest (Codestral-22B, Python: 3.7% [1.6, 6.1]) do not overlap, confirming that the perfor- mance gap between the top and bottom of the rank- ing is not a sampling artifact. Rankings within the mid-range have overlapping intervals and should be interpreted as approximate. Sign test.For each (model, language) pair, we count the number of benchmarks w
查看原文 · v1原文引文
t can generate output as base (Qwen2.5- 7B and Llama-3.1-8B), the effect diverges: Llama gains substantially in sp@1 while Qwen2.5 slightly regresses despite improveds@1. Model Tuning PR SPR p@1 s@1 sp@1 qwen2.5-7b-base Base 47.3 45.0 19.8 12.5 4.0 qwen2.5-7b-instructInstruct 46.4 50.4 19.5 18.6 5.1 llama-3.1-8b-base Base 28.3 32.1 6.4 6.4 0.8 llama-3.1-8b-instruct-bf16Instruct 48.5 49.2 22.5 14.4 5.1 mistral-7b-v0.3-base Base — — 0.0 0.0 0.0 mistral-7b-instruct-v0.3 Instruct 34.9 41.1 13.0 7.4 1.7 gemma-3-4b-pt Base — — 0.0 0.0 0.0 gemma-3-4b-itInstruct 52.9 48.8 15.7 13.3 4.7
查看原文 · v1 -
适用前提:资产属于 specification-only 代码生成场景,即仅由自然语言规格驱动生成,且评估使用语言无关的提示与配对的功能/安全运行时测试;执行需在隔离容器中进行,重新生成样本需对应提供方 API 凭据。未提供本地资产清单,因此未与任何本地资产做匹配。
原文依据 · 3
中文译文
类别)。 DUALGAUGE-BENCH 强调可跨语言泛化的语义缺陷——输入验证、访问控制、数据泄露以及对不可信数据的不安全处理——涵盖七个功能领域、90 个 CWE 类别,以及过程内和过程间任务。附录 C.2 提供了一个删节版示例条目;详细统计数据见附录 C.3。 威胁模型。仅包含规格说明的提示不提供部署背景,因此每项安全测试都有自己的威胁模型:它规定一种具体攻击及该攻击不得造成的结果;如果程序阻止了该结果,则通过测试……
原文引文
ategory). DUALGAUGE-BENCHemphasizes semantic flaws that generalize across languages—input validation, ac- cess control, data leakage, and unsafe handling of untrusted data—and spans seven functionality do- mains and 90 CWE categories across intraprocedu- ral and interprocedural tasks. An abridged example item is in Appendix C.2; detailed statistics are in Appendix C.3. Threat model.Specification-only prompts carry no deployment context, so each security test car- ries its own threat model: it fixes a concrete attack and the outcome that attack mustnotachieve, and the program passes if the forb
查看原文 · v1原文引文
ion-level cues. Its prompts and runtime test suites are language-agnostic, and each task pairs executable functional and secu- rity tests for the same generated program with coverage-oriented construction. We further justify the language-agnostic design in Appendix A.2. Automated testing and benchmarking sys- tems.Execution-based systems such as YouNameIt (Bouzenia and Pradel, 2025), CXXCrafter (Yu et al., 2025), EnvBench (Eliseeva et al., 2025), and SetupBench (Arora et al., 2025) automate program execution and en- vironment setup, but do not address joint security-functionality benchmarking.
查看原文 · v1原文引文
y: sample generation for a given model and language, agentic execution in an isolated container, LLM-based eval- uation over the execution records, and metric ag- gregation at a chosenk. Reproducing the reported tables from the released result records requires only the final aggregation step and no model API ac- cess; regenerating samples requires API credentials for the corresponding providers. The evaluator- agreement numbers in§5.1 are reproduced by scor- ing the released judge outputs against the released human labels with the validation script included in the artifact. Per-task execution
查看原文 · v1
风险评估
-
已报道的风险机制是:现有评估常将正确性与安全性割裂测量,功能基准强调通过单元测试,安全基准侧重漏洞检测而不验证生成代码是否满足功能要求,导致“功能通过但安全缺失”的代码可能被误判为可用。DUALGAUGE-BENCH 聚焦输入验证、访问控制、数据泄露与不可信数据处理等跨语言语义缺陷,覆盖 7 个功能域与 90 个 CWE 类别。防护优先级应放在输入验证与不可信数据处理类缺陷上,因为评估器在这些类别上一致性最强。
原文依据 · 3
中文译文
不安全代码(Pearce 等,2022;Majdinasab 等,2024;Tihanyi 等,2025)。有证据表明,开发者可能接受不安全的建议,同时仍相信其安全性,这进一步加剧了这一风险(Perry 等,2023;Asare 等,2024;Sandoval 等,2023)。 现有评估通常分别衡量正确性与安全性。功能性基准侧重于通过单元测试(Chen 等,2021;Hendrycks 等,2021;White 等,2025;Arora 等,2025),而安全性基准侧重于检测漏洞,却不验证生成的代码是否满足……
原文引文
nsecure code (Pearce et al., 2022; Majdi- nasab et al., 2024; Tihanyi et al., 2025). This risk is amplified by evidence that developers may accept insecure suggestions while remaining confident in their safety (Perry et al., 2023; Asare et al., 2024; Sandoval et al., 2023). Existing evaluations often measure correctness and security in isolation. Functional benchmarks emphasize passing unit tests (Chen et al., 2021; Hendrycks et al., 2021; White et al., 2025; Arora et al., 2025), while security benchmarks focus on vulnerability detection without verifying whether the generated code satisfies t
查看原文 · v1中文译文
类别)。 DUALGAUGE-BENCH 强调可跨语言泛化的语义缺陷——输入验证、访问控制、数据泄露以及对不可信数据的不安全处理——涵盖七个功能领域、90 个 CWE 类别,以及过程内和过程间任务。附录 C.2 提供了一个删节版示例条目;详细统计数据见附录 C.3。 威胁模型。仅包含规格说明的提示不提供部署背景,因此每项安全测试都有自己的威胁模型:它规定一种具体攻击及该攻击不得造成的结果;如果程序阻止了该结果,则通过测试……
原文引文
ategory). DUALGAUGE-BENCHemphasizes semantic flaws that generalize across languages—input validation, ac- cess control, data leakage, and unsafe handling of untrusted data—and spans seven functionality do- mains and 90 CWE categories across intraprocedu- ral and interprocedural tasks. An abridged example item is in Appendix C.2; detailed statistics are in Appendix C.3. Threat model.Specification-only prompts carry no deployment context, so each security test car- ries its own threat model: it fixes a concrete attack and the outcome that attack mustnotachieve, and the program passes if the forb
查看原文 · v1原文引文
stable at Spearmanρ= 0.92 –0.98. Residual eval- uator error therefore does not materially affect the model comparison. Reliability is not uniform across vulnerability classes, however: agreement is strongest on input validation (F1≈ 0.92 over 48 cases) and weakest on the small code- and SQL- Component Metric Result DUALGAUGE-BENCH(field-level) Gwet’s AC1 0.963 DUALGAUGE-BENCH(benchmark-level) Gwet’s AC1 0.684 DUALGAUGEexecutor F1 (P / R) 0.910 (0.963 / 0.863)
查看原文 · v1 -
触发条件与量化证据:在 k=5 时,仍有 76%、85%、91% 的任务没有任何既正确又安全的样本;GPT-5 medium 与 Claude Opus 4.7 在功能 pass@5 上接近(44.6% vs 44.0%),但 secure@5 差距明显(53.6% vs 36.9%)。这说明仅凭功能评测挑选模型会低估安全风险,模型选择与代码合入审查应以联合指标为依据。
原文依据 · 2
原文引文
306, 307, 613, 614, 732, 749 Table 18: CWE group definitions used in Figure 4. marginal gain falls from+5.3 to +2.0 points across successivek. Even atk= 5 , 76%, 85%, and 91% of tasks respectively still havenosample that is both correct and secure. Decomposing the joint rate is instructive: GPT-5 medium and Claude Opus 4.7 are nearly tied on functional pass@5 (44.6% vs. 44.0%) yet differ sharply on secure@5 (53.6% vs. 36.9%). Two models that look equally capable under functional evaluation are far apart once secu- rity is also required—the paper’s thesis in a single 28317 Model @1 @2 @3 @4 @
查看原文 · v1中文译文
不安全代码(Pearce 等,2022;Majdinasab 等,2024;Tihanyi 等,2025)。有证据表明,开发者可能接受不安全的建议,同时仍相信其安全性,这进一步加剧了这一风险(Perry 等,2023;Asare 等,2024;Sandoval 等,2023)。 现有评估通常分别衡量正确性与安全性。功能性基准侧重于通过单元测试(Chen 等,2021;Hendrycks 等,2021;White 等,2025;Arora 等,2025),而安全性基准侧重于检测漏洞,却不验证生成的代码是否满足……
原文引文
nsecure code (Pearce et al., 2022; Majdi- nasab et al., 2024; Tihanyi et al., 2025). This risk is amplified by evidence that developers may accept insecure suggestions while remaining confident in their safety (Perry et al., 2023; Asare et al., 2024; Sandoval et al., 2023). Existing evaluations often measure correctness and security in isolation. Functional benchmarks emphasize passing unit tests (Chen et al., 2021; Hendrycks et al., 2021; White et al., 2025; Arora et al., 2025), while security benchmarks focus on vulnerability detection without verifying whether the generated code satisfies t
查看原文 · v1
相关研究
-
研究方法上,DUALGAUGE 构建 DUALGAUGE-BENCH,提示来源包括 CodeGuard+、SecurityEval 与 Purple Llama CyberSecEval,任务为语言无关的提示与运行时测试套件,每个任务为同一生成程序配对可执行的功能测试与安全测试,并采用面向覆盖率的构造。评估侧使用基于 LLM 的运行时 oracle,结合候选代码、执行输出、覆盖率轨迹与基准提供的安全期望进行推理;遇到不熟悉的库或 API 时,由具备网络搜索能力的更强 resolver 模型检索文档,轻量模型处理常规评估。
原文依据 · 3
原文引文
curity- functionality benchmarking of specification-only code generation. C Additional Details of DUALGAUGE-BENCH C.1 Benchmark Construction Details Prompt sourcing and preprocessing.We source prompts from existing relevant datasets, including CodeGuard+ (Fu et al., 2024), SecurityEval (Siddiq and Santos, 2022), and Purple Llama CyberSecE- val (Bhatt et al., 2023). These datasets provide diverse coding requirements and security-relevant task templates that have been used in prior evalu- ations, supporting comparability, reproducibility, and alignment with established benchmarks. Be- cause exis
查看原文 · v1原文引文
ion-level cues. Its prompts and runtime test suites are language-agnostic, and each task pairs executable functional and secu- rity tests for the same generated program with coverage-oriented construction. We further justify the language-agnostic design in Appendix A.2. Automated testing and benchmarking sys- tems.Execution-based systems such as YouNameIt (Bouzenia and Pradel, 2025), CXXCrafter (Yu et al., 2025), EnvBench (Eliseeva et al., 2025), and SetupBench (Arora et al., 2025) automate program execution and en- vironment setup, but do not address joint security-functionality benchmarking.
查看原文 · v1原文引文
urce it should not have, whether the execution path reflects a gen- uine defense (Fu and Cai, 2019, 2021).DUALGAUGE meets this requirement with an LLM-based runtime oracle that reasons over the candidate code, execu- tion outputs, coverage traces (Cai and Santelices, 2015b), and benchmark-provided security expecta- tions. To address knowledge gaps about unfamiliar libraries or APIs, a stronger resolver model with web-search capability retrieves relevant documenta- tion when needed—a lighter model handles routine evaluations, and the resolver is invoked only when external knowledge is required.
查看原文 · v1 -
贡献定位是与既有工作区分:YouNameIt、CXXCrafter、EnvBench、SetupBench 等执行型系统自动化程序执行与环境搭建,但不处理安全与功能的联合基准测试;功能基准侧重单元测试通过,安全基准侧重漏洞检测。DUALGAUGE 的贡献在于把两者在同一生成程序上联合度量,并给出可复现的基准与评估流水线。
原文依据 · 3
原文引文
ion-level cues. Its prompts and runtime test suites are language-agnostic, and each task pairs executable functional and secu- rity tests for the same generated program with coverage-oriented construction. We further justify the language-agnostic design in Appendix A.2. Automated testing and benchmarking sys- tems.Execution-based systems such as YouNameIt (Bouzenia and Pradel, 2025), CXXCrafter (Yu et al., 2025), EnvBench (Eliseeva et al., 2025), and SetupBench (Arora et al., 2025) automate program execution and en- vironment setup, but do not address joint security-functionality benchmarking.
查看原文 · v1中文译文
不安全代码(Pearce 等,2022;Majdinasab 等,2024;Tihanyi 等,2025)。有证据表明,开发者可能接受不安全的建议,同时仍相信其安全性,这进一步加剧了这一风险(Perry 等,2023;Asare 等,2024;Sandoval 等,2023)。 现有评估通常分别衡量正确性与安全性。功能性基准侧重于通过单元测试(Chen 等,2021;Hendrycks 等,2021;White 等,2025;Arora 等,2025),而安全性基准侧重于检测漏洞,却不验证生成的代码是否满足……
原文引文
nsecure code (Pearce et al., 2022; Majdi- nasab et al., 2024; Tihanyi et al., 2025). This risk is amplified by evidence that developers may accept insecure suggestions while remaining confident in their safety (Perry et al., 2023; Asare et al., 2024; Sandoval et al., 2023). Existing evaluations often measure correctness and security in isolation. Functional benchmarks emphasize passing unit tests (Chen et al., 2021; Hendrycks et al., 2021; White et al., 2025; Arora et al., 2025), while security benchmarks focus on vulnerability detection without verifying whether the generated code satisfies t
查看原文 · v1中文译文
*,Keyan Guo∗、Suvadra Barua、Jiawei Guo、Abhijeet Pathak、Dinesh Gudimetla、Hongxin Hu、Haipeng Cai† 纽约州立大学布法罗分校 {rupampat,keyanguo,apathak4,dineshgu,jiaweigu,hongxinh,haipengc}@buffalo.edu suvadra.barua21@gmail.com 摘要 大型语言模型(LLM)及基于 LLM 的编程智能体如今被用于根据自然语言规格生成代码,但确保此类代码既功能正确又安全仍是一项挑战。我们提出 DUALGAUGE,这是首个联合评估仅依据规格生成的代码之正确性与安全性的全自动框架,
原文引文
*, Keyan Guo∗, Suvadra Barua, Jiawei Guo, Abhijeet Pathak, Dinesh Gudimetla, Hongxin Hu, Haipeng Cai† University at Buffalo, SUNY {rupampat,keyanguo,apathak4,dineshgu,jiaweigu,hongxinh,haipengc}@buffalo.edu suvadra.barua21@gmail.com Abstract Large language models (LLMs) and LLM- based coding agents are now used to generate code from natural-language specifications, yet ensuring such code is both functionally correct and secure remains a challenge. We present DUALGAUGE, the first fully automated frame- work for jointly evaluating correctness and se- curity of specification-only code generation,
查看原文 · v1
验证资料
-
来源报告的验证数据:DUALGAUGE-BENCH 字段级 Gwet’s AC1 为 0.963,基准级为 0.684;DUALGAUGE executor 的 F1 为 0.910(P 0.963 / R 0.863)。评估器与人工标注的 Spearman ρ 稳定在 0.92–0.98,说明残余评估误差对模型比较影响有限;但可靠性在不同漏洞类别间不均匀,输入验证最强(48 个案例上 F1≈0.92),代码与 SQL 相关类别最弱。统计上使用 5,000 次 bootstrap 的 95% 置信区间,GPT-5 medium Python 为 14.8% [10.6, 19.3],Codestral-22B Python 为 3.7% [1.6, 6.1],两者不重叠;中段排名区间重叠,应视为近似。
原文依据 · 3
原文引文
stable at Spearmanρ= 0.92 –0.98. Residual eval- uator error therefore does not materially affect the model comparison. Reliability is not uniform across vulnerability classes, however: agreement is strongest on input validation (F1≈ 0.92 over 48 cases) and weakest on the small code- and SQL- Component Metric Result DUALGAUGE-BENCH(field-level) Gwet’s AC1 0.963 DUALGAUGE-BENCH(benchmark-level) Gwet’s AC1 0.684 DUALGAUGEexecutor F1 (P / R) 0.910 (0.963 / 0.863)
查看原文 · v1原文引文
ples, benchmarks as the unit of resampling) for secure-pass@1 per (model, language) pair, using the same eligible-sample logic as the main results. The confidence intervals for the strongest model (GPT-5 medium, Python: 14.8% [10.6, 19.3]) and the weakest (Codestral-22B, Python: 3.7% [1.6, 6.1]) do not overlap, confirming that the perfor- mance gap between the top and bottom of the rank- ing is not a sampling artifact. Rankings within the mid-range have overlapping intervals and should be interpreted as approximate. Sign test.For each (model, language) pair, we count the number of benchmarks w
查看原文 · v1原文引文
ularity. E.4 Statistical Robustness We provide two forms of statistical evidence for the main results. Bootstrap confidence intervals.We compute 95% bootstrap confidence intervals (5,000 resam- 28315
查看原文 · v1 -
可执行的防御性核查:复现报告表格只需对已发布结果记录做最终聚合,无需模型 API;重新生成样本需要对应提供方的 API 凭据;§5.1 的评估器一致性数字可通过用制品内验证脚本对已发布 judge 输出与人工标签打分复现。执行侧在隔离容器中进行 agentic 执行,若 MAX 次尝试后仍无稳定运行,候选被标记为 NON_EXECUTABLE,失败运行写入结构化失败标记。日志观察指标可包括 NON_EXECUTABLE 计数、结构化失败标记比例与各 CWE 类别的判定分布。
原文依据 · 3
原文引文
y: sample generation for a given model and language, agentic execution in an isolated container, LLM-based eval- uation over the execution records, and metric ag- gregation at a chosenk. Reproducing the reported tables from the released result records requires only the final aggregation step and no model API ac- cess; regenerating samples requires API credentials for the corresponding providers. The evaluator- agreement numbers in§5.1 are reproduced by scor- ing the released judge outputs against the released human labels with the validation script included in the artifact. Per-task execution
查看原文 · v1原文引文
ut the output is malformed or unparseable (line 16), the harness script is patched to improve output capture (line 17); otherwise the loop exits (lines 18–19). IfMAX attempts are exhausted without a stable run, the candidate is declared NON_EXECUTABLE (lines 23–25). Remaining tests (lines 26–34).Once a stable (E,S) pair is established, the executor reuses it without further agent intervention to run every re- maining test caseT[2],...,T[|T|] (line 27). Suc- cessful runs append their traces to R (line 32); 28311 failed runs append a structured failure marker in- stead (line 30), preserving ful
查看原文 · v1原文引文
stable at Spearmanρ= 0.92 –0.98. Residual eval- uator error therefore does not materially affect the model comparison. Reliability is not uniform across vulnerability classes, however: agreement is strongest on input validation (F1≈ 0.92 over 48 cases) and weakest on the small code- and SQL- Component Metric Result DUALGAUGE-BENCH(field-level) Gwet’s AC1 0.963 DUALGAUGE-BENCH(benchmark-level) Gwet’s AC1 0.684 DUALGAUGEexecutor F1 (P / R) 0.910 (0.963 / 0.863)
查看原文 · v1
处置建议
-
第一步,将代码生成质量门禁从单一功能通过改为功能与安全联合判定:以 DUALGAUGE-BENCH 的威胁模型方式为关键任务固定具体攻击与必须达不到的结果,程序需满足整套测试才算通过。依据是现有评估割裂测量导致功能通过但安全缺失的代码被误判,且 k=5 时多数任务无既正确又安全样本。第二步,优先在输入验证、访问控制、数据泄露与不可信数据处理四类语义缺陷上配置检查,因为基准聚焦这些类别且评估器在输入验证上一致性最强。
原文依据 · 4
中文译文
不安全代码(Pearce 等,2022;Majdinasab 等,2024;Tihanyi 等,2025)。有证据表明,开发者可能接受不安全的建议,同时仍相信其安全性,这进一步加剧了这一风险(Perry 等,2023;Asare 等,2024;Sandoval 等,2023)。 现有评估通常分别衡量正确性与安全性。功能性基准侧重于通过单元测试(Chen 等,2021;Hendrycks 等,2021;White 等,2025;Arora 等,2025),而安全性基准侧重于检测漏洞,却不验证生成的代码是否满足……
原文引文
nsecure code (Pearce et al., 2022; Majdi- nasab et al., 2024; Tihanyi et al., 2025). This risk is amplified by evidence that developers may accept insecure suggestions while remaining confident in their safety (Perry et al., 2023; Asare et al., 2024; Sandoval et al., 2023). Existing evaluations often measure correctness and security in isolation. Functional benchmarks emphasize passing unit tests (Chen et al., 2021; Hendrycks et al., 2021; White et al., 2025; Arora et al., 2025), while security benchmarks focus on vulnerability detection without verifying whether the generated code satisfies t
查看原文 · v1中文译文
类别)。 DUALGAUGE-BENCH 强调可跨语言泛化的语义缺陷——输入验证、访问控制、数据泄露以及对不可信数据的不安全处理——涵盖七个功能领域、90 个 CWE 类别,以及过程内和过程间任务。附录 C.2 提供了一个删节版示例条目;详细统计数据见附录 C.3。 威胁模型。仅包含规格说明的提示不提供部署背景,因此每项安全测试都有自己的威胁模型:它规定一种具体攻击及该攻击不得造成的结果;如果程序阻止了该结果,则通过测试……
原文引文
ategory). DUALGAUGE-BENCHemphasizes semantic flaws that generalize across languages—input validation, ac- cess control, data leakage, and unsafe handling of untrusted data—and spans seven functionality do- mains and 90 CWE categories across intraprocedu- ral and interprocedural tasks. An abridged example item is in Appendix C.2; detailed statistics are in Appendix C.3. Threat model.Specification-only prompts carry no deployment context, so each security test car- ries its own threat model: it fixes a concrete attack and the outcome that attack mustnotachieve, and the program passes if the forb
查看原文 · v1原文引文
306, 307, 613, 614, 732, 749 Table 18: CWE group definitions used in Figure 4. marginal gain falls from+5.3 to +2.0 points across successivek. Even atk= 5 , 76%, 85%, and 91% of tasks respectively still havenosample that is both correct and secure. Decomposing the joint rate is instructive: GPT-5 medium and Claude Opus 4.7 are nearly tied on functional pass@5 (44.6% vs. 44.0%) yet differ sharply on secure@5 (53.6% vs. 36.9%). Two models that look equally capable under functional evaluation are far apart once secu- rity is also required—the paper’s thesis in a single 28317 Model @1 @2 @3 @4 @
查看原文 · v1原文引文
stable at Spearmanρ= 0.92 –0.98. Residual eval- uator error therefore does not materially affect the model comparison. Reliability is not uniform across vulnerability classes, however: agreement is strongest on input validation (F1≈ 0.92 over 48 cases) and weakest on the small code- and SQL- Component Metric Result DUALGAUGE-BENCH(field-level) Gwet’s AC1 0.963 DUALGAUGE-BENCH(benchmark-level) Gwet’s AC1 0.684 DUALGAUGEexecutor F1 (P / R) 0.910 (0.963 / 0.863)
查看原文 · v1 -
第三步,模型选型与合入审查使用联合指标而非仅功能指标,参考 GPT-5 medium 与 Claude Opus 4.7 在功能接近而 secure@5 差距明显的证据;对中段排名按近似处理,因置信区间重叠。第四步,监测执行侧 NON_EXECUTABLE 计数与结构化失败标记比例,并对评估器判定做抽样人工复核,重点覆盖代码与 SQL 相关等一致性较弱的类别。第五步,回归验证时用已发布结果记录做聚合复现,并用制品内验证脚本对 judge 输出与人工标签打分,确认评估器一致性后再用于门禁。
原文依据 · 5
原文引文
306, 307, 613, 614, 732, 749 Table 18: CWE group definitions used in Figure 4. marginal gain falls from+5.3 to +2.0 points across successivek. Even atk= 5 , 76%, 85%, and 91% of tasks respectively still havenosample that is both correct and secure. Decomposing the joint rate is instructive: GPT-5 medium and Claude Opus 4.7 are nearly tied on functional pass@5 (44.6% vs. 44.0%) yet differ sharply on secure@5 (53.6% vs. 36.9%). Two models that look equally capable under functional evaluation are far apart once secu- rity is also required—the paper’s thesis in a single 28317 Model @1 @2 @3 @4 @
查看原文 · v1原文引文
ples, benchmarks as the unit of resampling) for secure-pass@1 per (model, language) pair, using the same eligible-sample logic as the main results. The confidence intervals for the strongest model (GPT-5 medium, Python: 14.8% [10.6, 19.3]) and the weakest (Codestral-22B, Python: 3.7% [1.6, 6.1]) do not overlap, confirming that the perfor- mance gap between the top and bottom of the rank- ing is not a sampling artifact. Rankings within the mid-range have overlapping intervals and should be interpreted as approximate. Sign test.For each (model, language) pair, we count the number of benchmarks w
查看原文 · v1原文引文
ut the output is malformed or unparseable (line 16), the harness script is patched to improve output capture (line 17); otherwise the loop exits (lines 18–19). IfMAX attempts are exhausted without a stable run, the candidate is declared NON_EXECUTABLE (lines 23–25). Remaining tests (lines 26–34).Once a stable (E,S) pair is established, the executor reuses it without further agent intervention to run every re- maining test caseT[2],...,T[|T|] (line 27). Suc- cessful runs append their traces to R (line 32); 28311 failed runs append a structured failure marker in- stead (line 30), preserving ful
查看原文 · v1原文引文
y: sample generation for a given model and language, agentic execution in an isolated container, LLM-based eval- uation over the execution records, and metric ag- gregation at a chosenk. Reproducing the reported tables from the released result records requires only the final aggregation step and no model API ac- cess; regenerating samples requires API credentials for the corresponding providers. The evaluator- agreement numbers in§5.1 are reproduced by scor- ing the released judge outputs against the released human labels with the validation script included in the artifact. Per-task execution
查看原文 · v1原文引文
stable at Spearmanρ= 0.92 –0.98. Residual eval- uator error therefore does not materially affect the model comparison. Reliability is not uniform across vulnerability classes, however: agreement is strongest on input validation (F1≈ 0.92 over 48 cases) and weakest on the small code- and SQL- Component Metric Result DUALGAUGE-BENCH(field-level) Gwet’s AC1 0.963 DUALGAUGE-BENCH(benchmark-level) Gwet’s AC1 0.684 DUALGAUGEexecutor F1 (P / R) 0.910 (0.963 / 0.863)
查看原文 · v1
模型与引文记录
- 模型
- deepseek-flash
- 生成时间
- 记录编号
- REQ-62f16ac56b194ec48dd9eeb3989341bd
- 分析原文
- 查看原文 · v1
关联全文
展开关联全文收起关联全文
DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agents [PDF pages 1-21; part 1/2] · PDF 第 1/2 段 · 第 1–21 页
v1 · 95433 字符 · 打开本段原文页面
Findings of the Association for Computational Linguistics: EMNLP 2026, pages 28295–28319 October 24-29, 2026 ©2026 Association for Computational Linguistics DUALGAUGE: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agents Rupam Patir*, Keyan Guo∗, Suvadra Barua, Jiawei Guo, Abhijeet Pathak, Dinesh Gudimetla, Hongxin Hu, Haipeng Cai† University at Buffalo, SUNY {rupampat,keyanguo,apathak4,dineshgu,jiaweigu,hongxinh,haipengc}@buffalo.edu suvadra.barua21@gmail.com Abstract Large language models (LLMs) and LLM- based coding agents are now used to generate code from natural-language specifications, yet ensuring such code is both functionally correct and secure remains a challenge. We present DUALGAUGE, the first fully automated frame- work for jointly evaluating correctness and se- curity of specification-only code generation, supported byDUALGAUGE-BENCH, a language- agnostic benchmark of 307 coding tasks each paired with functional and security tests derived from the same specification. Evaluating 10 representative LLMs across Python, C++, and JavaScript, we find that functional correctness substantially overestimates reliable code gen- eration: even the strongest model remains be- low 15% joint security-functionality success in every language. Common model-side factors— scale, extended thinking, quantization, instruc- tion tuning, and code specialization—do not reliably improve joint performance, suggest- ing secure-and-correct code generation does not simply emerge from stronger coding capa- bility. Evaluation of 3 leading coding agents (Codex, OpenHands, and Claude Code) shows that iterative scaffolding is not a reliable rem- edy on specification-only tasks: results are strongly scaffold-dependent, with two of the three agents failing to outperform a compara- ble direct model. A qualitative audit reveals that these failures concentrate at the output contract boundary and in guards that exist but are insufficient—patterns that only joint bench- marking reliably exposes. 1 Introduction Large language models (LLMs) and LLM-based coding agents have become primary AI tools for generating code from natural-language specifica- tions (Mohamed et al., 2025; Ziegler et al., 2024; Li et al., 2025a; Wang et al., 2025). As AI-generated *Equal contribution †Corresponding author snippets are integrated into real codebases (Fu et al., 2025), evaluating whether the generated code is bothfunctionally correct and secure becomes essen- tial. Functional correctness has become the domi- nant criterion for code-generation evaluation (Chen et al., 2021; Hendrycks et al., 2021; Austin et al., 2021; Li et al., 2022b), but it alone is insufficient: prior studies show that AI coding assistants can generate insecure code (Pearce et al., 2022; Majdi- nasab et al., 2024; Tihanyi et al., 2025). This risk is amplified by evidence that developers may accept insecure suggestions while remaining confident in their safety (Perry et al., 2023; Asare et al., 2024; Sandoval et al., 2023). Existing evaluations often measure correctness and security in isolation. Functional benchmarks emphasize passing unit tests (Chen et al., 2021; Hendrycks et al., 2021; White et al., 2025; Arora et al., 2025), while security benchmarks focus on vulnerability detection without verifying whether the generated code satisfies the intended functional- ity (Siddiq and Santos, 2022; Hajipour et al., 2024; Li et al., 2025b). Recent secure-code-generation work often inherits this separation, evaluating se- curity and functionality on different datasets (He and Vechev, 2023; He et al., 2024; Xu et al., 2025; Nazzal et al., 2024; Liu et al., 2025). This separa- tion is misleading:a program that avoids a target vulnerability but violates the specification is not useful, while a functionally correct program that violates security constraints remains unsafe. Joint evaluation is hard as prior benchmarks rarely pair functional and security tests for the same specification (Wang et al., 2023; Siddiq and Santos, 2022; Hajipour et al., 2024; Pearce et al., 2022; Li et al., 2025b; Fu et al., 2024), and automating security evaluation is non-trivial: static analysis is imprecise (Lipp et al., 2022; Li et al., 2023, 2024), dynamic oracles are narrowly scoped (Vero et al., 2025; Cai et al., 2014), and manual inspection does not scale (Pearce et al., 2022; Wang et al., 2023). 28295
… 1 import os 2 def load_file(path): 3 full_path = os.path.join( "./test_dir", path) 4 try: 5 with open(full_path, "r") as f: 6 return f.read() 7 except OSError: 8 return None in "hello.txt" out "Hello World" trace 1→2→3→4→5→6 in "../etc/passwd" out None exit 0 trace 1→2→3→4→5→7→8 load_file(path) ./test_dir/ None in "hello.txt" exp "Hello World" in .. /etc/passwd exp reject input 3 base = os.path.realpath( "./test_dir") 4 full_path = os.path.realpath( os.path.join(base, path)) 5 if not full_path.startswith( base + os.sep): 6 return None # reject in "hello.txt" out "Hello World" trace 1→2→3→4→5→7→8→9 in "../etc/passwd" out None exit 0 trace 1→2→3→4→5→6 <lines 8-11 same as Sample 1’s lines 5-8> 1 import os 2 def load_file(path): Figure 1: Motivating example for semantic runtime security evaluation. Two generated implementations satisfy the functional test, but only the second satisfies the security requirement. Both return None with exit code 0 on the adversarial input, so output matching alone cannot distinguish them. The execution trace reveals the difference: the vulnerable implementation attempts file access before failing, whereas the secure implementation rejects the unsafe path before any file access. Thus, semantic judgment over the execution trace can serve as the security-test oracle. Beyond paired test construction, joint evalua- tion also introduces an evaluation-oracle challenge: deciding whether a security test passes often can- not be reduced to exact output matching. Figure 1 makes this concrete. Given the same specification, a vulnerable and a secure implementation return identical outputs and exit codes even on the ad- versarial input; only their execution traces reveal that the first reaches the file system before failing while the second rejects the unsafe path outright. Functional tests, which judge correctness by out- put matching (Cai et al., 2015; Cai and Santelices, 2015a), are therefore structurally blind to this class of failure; security evaluation requires semantic reasoning over runtime behavior. The benchmark setting introduces another gap. Most benchmarks are tied to specific languages or completion-based settings (Shen et al., 2025; Peng et al., 2025; Yang et al., 2024; Chen et al., 2025; Zhao et al., 2025b; Vero et al., 2025), over- lookingspecification-only code generationwhere a model implements a function or module from a natural-language description alone. These motivate a language-agnostic, specification-only benchmark that enhances reusability, enables cross-language comparison, and exposes risks that contextualized settings may obscure. We elaborate on these gaps in Appendix A, including a detailed treatment of why security evaluation requires semantic judg- ment rather than output matching (Appendix A.3). Our work.We presentDUALGAUGE, afully au- tomatedbenchmarking system for joint security- functionality evaluation of specification-only code generation. Given a specification and a target LLM or agent,DUALGAUGE 1 generates candidate code on the LLM/agent for the specification, 2 executes it against paired functional and security tests in an isolated environment, and 3 reports structured results with execution traces and aggregate met- rics.DUALGAUGEcombines anagentic execution engine, which stabilizes execution without alter- ing model-generated logic, with anLLM-based evaluator, which checks runtime behavior against benchmark-provided security expectations and pre- defined oracles. To support this evaluation, we cu- rateDUALGAUGE-BENCH, a language-agnostic bench- mark of 307 specification-only coding tasks, each pairing coverage-guided functional tests with secu- rity tests derived from OWASP (OWASP Founda- tion, 2024) and CERT (SEI CERT Division, 2025) principles, constructed through a human-LLM co- creation process.DUALGAUGE-BENCHis currently instantiated across three top popular programming languages, Python, C++, and JavaScript. Results.We evaluate 10 representative LLMs on all 307DUALGAUGE-BENCHtasks in Python, C++, and JavaScript, and separately evaluate 3 coding agents—Codex, OpenHands, and Claude Code—on the same tasks. To test whether any model-side factor closes the gap, we sweep six axes on Python—access type, scale, quantization, 28296
extended thinking, instruction tuning, and code specialization—for 42 direct-model configurations in total, the 10 above included. The central finding is that functional correctness is a poor proxy for safe code generation: even the strongest model sat- isfies both constraints on fewer than 15% of tasks in every language, despite reaching nearly 39% func- tional pass rate on Python. This gap does not close with conventional scaling levers. No factor reliably improves the joint metric: each shifts functional and security metrics differently depending on the model family—indicating that secure generation is not an emergent property of stronger coding ca- pability alone. For coding agents, scaffolding is not a reliable remedy on specification-only tasks and its effect depends heavily on the scaffold: two of the three agents underperform a comparable di- rect model, and the feedback signals agents rely on are absent when there is no existing codebase or test runner to interact with. Together, these results suggest thatagentic coding is not yet a remedy for secure code generation: multi-turn refinement, tool use, and feedback do not automatically overcome the core challenge of producing code that is both functionally correct and secure. Contributions.Our work complements prior benchmarks by targeting a distinct goal: automati- cally evaluating whether LLMs and coding agents can generate code that is both correct and secure forthe same natural-language specification. Our contributions are: • DUALGAUGE-BENCH, the first language-agnostic benchmark that pairs each specification-only prompt with dual, coverage-enforced functional and security test suites (§3); • DUALGAUGE, a fully automated benchmarking sys- tem for joint security-functionality evaluation, combining agentic execution with semantic run- time security evaluation (§4); • An open-source implementation and valida- tion ofDUALGAUGE-BENCHandDUALGAUGE, 1, demonstrating benchmark quality and automated- evaluation reliability (§5.1); • A cross-language measurement study of 10 rep- resentative LLMs across Python, C++, and JavaScript, revealing substantial gaps, trade-offs, and failure modes in secure specification-only code generation (§5.2,§5.3); 1Our code and data are available at https://github.c om/SRestLabUB/DualGauge and interactive dashboard at https://srestlabub.github.io/DualGauge/. • To our knowledge, the first evaluation of coding agents for secure specification-only code gener- ation, showing that agentic scaffolding such as multi-turn refinement, tool use, and feedback do not yet reliably overcome the joint functionality- security challenge (§5.2,§5.3). 2 Related Work Benchmarks for secure code generation.We positionDUALGAUGE-BENCHas complementary to existing benchmarks along four dimensions:paired executable tests,pure specification-only generation, language-agnostic design, andcoverage-oriented construction. Functional code-generation bench- marks focus on behavioral correctness (Chen et al., 2021; Austin et al., 2021; Hendrycks et al., 2021; White et al., 2025), while early security bench- marks mainly assess vulnerability presence or miti- gation without checking whether the same gener- ated program remains functionally correct (Siddiq and Santos, 2022; Hajipour et al., 2024; Wang et al., 2023; Fu et al., 2024; Li et al., 2025b; Bhatt et al., 2023). Recent benchmarks add both functional and security checks (Yang et al., 2024; Peng et al., 2025; Vero et al., 2025; Shen et al., 2025; Chen et al., 2025; Zhao et al., 2025b), but they typically target code completion, language-specific function tasks, repository-level completion/editing, vulnerability- introduction scenarios, or framework-conditioned backend development. In contrast, as Table 1 shows,DUALGAUGE-BENCH targetspure specification-only generation: each task is a natural-language specification, without partial code, function signatures, arguments, repos- itory context, fixed APIs, framework scaffolding, or other implementation-level cues. Its prompts and runtime test suites are language-agnostic, and each task pairs executable functional and secu- rity tests for the same generated program with coverage-oriented construction. We further justify the language-agnostic design in Appendix A.2. Automated testing and benchmarking sys- tems.Execution-based systems such as YouNameIt (Bouzenia and Pradel, 2025), CXXCrafter (Yu et al., 2025), EnvBench (Eliseeva et al., 2025), and SetupBench (Arora et al.,
- automate program execution and en-
vironment setup, but do not address joint security-functionality benchmarking. Recent peer benchmarks increasingly use dynamic testing, yet their security oracles are often tied to sanitizer 28297
Benchmark SecTest FuncTest Paired Pure NL Spec. Lang.-agn. Cov. Pearce et al. (Pearce et al., 2022) SecurityEval (Siddiq and Santos, 2022) CodeLMSec (Hajipour et al., 2024) SecuCoGen (Wang et al., 2023) ● SafeGenBench (Li et al., 2025b) CodeGuard+ (Fu et al., 2024) LiveBench (White et al., 2025) SecCodePLT (Yang et al., 2024) ● ● ● CWEval (Peng et al., 2025) SecRepoBench (Shen et al., 2025) SecureAgentBench (Chen et al., 2025) ● SUSVIBES (Zhao et al., 2025b) BaxBench (Vero et al., 2025) DUALGAUGE-BENCH Table 1: Benchmark comparison on using dynamic secu- rity (SecTest) and functional (FuncTest) tests paired for the same coding task (Paired) purely specified by natu- ral language (Pure NL Spec.), programming-language agnostic (Lang.-agn.) design/nature, and coverage en- forcement (Cov.), including partial support (●). reports, expert-crafted exploits, repository-specific tests, or framework-specific behaviors (Vero et al., 2025; Shen et al., 2025; Chen et al., 2025; Zhao et al., 2025b). In particular, BaxBench (Vero et al.,
- is the closest prior work to ours, but targets
fixed backend APIs/frameworks and relies on manually created security test inputs for specific CWEs. CWEval (Peng et al., 2025) also evaluates functionality and security on the same tasks, but is only for language-specific function tasks. DUALGAUGEfills these gaps end-to-end by execut- ing generated programs in isolated environments via anautomatedruntime oracle to judge functional and security behaviors from execution outcomes. To our knowledge,DUALGAUGEis the first fully automated system for joint security-functionality evaluation of specification-only code generation. We further justify this design in Appendix A.1 and discuss related work more broadly in Appendix B. 3 DUALGAUGE-BENCH We buildDUALGAUGE-BENCHaround specification- only task representation, paired functional/security testing, and coverage over functional requirements and security-relevant behaviors,as per the specifi- cationrather than implementation details. 3.1 Task Design Each benchmark item consists of a natural- languagecode-generation promptpaired with a functional test suiteand asecurity test suite. The prompt specifies the functionality to be imple- mented without code snippets, function signatures, or language-specific constraints, making each item reusable across target languages and models. Func- tional tests check whether the generated program satisfies the requested behavior (input and expected output); security tests check whether it avoids in- secure behaviors relevant to the task (input, ex- pected security behavior, and CWE category). DUALGAUGE-BENCHemphasizes semantic flaws that generalize across languages—input validation, ac- cess control, data leakage, and unsafe handling of untrusted data—and spans seven functionality do- mains and 90 CWE categories across intraprocedu- ral and interprocedural tasks. An abridged example item is in Appendix C.2; detailed statistics are in Appendix C.3. Threat model.Specification-only prompts carry no deployment context, so each security test car- ries its own threat model: it fixes a concrete attack and the outcome that attack mustnotachieve, and the program passes if the forbidden effect does not occur—judged from what the program did, not how it was written. The test does not prescribe a de- fense; rejecting, sanitizing, canonicalizing, or dele- gating to a safe API all count, provided the attack fails. For the attacks we test there is no deployment in which the attack succeeding is acceptable, so the required outcome does not depend on a use case, which makes the ground truth definite one attack at a time (Appendix A.3). 3.2 Benchmark Construction We curate prompts from CodeGuard+ (Fu et al., 2024), SecurityEval (Siddiq and Santos, 2022), and Purple Llama CyberSecEval (Bhatt et al., 2023), converting each into a specification-only natural- language requirement by removing implementation details while preserving the intended functional- ity and security-relevant behavior. This process yields 307 prompts, and we release the mapping from each task to its source record (Appendix F.1). Because the sources supply code stubs or language- specific prompts rather than specifications, the rewriting is extensive: the median task shares 0.7% of its verbatim five-word sequences with its source, and 78% share under 10%. For each, we construct paired functional and security test suites through a human-LLM co-creation process: LLMs (GPT-5, Claude-4.5, and DeepSeek-R1) propose candidate tests, and human raters validate, consolidate, and extend them. Functional tests are guided by bound- ary value analysis and equivalence-class partition- ing; security tests are guided by OW ASP (OW ASP Foundation, 2024) and CERT (SEI CERT Division,
- principles. Both suites are derived from the
same specification but evaluate complementary re- 28298
1 Phase 1 Sample Generation Candidates in Python Extract & normalize candidate code programs Query Target LLM Candidates in C++ Candidates in JavaScript 2 Phase 2 Agentic Execution Environment (e.g., missing package) Script (e.g., wrong Invocation) Code (e.g., logic error àGive up) 2.1. Understand & Plan Failure Classifica-on Direct Execution Service (HTTP, DB, ...) 2.2. Execute & Stabilize (on first test) Isolate Container Run & Observe Diagnose Failure Fix Env./ Script 2.3. Batch Execution (remaining tests) Collect program outputs and coverage traces 3 Phase 3 LLM-Based Runtime Evaluation Functional Oracle (Exact Matching) Security Oracle (LLM Judgment) Candidate Code Execution Output Coverage Trace Expected Security Behavior Per-test pass / fail (functional and security) Knowledge Resolver (if needed) LLM Oracle 4 Phase 4 Result Aggregation Per-Problem Aggregation (over k samples) •pass@k (functional correctness) •secure@k (security correctness) •secure-pass@k (both functional and secure) Global Metrics (across all problems) •PR (Pass Rate): % functional test cases passed •SPR (Secure Pass Rate): % security test cases passed Structured results (JSON / CSV) •Program output vs. Expected output •Per-test pass / fail DualGauge- Bench Prompt / Specification Functional Tests Input → Expected output Security Tests Input → Expected security behavior Target LLM or Agent Figure 2: Overview ofDUALGAUGE. The system takes a target LLM and benchmark items fromDUALGAUGE-BENCH, generates candidate code, executes it through an agentic executor, evaluates functional outputs and security behaviors with runtime oracles, and aggregates functionality, security, and joint security-functionality metrics. quirements, ensuring that functional and security judgments are grounded in a shared task definition. Details and prompt templates are in Appendix C.1. 4 DUALGAUGE We operationalizeDUALGAUGE-BENCHthroughDU- ALGAUGE, a fully automated benchmarking sys- tem for joint security-functionality evaluation of specification-only code generation. Given a target model and a benchmark item fromDUALGAUGE- BENCH,DUALGAUGEgenerates code, executes it against paired functional and security tests, and outputs structured results containing execution evi- dence, per-test verdicts, and functionality, security, and joint security-functionality metrics. 4.1 System Overview Figure 2 illustrates the four-phase workflow ofDU- ALGAUGE: Phase 1 samples candidates for a speci- fication and target language, Phase 2 runs each in an isolated container while recording outputs and coverage traces, Phase 3 judges those traces against the paired tests, and Phase 4 aggregates the verdicts. The two core components are theagentic executor (Phase 2) and theLLM-based runtime evaluator (Phase 3), which address the main automation chal- lenges of heterogeneous execution and semantic security judgment, respectively. 4.2 Sample Generation Given a benchmark prompt,DUALGAUGEqueries the target model to retrievek independently sampled code candidates using fixed sampling parameters for comparability. Because model outputs may include explanations or formatting,DUALGAUGEap- plies a lightweight extraction step to isolate the candidate program while preserving associated metadata. Since benchmark prompts are language- agnostic, a target language is appended to instanti- ate each item in a concrete evaluation setting. 4.3 Agentic Execution Following sample generation,DUALGAUGEexe- cutes each generated candidate program through an LLM-guided execution model that gives every sam- ple a consistent opportunity to run without manual intervention or any change to the generated logic. The executor first analyzes the candidate code to determine its execution pattern. Generated pro- grams typically fall into two categories:direct- executionprograms, which can be invoked from the command line or standard input, andservice- orientedprograms, which require server startup and external requests. Based on this analysis, the agent constructs an execution script that handles invocation, input delivery, and output capture. The script is then run in an isolated environment on an initial test case. If execution fails, the agent classifies the failure into environment, script, or code issues. Only environment and script issues trigger repair actions, such as installing required packages, adjusting invocation logic, or fixing out- put capture. Code issues are not repaired. This bounded repair loop continues until execution sta- bilizes or the candidate is deemed non-executable. Once stabilized on the first test, the same en- vironment and execution script are reused for all remaining tests without further agent intervention. This design separates execution-time support from code correction: the agent helps make the program executable, but does not improve the generated so- lution itself. The final output is a set of program 28299
outputs and statement-coverage traces. Algorithm 1 in Appendix D provides the full procedure. 4.4 LLM-Based Runtime Evaluation Functional evaluation compares captured output against the benchmark’s expected output, produc- ing a binary verdict. Security evaluation requires a fundamentally different oracle: on normal inputs, a vulnerable and a secure implementation are of- ten observationally equivalent, and the difference only surfaces on adversarial inputs—e.g., a path- traversal attempt, a malicious payload, an injection string—where even the output alone may not reveal whether the code defended itself (Figure 1). Judging security therefore requires reasoning aboutwhat the program did: whether it validated the input, whether it accessed a resource it should not have, whether the execution path reflects a gen- uine defense (Fu and Cai, 2019, 2021).DUALGAUGE meets this requirement with an LLM-based runtime oracle that reasons over the candidate code, execu- tion outputs, coverage traces (Cai and Santelices, 2015b), and benchmark-provided security expecta- tions. To address knowledge gaps about unfamiliar libraries or APIs, a stronger resolver model with web-search capability retrieves relevant documenta- tion when needed—a lighter model handles routine evaluations, and the resolver is invoked only when external knowledge is required. Algorithm 2 in Appendix D provides the full procedure. 4.5 Result Aggregation The final phase aggregates pass/fail judgments into per-problem and benchmark-level scores. Givenn sampled solutions for a benchmark problem, with c functionally correct, s securely correct, and sp satisfying both,DUALGAUGEcomputes: pass@k=E x [ 1− ( n−c k ) / ( n k )] , secure@k=E x [ 1− ( n−s k ) / ( n k )] , secure-pass@k=E x [ 1− ( n−sp k ) / ( n k )] measuring functional correctness, security correct- ness, and joint security-functionality performance, respectively. It also computes PR=P func/Tfunc (Pass Rate) and SPR=P sec/Tsec (Secure Pass Rate), the proportion of functional and security test cases passed across the benchmark. We use p@1, s@1, and sp@1 as shorthands for pass@1, secure@1, and secure-pass@1 throughout. The two families differ in granularity: PR and SPR pool individual test cases and therefore award partial credit, whereas p@1 and sp@1 are all-or-nothing per task, crediting only an implementation that satisfies its whole suite. 5 Evaluation We aim to answer three research questions: RQ1 AreDUALGAUGE-BENCHandDUALGAUGEboth reliable for evaluating specification-only coding? RQ2 How do current LLMs and coding agents per- form under joint security-functionality evaluation? RQ3What mechanisms drive failures? 5.1 RQ1: Reliability Validation We validate both the benchmark artifacts and the automated evaluation pipeline against human- reviewed ground truth; Table 3 summarizes the re- sults. ForDUALGAUGE-BENCH, field-level agreement is strong, reflecting consistent annotator judgments across individual specification, functionality, and security components; benchmark-level agreement is lower, as task validity requires all nine fields to pass jointly. ForDUALGAUGE, the executor achieves high precision and F1, indicating it rarely accepts unreliable executions, while the evaluator achieves closely matched precision and recall, erring slightly toward flagging secure behavior as insecure rather than the reverse—a conservative direction that can- not inflate the security results we report. These results support usingDUALGAUGEas a scalable eval- uation pipeline; we nonetheless treat its outputs as benchmark estimates rather than substitutes for human security review. Full validation details and the nine-field rubric are in Appendix E.1. Evaluator sensitivity.Our evaluator (GPT-5 nano) is smaller than several models it grades, so we test whether a stronger or cross-family judge would reach different verdicts. We hand-labeled a fresh set of 307 cases (154 functional, 153 se- curity; 107 Python, 100 C++, 100 JavaScript) and re-judged them with two stronger evaluators. As Table 3 shows, the three judges score almost identi- cally against the human labels, and they agree with each other at Cohen’s κ= 0.74 –0.79. Security judging here is a bounded decision—the evaluator is given the code, the attack input, the execution trace, and the required outcome, and decides only 28300
Python C++ JavaScript Model PR SPR p@1 s@1 sp@1 PR SPR p@1 s@1 sp@1 PR SPR p@1 s@1 sp@1 gpt-5-medium 73.2 72.7 38.6 34.5 14.8 54.1 73.3 19.8 30.4 8.4 47.9 72.9 20.0 32.4 8.0 gpt-4.1 65.2 68.4 31.3 23.4 8.7 49.0 63.5 19.5 23.2 5.9 42.9 63.5 16.1 23.3 4.5 claude-opus-4-7-think-on 70.3 59.6 33.9 24.0 10.2 52.6 63.8 19.2 24.9 5.0 50.4 60.8 24.3 28.3 7.0 claude-sonnet-4-5-think-off 68.5 57.1 31.3 20.2 8.4 49.0 59.4 19.0 23.6 5.4 46.8 56.6 21.4 23.6 6.6 claude-haiku-4-5 40.8 55.2 17.8 18.8 6.5 42.6 57.8 18.2 22.7 5.3 32.3 50.8 15.5 15.9 2.9 llama-3.1-8b-instruct-bf16 48.5 49.2 22.5 14.4 5.1 15.1 35.4 4.5 5.9 0.9 30.3 44.8 9.0 12.8 2.3 qwen3-14b 60.2 56.5 27.4 17.5 5.6 24.8 46.1 12.3 11.5 1.5 37.5 55.9 13.9 18.7 3.0 qwen2.5-coder-32b-instruct 64.2 56.5 29.5 20.3 7.2 27.7 47.1 9.8 15.4 3.0 39.7 50.1 13.0 14.8 2.2 codestral-22b-v0.1 63.7 49.8 27.5 14.8 4.5 23.3 41.5 7.0 10.1 1.6 37.6 48.8 10.7 12.5 0.0 gemma-3-27b-it 61.5 56.6 27.3 19.6 6.9 28.3 45.5 8.1 13.5 1.2 36.6 52.2 13.8 18.8 2.7 Table 2: Headline performance across the 10 main models and three languages. All metrics are percentages; shorthands are defined in §4.5. whether the attack succeeded—which is why ad- ditional judge capacity yields little. Notably, the strictest judge (Claude Opus 4.7) has thehighest precision and lowest recall: its errors are over-flags of secure code, not missed vulnerabilities, so sub- stituting it would widen the reported security gap rather than narrow it. Re-evaluating the 153 se- curity cases under four prompt variants leaves F1 within 0.84–0.88 (κ= 0.70 –0.82 against the base- line prompt), so the result is not an artifact of one prompt wording. Effect on model rankings.Human labels ex- ist only for these 307 cases, so we propagate the measured error profiles of all three judges and the prompt variants through the full leaderboard, re- scoring every model 2,000 times per profile. The top-ranked model is unchanged in 100% of test- level simulations and 98.7–100% of benchmark- level simulations, and the overall ordering remains stable at Spearmanρ= 0.92 –0.98. Residual eval- uator error therefore does not materially affect the model comparison. Reliability is not uniform across vulnerability classes, however: agreement is strongest on input validation (F1≈ 0.92 over 48 cases) and weakest on the small code- and SQL- Component Metric Result DUALGAUGE-BENCH(field-level) Gwet’s AC1 0.963 DUALGAUGE-BENCH(benchmark-level) Gwet’s AC1 0.684 DUALGAUGEexecutor F1 (P / R) 0.910 (0.963 / 0.863) DUALGAUGEevaluator, by judge GPT-5 nano (ours) F1 (P / R)0.895(0.906 / 0.885) GPT-5 medium F1 (P / R)0.906(0.901 / 0.911) Claude Opus 4.7 (thinking) F1 (P / R)0.891(0.942 / 0.845) Table 3: Reliability validation results.DUALGAUGE- BENCHquality is measured by inter-annotator agree- ment (Gwet’s AC1) at the field and benchmark level; DUALGAUGEcomponents by F1, precision, and recall against human-curated ground truth. injection subsets (F1≈ 0.67–0.75 over 5–6 cases each). We report this as a per-class reliability map (Appendix E.2) rather than imply uniform accuracy, and note that the low points are small-sample. 5.2 RQ2: Performance Under Joint Evaluation Experimental setup.We evaluate 10 LLMs across Python, C++, and JavaScript on 307 DUALGAUGE-BENCHprompts: GPT-5 medium, GPT-4.1, Claude Opus 4.7 (with thinking), Claude Sonnet 4.5, Claude Haiku 4.5, Llama-3.1- 8B-Instruct, Qwen3-14B, Qwen2.5-Coder-32B- Instruct, Codestral-22B, and Gemma-3-27B-IT. We also evaluate 3 coding agents: Codex (GPT-5.4), OpenHands (GPT-5.4), and Claude Code (Opus 4.7). Each generates one sample per prompt (k=
- at temperature = 0; the executor and evalua-
tor use GPT-5 nano. Sweeping access type, scale, quantization, extended thinking, instruction tuning, and code specialization extends this to 42 direct- model configurations, each evaluated on Python only (agents excluded; Appendix E.5). Headline results.Table 2 shows that even the strongest model remains below 15% secure-pass@1 in every language, confirm- ing that functional correctness is a poor proxy for joint performance. secure@1 consistently exceeds secure-pass@1 across all models and languages, showing that modelscanproduce secure code — they simply do not do soconsistentlyacross all test cases. The bottleneck is coverage, not capability: models satisfy some security requirements some of the time, but fail to cover all of them reliably in a single implementation. Effect of model-side factors.Figure 3 shows that none of the five model-side factors provides a reliable path to better joint performance. Scaling 28301
0.6B 4B 8B 14B 32B 0 20 40 60 80 100Score (%) Qwen3 (a) Scale BF16 FP8 INT8 AWQ-INT4GPTQ-INT4 0 20 40 60 80 100Score (%) Qwen3 (b) Quantization Minimal High Off On Off On 0 20 40 60 80 100Score (%) GPT-5 Opus 4.7 Qwen3 (c) Extended thinking GeneralCoderGeneralCoderGeneralCoderGeneralCoder 0 20 40 60 80 100Score (%) Qwen2.5 Qwen3 Mistral Llama (d) Code specialization Instruct Base Instruct Base Instruct Base Instruct Base 0 20 40 60 80 100Score (%) Qwen2.5 Llama Mistral Gemma (e) Instruction tuning Figure 3: Effect of five model-side factors on Python performance. Markers: •pass@1 , •secure@1 , •secure-pass@1 ,◦PR ,◦SPR . Each subfigure isolates one factor; vertical lines separate model families. Base models for Mistral and Gemma produced no parseable output under specification-only prompting. Resource / DoS (n=348) Path & File Access (n=660) Serialization & XML (n=270) Cryptography (n=258) Access & Disclosure (n=132) Input Validation (n=2,100) Network Safety (n=297) Injection (n=1,542) 0% 25% 50% 75% 100%Security Pass Rate (SPR) Python C++ JavaScript Figure 4: Distribution of SPR across the 10 evaluated models per CWE group and language. Box plots show median, interquartile range, and outliers. Groups are ordered by increasing median SPR across all languages. improves functional fluency but security coverage plateaus well before the largest model sizes, sug- gesting the two capabilities are not coupled. Ex- tended thinking, quantization, and code specializa- tion each shift the functional and security metrics differently across model families. If security fail- ures reflected missing knowledge, targeted inter- ventions such as extended reasoning or code spe- cialization would be expected to help; the fact that they do not reinforces that the problem is consistent application across requirements, not awareness of them. Detailed analyses are in Appendix E.5. Security performance by vulnerability class. The per-category breakdown in Figure 4 rein- forces the coverage interpretation: even where models clearly know the relevant defensive pat- terns, strong SPR does not reliably translate into secure-pass@1. A model that handles the com- mon injection vector can still miss an edge case the suite exercises—passing some tests in a category is not the same as covering all of them. The weak- est categories (Resource/DoS, Path & File Access) make this distinction starkest: defenses are partial, leaving whole classes of security invariants uncov- ered. Full per-CWE results are in Appendix E.6. Coding agents.Comparing OpenHands and Codex—both backed by GPT-5.4—reveals that the agentic loopactively degradesperformance: Open- Hands underperforms Codex on every metric and in every language. Inspection of iteration traces reveals the mechanism: over half of all agent ac- tions are spent on repository-oriented overhead— listing directories, searching for AGENTS.md, up- dating task trackers—behaviors calibrated to navi- gate existing codebases that yield no useful signal in an empty workspace. When agents do act on the implementation, they substitute self-generated tests for ground-truth feedback, submitting once those pass without querying the benchmark’s actual requirements—on Python problems where Open- Hands revised its code (15% of cases), the gap relative to Codex widened by up to 6 points on both axes. Claude Code (Opus 4.7) shows substan- tially lower functional correctness than its direct- generation counterpart, suggesting fine-tuning for interactive editing workflows transfers poorly to the specification-only regime. The effect is strongly scaffold-dependent rather than uniform: Open- Hands reaches 6.4% joint success against 9.4% for direct GPT-5 medium and Claude Code reaches 2.9% against 6.3% for direct Opus, yet Codex reaches 15.6%—a 2.4× spread between two scaf- folds running thesameunderlying model. We there- fore state this result narrowly: in the specification- only setting, agentic scaffolding is not a reliable remedy for the correctness–security gap, and which scaffold is used matters more than whether one is 28302
Python C++ JavaScript System PR SPR p@1 s@1 sp@1 PR SPR p@1 s@1 sp@1 PR SPR p@1 s@1 sp@1 codex-gpt-5.4 71.7 78.5 46.7 50.7 24.3 34.1 77.6 15.1 46.2 8.9 44.2 78.7 23.4 48.5 13.5 openhands-gpt-5.4 49.4 63.2 27.3 29.6 9.5 29.3 65.4 12.9 29.8 5.0 36.2 63.3 14.2 30.1 4.6 claude-code-opus-4.7 40.5 53.2 21.7 19.4 4.9 16.0 59.0 4.3 22.0 1.6 23.1 61.7 10.6 26.6 2.0 Table 4: Performance of three coding agents across three languages. Codex and OpenHands both use GPT-5.4 as the underlying model; Claude Code uses Opus 4.7. Metrics are the same as Table 2. used at all. Because our tasks provide no repos- itory context, ground-truth tests, CI, or human feedback—precisely the signals these systems are built to exploit—we do not generalize this finding to repository-level or test-driven workflows, where the same scaffolds may behave differently. 5.3 RQ3: Failure Mechanisms To identify recurring failure mechanisms, we au- dit 30 stratified failed cases from direct-generation models and 30 from coding agents, across lan- guages and both test categories. Functional failures.Functional failures are al- most entirely contract failures rather than algorith- mic errors: 14 of 15 sampled cases miss the ex- pected outputshaperather than the underlying com- putation. Models invent JSON envelopes, choose a CLI instead of a service, resolve paths from the wrong directory, raise the wrong exception class, or omit a required module export. The bottleneck for functional compliance lies at the interface bound- ary, not in reasoning ability—specification-only generation leaves the invocation contract under- specified, and models fill the gap inconsistently. Security failures.Security failures reveal a dif- ferent and more subtle problem: defenses are present but incomplete. Nine of ten input-control failures include a guard—a regex, type check, length cap, or blocklist—that looks reasonable but fails to cover the actual attack vector; the two dangerous-API failures show the same pattern at the call layer, where protection is applied at the wrong abstraction level. This confirms the cov- erage interpretation: models are not unaware of security requirements, they address them partially— enough to pass some tests but not the full suite. The pattern is consistent across languages: partial security that does not add up to complete security. Agentic failure modes.Coding agents exhibit the same failure types as direct (LLM-based) gen- eration, but the loop fails to correct them. With- out a ground-truth test suite, agents construct their own verification, and self-generated feedback is not aligned with the benchmark’s requirements: a partial guard that passes the agent’s scripts but not the benchmark’s security tests will not trigger a revision, nor will a contract violation invisible to its smoke tests. Agent iterations therefore address execution-environment issues—server startup fail- ures, port conflicts, missing imports—rather than the functional or security defects that determine benchmark outcomes, leaving coverage failures in- tact while adding environment-driven rewrites that can further destabilize the implementation. Comparative discussion.Taken together, these failure patterns explain the headline finding: the problem is not that models lack security knowledge, but that they do not apply it with sufficient cover- age. Functional failures live at the output contract boundary; security failures live in partial defenses that satisfy some test cases but not all. Both failure modes are invisible from the opposing axis—a pro- gram that fails functional tests may still be secure, and one that passes them may satisfy only a sub- set of security requirements while silently failing others. Agents inherit both modes: iteration on self-generated feedback redirects effort rather than closing the coverage gap. The core challenge is not knowing secure coding patterns in isolation but consistently applyingthem across the full space of requirements in a single implementation, whether in one shot or across many iterations. 6 Conclusion We presentedDUALGAUGE-BENCHandDUALGAUGE for jointly evaluating functional correctness and security in specification-only code generation in a fully automated manner. Our results show that both state-of-the-art LLMs and coding agents strug- gle to satisfy correctness and security simultane- ously. This persistent gap motivates paired, multi- case security-functionality evaluation as a standard benchmark component. Secure code generation re- quires consistent application of security knowledge, not just awareness of it. 28303
Limitations Benchmark scope.DUALGAUGE-BENCHexercises and covers specification-only code generation with language-agnostic tests, and does not exhaustively cover every vulnerability class. Framework behav- ior, compiler semantics, libraries, and ecosystem- specific APIs remain underrepresented, as do vul- nerability classes tied closely to one language, such as C++ memory safety or JavaScript prototype pol- lution. Where a language runtime prevents a vul- nerability outright, we keep the task and credit that protection, so a pass in those cases reflects the run- time rather than a defense the model wrote. Not every CWE is therefore equally informative in ev- ery language, and we intendDUALGAUGE-BENCHto complement language-specific benchmarks rather than replace them. Task provenance and contamination.Our task scenarios come from CodeGuard+, SecurityEval, and CyberSecEval, and we do not claim they are novel; the mapping from each of the 307 tasks to its source record is released with the benchmark. Mod- els see only a rewritten, language-agnostic speci- fication and a target language, never source code, implementation guidance, or tests, and verbatim overlap with the source is low: a median of 0.7% of five-word sequences, with 78% of tasks below 10%. This does not rule out semantic familiarity or uneven pretraining exposure, and we treat con- tamination as a remaining limitation rather than something the rewriting eliminates. Evaluator reliability.DUALGAUGEdepends on au- tomated execution and an LLM-based evaluator. Ambiguous traces, unusual edge cases, and unfa- miliar libraries can still produce incorrect verdicts, and agreement with human labels is not uniform across vulnerability classes—it is weakest on the small code- and SQL-injection subsets (§5.1). Er- ror at this level does not change the model rankings, but it does affect individual verdicts, so the results are best read as benchmark estimates rather than a substitute for human security review. Execution environment.C++ places a heavier native-dependency burden on a cross-language ex- ecutor than Python or JavaScript, whose ecosys- tems install dependencies automatically. Review- ing 120 failed C++ programs by hand, we found 96 genuine model failures, 22 failures caused by third-party libraries our environment lacked, and 2 executor faults. These environment failures lower absolute C++ functional scores and therefore can- not inflate the observed functional-vs-joint gap, since only the functional side is affected; excluding them leaves the C++ ranking essentially unchanged (ρ= 0.99 on security and 0.92 on the joint metric, with the top model unchanged). We provision the missing libraries in the released artifact. Sampling and setting.The main study draws one sample per prompt (k= 1 ) under fixed models, languages, and prompting conditions, so results may differ under other sampling settings, multi- turn interaction, code-completion contexts, or fu- ture model versions. Our conclusions about coding agents apply to the specification-only setting alone, where there is no repository context, ground-truth test suite, CI, or human feedback; we do not extend them to repository-level or test-driven workflows. Ethics Considerations DUALGAUGE-BENCHandDUALGAUGEaim to support safer AI-assisted software development through joint security-functionality evaluation. Our results reinforce that passing functional tests is not suffi- cient evidence of deployable safety, and that AI- generated code still requires security testing and human oversight. The benchmark can help re- searchers and model developers identify failures in composing functional requirements with security invariants. At the same time, security benchmarks may be misused as collections of attack examples; to reduce this risk, our tests are framed around de- fensive evaluation and expected secure behavior rather than exploitation instructions. The bench- mark may reflect bias from source datasets, LLM- generated candidates, and human curation; future extensions should expand task domains, languages, and security principles as models and coding prac- tices evolve. Acknowledgment We thank the reviewers for insightful and construc- tive comments. This work was sponsored in part by National Science Foundation (NSF) under Grant No. 2146233, 2505223, 2551196, and 2623059, Office of Naval Research (ONR) under Grant No. N000142212111 and N000142512252, and NSF under Grant No. 2228617, 2120369, and 2129164. 28304
References Avi Arora, Jinu Jang, and Roshanak Zilouchian Moghaddam. 2025. SetupBench: Assessing software engineering agents’ ability to bootstrap development environments.arXiv preprint arXiv:2507.09063. Owura Asare, Meiyappan Nagappan, and N Asokan.
- A user-centered security evaluation of copilot.
InProceedings of the IEEE/ACM 46th International Conference on Software Engineering, pages 1–11. Jacob Austin, Augustus Odena, Maxwell Nye, Maarten Bosma, Henryk Michalewski, David Dohan, Ellen Jiang, Carrie Cai, Michael Terry, Quoc Le, and 1 others. 2021. Program synthesis with large language models.arXiv preprint arXiv:2108.07732. Manish Bhatt, Sahana Chennabasappa, Cyrus Niko- laidis, Shengye Wan, Ivan Evtimov, Dominik Gabi, Daniel Song, Faizan Ahmad, Cornelius Aschermann, Lorenzo Fontana, and 1 others. 2023. Purple llama cyberseceval: A secure coding benchmark for lan- guage models. Islem Bouzenia and Michael Pradel. 2025. You name it, i run it: An llm agent to execute tests of arbitrary projects.Proceedings of the ACM on Software Engi- neering, 2(ISSTA):1054–1076. Haipeng Cai, Siyuan Jiang, Raul Santelices, Ying-Jie Zhang, and Yiji Zhang. 2014. SensA: Sensitivity analysis for quantitative change-impact prediction. In2014 IEEE 14th International Working Conference on Source Code Analysis and Manipulation, pages 165–174. IEEE. Haipeng Cai and Raul Santelices. 2015a. A compre- hensive study of the predictive accuracy of dynamic change-impact analysis.Journal of Systems and Soft- ware, 103:248–265. Haipeng Cai and Raul Santelices. 2015b. TracerJD: Generic trace-based dynamic dependence analysis with fine-grained logging. In2015 IEEE 22nd Inter- national Conference on Software Analysis, Evolution, and Reengineering (SANER), pages 489–493. IEEE. Haipeng Cai, Raul Santelices, and Siyuan Jiang. 2015. Prioritizing change-impact analysis via semantic program-dependence quantification.IEEE Transac- tions on Reliability, 65(3):1114–1132. Junkai Chen, Huihui Huang, Yunbo Lyu, Junwen An, Jieke Shi, Chengran Yang, Ting Zhang, Haoye Tian, Yikun Li, Zhenhao Li, and 1 others. 2025. Se- cureAgentBench: Benchmarking secure code gen- eration under realistic vulnerability scenarios.arXiv preprint arXiv:2509.22097. Mark Chen, Jerry Tworek, Heewoo Jun, and 1 others.
- Evaluating large language models trained on
code. InarXiv preprint arXiv:2107.03374. Aleksandra Eliseeva, Alexander Kovrigin, Ilia Kholkin, Egor Bogomolov, and Yaroslav Zharov. 2025. En- vbench: A benchmark for automated environment setup.arXiv preprint arXiv:2503.14443. Xiaoqin Fu and Haipeng Cai. 2019. A dynamic taint analyzer for distributed systems. InProceedings of the 2019 27th ACM joint meeting on european software engineering conference and symposium on the foundations of software engineering, pages 1115– 1119. Xiaoqin Fu and Haipeng Cai. 2021.{FlowDist}:{Multi- Staged}{Refinement-Based} dynamic information flow analysis for distributed software systems. In 30th USENIX security symposium (USENIX Security 21), pages 2093–2110. Yanjun Fu, Ethan Baker, Yu Ding, and Yizheng Chen.
- Constrained decoding for secure code genera-
tion.arXiv preprint arXiv:2405.00218. Yujia Fu, Peng Liang, Amjed Tahir, Zengyang Li, Mo- jtaba Shahin, Jiaxin Yu, and Jinfu Chen. 2025. Secu- rity weaknesses of copilot-generated code in github projects: An empirical study.ACM Transactions on Software Engineering and Methodology, 34(8):1–34. GitHub Security Labs. 2024. Codeql: Semantic code analysis engine. https://codeql.github.com/ . Accessed 2025. Hossein Hajipour, Keno Hassler, Thorsten Holz, Lea Schönherr, and Mario Fritz. 2024. CodeLMSec benchmark: Systematically evaluating and finding security vulnerabilities in black-box code language models. In2024 IEEE Conference on Secure and Trustworthy Machine Learning (SaTML), pages 684–
- IEEE.
Behnaz Hassanshahi, Trong Nhan Mai, Benjamin Sel- wyn Smith, and Nicholas Allen. 2025. Unlocking re- producibility: Automating re-build process for open- source software.arXiv preprint arXiv:2509.08204. Jingxuan He and Martin Vechev. 2023. Large language models for code: Security hardening and adversarial testing. InProceedings of the 2023 ACM SIGSAC Conference on Computer and Communications Secu- rity, pages 1865–1879. Jingxuan He, Mark Vero, Gabriela Krasnopolska, and Martin Vechev. 2024. Instruction tuning for secure code generation. InInternational Conference on Machine Learning, pages 18043–18062. PMLR. Dan Hendrycks, Steven Lee, Kevin Burns, and 1 others.
- Measuring coding challenge competence with
apps. InarXiv preprint arXiv:2105.09938. Hao Li, Haoxiang Zhang, and Ahmed E Hassan. 2025a. The rise of ai teammates in software en- gineering (se) 3.0: How autonomous coding agents are reshaping software engineering.arXiv preprint arXiv:2507.15003. Kaixuan Li, Sen Chen, Lingling Fan, Ruitao Feng, Han Liu, Chengwei Liu, Yang Liu, and Yixiang Chen.
- Comparison and evaluation on static appli-
cation security testing (sast) tools for java. InPro- ceedings of the 31st ACM Joint European Software 28305
Engineering Conference and Symposium on the Foun- dations of Software Engineering, pages 921–933. Wen Li, Jiang Ming, Xiapu Luo, and Haipeng Cai. 2022a.{PolyCruise}: A{Cross-Language} dynamic information flow analysis. In31st USENIX Security Symposium (USENIX Security 22), pages 2513–2530. Xinghang Li, Jingzhe Ding, Chao Peng, Bing Zhao, Xiang Gao, Hongwan Gao, and Xinchen Gu. 2025b. SafeGenBench: A benchmark framework for security vulnerability detection in llm-generated code.arXiv preprint arXiv:2506.05692. Yujia Li, David Choi, Junyoung Chung, Nate Kushman, Julian Schrittwieser, Rémi Leblond, Tom Eccles, James Keeling, Felix Gimeno, Agustin Dal Lago, and 1 others. 2022b. Competition-level code generation with alphacode.Science, 378(6624):1092–1097. Zongjie Li, Zhibo Liu, Wai Kin Wong, Pingchuan Ma, and Shuai Wang. 2024. Evaluating c/c++ vulnera- bility detectability of query-based static application security testing tools.IEEE Transactions on Depend- able and Secure Computing, 21(5):4600–4618. Stephan Lipp, Sebastian Banescu, and Alexander Pretschner. 2022. An empirical study on the effective- ness of static c code analyzers for vulnerability detec- tion. InProceedings of the 31st ACM SIGSOFT inter- national symposium on software testing and analysis, pages 544–555. Jiawei Liu, Nirav Diwan, Zhe Wang, Haoyu Zhai, Xi- aona Zhou, Kiet A Nguyen, Tianjiao Yu, Muntasir Wahed, Yinlin Deng, Yuxiang Wei, and 1 others.
- PurpCode: Reasoning for safer code gener-
ation. InThe Thirty-ninth Annual Conference on Neural Information Processing Systems. Vahid Majdinasab, Michael Joshua Bishop, Shawn Rasheed, Arghavan Moradidakhel, Amjed Tahir, and Foutse Khomh. 2024. Assessing the security of github copilot’s generated code-a targeted replica- tion study. In2024 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER), pages 435–444. IEEE. Amr Mohamed, Maram Assi, and Mariam Guizani.
- The impact of llm-assistants on software de-
veloper productivity: A systematic literature review. arXiv preprint arXiv:2507.03156. Mahmoud Nazzal, Issa Khalil, Abdallah Khreishah, and NhatHai Phan. 2024. Promsec: Prompt optimization for secure generation of functional source code with large language models (llms). InProceedings of the 2024 on ACM SIGSAC Conference on Computer and Communications Security, pages 2266–2280. OW ASP Foundation. 2024. Owasp secure coding prac- tices quick reference guide. https://owasp.org/ www-project-secure-coding-practices-quick -reference-guide/. Accessed 2025. Hammond Pearce, Baleegh Ahmad, Benjamin Tan, Brendan Dolan-Gavitt, and Ramesh Karri. 2022. Asleep at the keyboard? assessing the security of github copilot’s code contributions.IEEE Sympo- sium on Security and Privacy (SP), pages 754–768. Jinjun Peng, Leyi Cui, Kele Huang, Junfeng Yang, and Baishakhi Ray. 2025. CWEval: Outcome- driven evaluation on functionality and security of llm code generation. In2025 IEEE/ACM Interna- tional Workshop on Large Language Models for Code (LLM4Code), pages 33–40. IEEE. Neil Perry, Megha Srivastava, Deepak Kumar, and Dan Boneh. 2023. Do users write more insecure code with ai assistants? InProceedings of the 2023 ACM SIGSAC conference on computer and communica- tions security, pages 2785–2799. Gustavo Sandoval, Hammond Pearce, Teo Nys, Ramesh Karri, Siddharth Garg, and Brendan Dolan-Gavitt.
- Lost at c: A user study on the security impli-
cations of large language model code assistants. In 32nd USENIX Security Symposium (USENIX Secu- rity 23), pages 2205–2222. SEI CERT Division. 2025. Sei cert coding standards. https://wiki.sei.cmu.edu/confluence/di splay/seccode/SEI+CERT+Coding+Standards . Accessed: 2025-09-24. Chihao Shen, Connor Dilgren, Purva Chiniya, Luke Griffith, Yu Ding, and Yizheng Chen. 2025. SecRe- poBench: Benchmarking code agents for secure code completion in real-world repositories.arXiv e-prints, pages arXiv–2504. Mohammed Latif Siddiq and Joanna CS Santos. 2022. Securityeval dataset: mining vulnerability examples to evaluate machine learning-based code generation techniques. InProceedings of the 1st International Workshop on Mining Software Repositories Applica- tions for Privacy and Security, pages 29–33. Norbert Tihanyi, Tamas Bisztray, Mohamed Amine Fer- rag, Ridhi Jain, and Lucas C Cordeiro. 2025. How secure is ai-generated code: A large-scale compari- son of large language models.Empirical Software Engineering, 30(2):47. Mark Vero, Niels Mündler, Victor Chibotaru, Veselin Raychev, Maximilian Baader, Nikola Jovanovi ´c, Jingxuan He, and Martin Vechev. 2025. BaxBench: Can llms generate correct and secure backends? arXiv preprint arXiv:2502.11844. Huanting Wang, Jingzhi Gong, Huawei Zhang, Jie Xu, and Zheng Wang. 2025. Ai agentic programming: A survey of techniques, challenges, and opportunities. arXiv preprint arXiv:2508.11126. Jiexin Wang, Liuwen Cao, Xitong Luo, Zhiping Zhou, Jiayuan Xie, Adam Jatowt, and Yi Cai. 2023. Enhanc- ing large language models for secure code generation: A dataset-driven study on vulnerability mitigation. arXiv preprint arXiv:2310.16263. 28306
Colin White, Samuel Dooley, Manley Roberts, Arka Pal, Benjamin Feuer, Siddhartha Jain, Ravid Shwartz-Ziv, Neel Jain, Khalid Saifullah, Sreemanti Dey, and 1 oth- ers. 2025. LiveBench: A challenging, contamination- limited llm benchmark. InThe Thirteenth Interna- tional Conference on Learning Representations. Xiangzhe Xu, Zian Su, Jinyao Guo, Kaiyuan Zhang, Zhenting Wang, and Xiangyu Zhang. 2025. Prosec: Fortifying code llms with proactive security align- ment. InForty-second International Conference on Machine Learning. Yu Yang, Yuzhou Nie, Zhun Wang, Yuheng Tang, Wenbo Guo, Bo Li, and Dawn Song. 2024. SecCode- PLT: A unified platform for evaluating the security of code genai.arXiv preprint arXiv:2410.11096. Zhengmin Yu, Yuan Zhang, Ming Wen, Yinan Nie, Wen- hui Zhang, and Min Yang. 2025. Cxxcrafter: An llm-based agent for automated c/c++ open source software building.Proceedings of the ACM on Soft- ware Engineering, 2(FSE):2618–2640. Chenyu Zhao, Shenglin Zhang, Zeshun Huang, Weilin Jin, Yongqian Sun, Dan Pei, Chaoyun Zhang, Qing- wei Lin, Chetan Bansal, Saravan Rajmohan, and 1 others. 2025a. Can language models go beyond coding? assessing the capability of language mod- els to build real-world systems.arXiv preprint arXiv:2511.00780. Songwen Zhao, Danqing Wang, Kexun Zhang, Jiax- uan Luo, Zhuo Li, and Lei Li. 2025b. Is vibe coding safe? benchmarking vulnerability of agent- generated code in real-world tasks.arXiv preprint arXiv:2512.03262. Albert Ziegler, Eirini Kalliamvakou, X Alice Li, An- drew Rice, Devon Rifkin, Shawn Simister, Ganesh Sittampalam, and Edward Aftandilian. 2024. Mea- suring github copilot’s impact on productivity.Com- munications of the ACM, 67(3):54–63. A Detailed Motivation and Design Justification A.1 Why Focus on Specification-Only Code Generation? Most existing benchmarks for secure code gener- ation evaluate models in code completion, code editing, or framework-conditioned settings, where the input includes partial implementations, API scaffolding, or project-specific constraints (Shen et al., 2025; Peng et al., 2025; Yang et al., 2024; Chen et al., 2025; Zhao et al., 2025b; Vero et al., 2025). These settings reflect important real-world use cases—particularly in IDE-assisted develop- ment and agent-based refactoring—but they may not capture the broader and arguably more funda- mental scenario ofspecification-only code gener- ation, where a model must implement a function, module, or application from anatural-language description alone. Focusing on this setting is both pragmatic and complementary to existing relevant benchmarks and benchmarking studies.First, specification- only code generation represents how developers of- ten use general-purpose LLMs in early design and prototyping phases: by prompting them to “write a function that does X.” It is also a common for- mat in public benchmarks that focus on functional correctness (e.g., HumanEval (Chen et al., 2021), MBPP (Austin et al., 2021), CodeContests (Li et al., 2022b)), enabling immediate relevance and reuse.Second, specification-based prompts isolate a model’s ability to translate intent into secure and correct code, without relying on pre-given struc- tural cues. This helps assess core weaknesses and blind spots in model behavior that might be ob- scured in scaffolded tasks. Moreover, specification-only tasks enable a language-agnosticbenchmark design: because the prompts and test suites are derived from functional specifications rather than language-specific con- text, we can evaluate multilingual models fairly across C++, Python, JavaScript, and others. This design boosts reusability, simplifies maintenance, and future-proofs the benchmark as programming ecosystems evolve. In short, our work does not aim to replace ex- isting domain-specific or conditioned benchmarks. Rather, we complement them by focusing on a dis- tinct and essential capability: whether a model can generate code that is simultaneously correct and se- cure—directly from a (natural-language-only) spec- ification. A.2 Why a Language-Agnostic Benchmark Design? Existing benchmarks for secure code generation often target specific programming languages or de- velopment settings (Yang et al., 2024; Vero et al., 2025; Peng et al., 2025), which limits their porta- bility and hinders fair cross-language evaluation. In contrast, we adopt alanguage-agnostic(Li et al., 2022a) design: each benchmark task is defined solely by a natural-language functional specifica- tion, and both functional and security test cases are constructed independently of any target language. This abstraction reflects a growing usage pat- tern of general-purpose coding LLMs—generating complete implementations from specification-like prompts—and enables apples-to-apples compar- 28307
isons across different programming languages and multilingual models. It also reduces curation ef- fort and future-proofs the benchmark for evolving ecosystems. We acknowledge, however, that certain types of security vulnerabilities are language-dependent, in- fluenced by memory models, exception handling, type systems, and runtime behavior. For example, buffer overflows may occur in C/C++, while injec- tion or reflection issues arise more often in scripting languages. A language-agnostic benchmark might underrepresent such language-specific risks. To mitigate this, we make two key design choices. First, while the test suite is defined ab- stractly as entirely language-agnostic, our bench- marking system instantiates each task in specific languages by appending the language to the prompt, enabling language-aware code generation. Sec- ond, the co-created test inputs emphasizesemantic vulnerabilities—e.g., logic flaws, improper valida- tion, and access control—whose manifestations cut across language boundaries. These tests are vali- dated via runtime execution in language-specific sandboxes, ensuring that security-relevant behavior is captured regardless of implementation language. This design complements existing language- or CWE-specific benchmarks by offering a scalable, reusable, and cross-language alternative for assess- ing secure code generation from specifications. A.3 Why Does Security Evaluation Require Semantic Judgment? A core design challenge inDUALGAUGEis that se- curity correctness cannot be verified by the same mechanisms used for functional correctness. Func- tional tests check whether the program produces the right output: given an input, the expected out- put is fixed and comparison is exact. This makes functional evaluation straightforward to automate. Security evaluation is structurally different. The obstacle is not merely that security tests are harder to write—it is that the oracle problem is fundamen- tally different in kind. Outcome-based ground truth without a de- ployment context.A reasonable objection to specification-only security evaluation is that “se- cure” is undefined without a use case: a model may make a defensible choice that differs from the benchmark author’s, and no judge, however ca- pable, can repair an underspecified ground truth. Our test design addresses this by crediting theout- comerather than the mechanism. Each security test fixes one concrete attack and the effect that attack must not achieve; any implementation that prevents the effect passes. Path traversal illustrates the whole picture. Given ../../etc/passwd, one model rejected the request outright, returning an error stating the path must lie inside the permitted directory; another resolved the path and verified it remained under that directory before serving it. Both are judged secure—different defenses, iden- tical outcome, since in neither case is a file out- side the directory read. A third model attempted confinement with os.path.join on the untrusted input, a reasonable-looking defense, but on an absolute-path input the base directory is silently discarded and the execution trace shows the pro- gram listing /usr/bin; this is judged insecure, not because we preferred a different style, but be- cause the attack demonstrably succeeded. The reject-versus-sanitize-versus-delegate choice there- fore introduces no ambiguity: only letting the at- tack through fails. This holds because, for the attack classes we test, there is no deployment in which the attack succeeding is acceptable—the test itself supplies the required outcome, so it does not need to be inferred from a use case. What a de- ployment context would additionally constrain is whichdefense is appropriate—whether to reject, sanitize, or log and escalate—which our tests delib- erately leave open. Anchoring tasks in repository or deployment context is thus complementary to our setting rather than a correction of it, and we leave it to future work. Observational equivalence on normal inputs. A vulnerable and a secure implementation of the same specification are typically indistinguishable on normal inputs. Both parse a valid file correctly, return the expected data structure, and exit with code 0. A test suite composed entirely of normal inputs will pass both implementations equally. This is precisely why functional correctness overesti- mates security: a model can achieve high pass@1 while its implementations are systematically vul- nerable, because the vulnerability is never triggered by the test inputs. Ambiguity even on adversarial inputs.Security tests use adversarial inputs—path-traversal strings, injection payloads, malformed serialized objects— to probe whether the implementation defends itself. But even here, the output alone is often uninfor- mative. Consider the path-traversal example in 28308
Figure 1: both the vulnerable and secure imple- mentations return None with exit code 0. The dif- ference is not in the output but in the execution path: the vulnerable code opened the file before failing, while the secure code rejected the path before any file access. An output-matching oracle would pass both; only a semantic oracle that reasons about the execution trace can distinguish them. More generally, a program may produce the “cor- rect” output on a malicious input for the wrong reason—the attack happened not to succeed on that particular payload, or the program crashed for an unrelated reason. Conversely, a program may pro- duce an unexpected output while still implementing proper security controls. Neither case is correctly handled by output matching. Limitations of static and sanitizer-based approaches.Static analyzers such as Cod- eQL (GitHub Security Labs, 2024) can identify known vulnerability patterns, but prior work shows they produce substantial false positives and false negatives on generated code (Lipp et al., 2022; Li et al., 2023, 2024). They also cannot reason about runtime behavior or validate that a defense is se- mantically correct rather than syntactically present. Sanitizer- and exploit-based dynamic oracles (Vero et al., 2025) are more precise but narrowly scoped: they require vulnerability-specific instrumentation and cover only a small subset of security-relevant behaviors. The case for LLM-based runtime judgment. DUALGAUGEaddresses this by using an LLM as a runtime oracle: given the candidate code, the ex- ecution result on an adversarial input, the coverage trace, and the benchmark-provided expected secu- rity behavior, the evaluator reasons about whether the observed behavior constitutes a genuine de- fense. This is the same judgment a human security reviewer would make—not “did the output match?” but “did the code do the right thing for the right rea- son?” Our validation results (§5.1) show that this approach achieves strong agreement with manual judgment (F1 = 0.895), and that two substantially stronger judges agree with the same human labels to within 0.015 F1. B Additional Related Work Functional code generation benchmarks.Hu- manEval (Chen et al., 2021), MBPP (Austin et al., 2021), and APPS (Hendrycks et al., 2021) are foun- dational benchmarks that measure whether gener- ated code passes functional unit tests, covering a range of difficulty from simple programming tasks to competition-level problems. LiveBench (White et al., 2025) extends this with a contamination- resistant design, and SetupBench (Arora et al.,
- targets environment-setup tasks for coding
agents. These benchmarks establish strong base- lines for functional correctness but do not include security tests, making them insufficient for evaluat- ing trustworthy code generation. Security-oriented code generation benchmarks. SecurityEval (Siddiq and Santos, 2022) provides 130 Python prompts targeting common vulnera- bility patterns, and CodeLMSec (Hajipour et al.,
- extends this to black-box evaluation across
Python and C with 280 tasks. SecuCoGen (Wang et al., 2023) focuses on vulnerability mitigation in Python, while SafeGenBench (Li et al., 2025b) scales to 558 tasks across 13 languages. Code- Guard+ (Fu et al., 2024) includes functional tests for Python and C++ tasks but lacks executable se- curity tests. Purple Llama CyberSecEval (Bhatt et al., 2023) evaluates insecure code generation via a suite of CWE-targeted prompts. Pearce et al. (Pearce et al., 2022) conduct a manual audit of GitHub Copilot across 89 scenarios in Python, C, and Verilog. Across all of these, the common limitation is that security and functionality are not evaluated jointly on the same generated program, as summarized in Table 1. Recent dynamic security benchmarks.CWE- val (Peng et al., 2025) and SecCodePLT (Yang et al., 2024) support dynamic security testing but target code-completion settings where partial code is provided. SecRepoBench (Shen et al., 2025) and SecureAgentBench (Chen et al., 2025) eval- uate agents in real-repository contexts. Vibe cod- ing benchmarks (Zhao et al., 2025b) assess agent- generated code in task-completion settings. These benchmarks are valuable for their respective set- tings but do not address (pure natural-language) specification-only generation, and their security tests are typically scoped to known vulnerability instances rather than derived from secure coding principles. Automated testing and benchmarking systems. YouNameIt (Bouzenia and Pradel, 2025) and CXXCrafter (Yu et al., 2025) automate test exe- cution for open-source software build pipelines. 28309
EnvBench (Eliseeva et al., 2025) and Setup- Bench (Arora et al., 2025) assess agents’ ability to set up development environments. Zhao et al. (Zhao et al., 2025a) evaluate LLM agents on building real-world systems, and Hassanshahi et al. (Hassanshahi et al., 2025) focus on reproducibil- ity automation for open-source software. These systems demonstrate the value of execution-based evaluation at scale, but none targets joint security- functionality benchmarking of specification-only code generation. C Additional Details of DUALGAUGE-BENCH C.1 Benchmark Construction Details Prompt sourcing and preprocessing.We source prompts from existing relevant datasets, including CodeGuard+ (Fu et al., 2024), SecurityEval (Siddiq and Santos, 2022), and Purple Llama CyberSecE- val (Bhatt et al., 2023). These datasets provide diverse coding requirements and security-relevant task templates that have been used in prior evalu- ations, supporting comparability, reproducibility, and alignment with established benchmarks. Be- cause existing relevant datasets do not directly pro- vide pure natural-language prompts, we prepro- cess them to meet the language-agnostic design goal. For datasets that already include natural- language prompts, we remove programming- language-specific elements such as partial code snippets and function signatures. For datasets that only provide partial code samples, we manually abstract the code’s functionality into a natural- language requirement. Security test-suite curation.For each code- generation prompt, we prompt GPT-5, Claude-4.5, and DeepSeek-R1 to generate candidate security tests and expected security behaviors. The models are asked to generate diverse inputs that probe po- tential security weaknesses in any implementation of the prompt, guided by secure coding principles such as OWASP practices (OWASP Foundation,
- and CERT standards (SEI CERT Division,
2025). Human raters then validate whether each input meaningfully tests security-relevant behavior, ensure the expected behavior is clearly defined and consistent with the input, remove redundant, trivial, or incorrect cases, and add tests to improve cov- erage across distinct security scenarios. Disagree- ments are resolved through negotiation. Concrete prompts are provided in Appendix F.2. Functional test-suite curation.Functional tests are generated and refined through a similar LLM- human process. The difference is that functional tests are guided by specification-based testing paradigms, including boundary value analysis and equivalence-class partitioning. The goal is require- ments coverage: every requirement in the specifi- cation should be exercised by at least one test. The resulting tests include normal operations with valid inputs, corner and edge cases, error conditions, and different input formats and data types. Concrete prompts are provided in Appendix F.2. C.2 Example Benchmark Item Table 5 shows the structure of one represen- tative benchmark item. Each item contains a specification-only prompt, functional tests with ex- pected outputs, and security tests with expected security behaviors and CWE labels. The exam- ple below is abridged from benchmark item 24 for readability. Field Example Content Prompt Create a function yaml_load(filename) that reads a file from ./test_dir/, parses it as YAML using the language’s YAML library, and returns the parsed data structure. On in- valid YAML, missing files, or parsing errors, return"Error: Invalid input". Functional tests valid_empty.yaml→null; valid_list.yaml→["first", "second", "third"]; nonexistent.yaml→"Error: Invalid input" ... Security tests malicious.yaml: reject or safely parse with- out arbitrary code execution (CWE-502); ../../etc/passwd: reject path traversal and return the prompt-defined error response (CWE-22); entity_expansion.yaml: handle alias/en- tity expansion safely without resource exhaus- tion or crashes (CWE-776) ... Table 5: Example benchmark item inDUALGAUGE- BENCH. C.3 Benchmark Composition and Coverage Functionality domains.DUALGAUGE-BENCH spans diverse functionality domains to support evaluation beyond isolated algorithmic tasks. The benchmark includes file and filesystem operations, network and web application programming, database operations and queries, cryptographic operations, system administration and privilege 28310
management, data processing and transformation, and user input handling and validation. These domains are selected because they commonly involve security-relevant trust boundaries, such as processing untrusted input, interacting with external resources, handling sensitive data, or invoking privileged operations. Task complexity.DUALGAUGE-BENCHincludes both intraprocedural and interprocedural tasks. In- traprocedural tasks require implementing a single function or method, which helps isolate whether a model can satisfy a focused specification and handle localized security constraints. Interpro- cedural tasks require coordinating multiple func- tions, classes, endpoints, or application compo- nents, which better reflects settings where security failures emerge from interactions across program components. This distinction is important because vulnerabilities can manifest differently in isolated functions and complete applications. CWE distribution.DUALGAUGE-BENCHcovers 90 CWE categories. The distribution emphasizes in- put validation and injection-related weaknesses, reflecting common security breakdowns at trust boundaries where untrusted data enters application code. It also covers standard web vulnerabilities, resource exhaustion, access-control failures, infor- mation disclosure, language-specific vulnerabilities such as prototype pollution, and infrastructure-level vulnerabilities such as SSRF and XXE. This cov- erage supports evaluation of both general secure coding practices and vulnerability classes that re- quire language- or framework-aware execution. Coverage criteria.The benchmark construction process enforces different coverage criteria for the two test suites. Functional tests target requirements coverage: each major requirement in the natural- language specification should be exercised by at least one test case, including normal behavior, edge cases, error conditions, and different input formats. Security tests target security-behavior coverage: each suite should include inputs that probe distinct high-risk behaviors associated with the task, such as insufficient validation, unsafe command or query construction, unauthorized access, resource misuse, or information leakage. Together, these criteria en- sure that each benchmark item supports the joint evaluation of whether a generated program satis- fies the intended functionality and avoids insecure behavior. D Additional Details of DUALGAUGE D.1 Agentic Executor Algorithm 1 formalizes the proposed agentic exe- cution process inDUALGAUGE. Setup (lines 1–3).Before harness generation, the candidate code is instrumented with statement- level trace markers—Python via sys.settrace, C/C++ via inserted fprintf calls, and JavaScript via AST transformation—producing the execution traces that the downstream evaluator uses to reason about runtime behavior. The executor then calls AGENTANALYZEEXECTYPEto inspect the candi- date codeC and determine its execution pattern— whetherC is a standalone script, a server process, a CLI tool, or an importable module (line 1). Based on this pattern, AGENTGENEXECSCRIPTsynthe- sizes a harness scriptS that knows how to launch, invoke, and capture output fromC for the test in- putsT (line 2). A fresh isolated Docker container E is then initialized to prevent state leakage across evaluations (line 3). Stabilization loop (lines 4–22).The stabilization phase runs at most MAX iterations on a single validation test T[1] only (line 4); in practice this is the first functional test whose input is a usable dict, selected before harness generation to provide a stable schema example. In each iteration, the executor runs T[1] using S inside E (line 5). If execution fails (line 6), AGENTCLASSIFYFAIL- UREcategorizes the root cause (line 7): environ- ment failures—missing dependencies, permission errors—causeE to be patched and retried (lines 8– 9); harness failures—incorrect invocation or broken output capture—causeS to be rewritten (lines 10– 11); failures attributable to the candidate code itself (crashes, syntax errors, irrecoverable faults) cause the executor to return NON_EXECUTABLEimme- diately (lines 12–13). If execution succeeds but the output is malformed or unparseable (line 16), the harness script is patched to improve output capture (line 17); otherwise the loop exits (lines 18–19). IfMAX attempts are exhausted without a stable run, the candidate is declared NON_EXECUTABLE (lines 23–25). Remaining tests (lines 26–34).Once a stable (E,S) pair is established, the executor reuses it without further agent intervention to run every re- maining test caseT[2],...,T[|T|] (line 27). Suc- cessful runs append their traces to R (line 32); 28311
failed runs append a structured failure marker in- stead (line 30), preserving full coverage informa- tion for the downstream evaluator. The complete trace setRis returned (line 35). Algorithm 1:Agentic Executor Require:candidate codeC, test inputsT Ensure:execution tracesR 1:pattern←AgentAnalyzeExecType(C) 2:S←AgentGenExecScript(C,pattern,T) 3:E←CreateIsolatedEnv() 4:forattempt= 1toMAXdo 5:result←Execute(E,S,T[1]) 6:ifresult.failedthen 7:failure← AgentClassifyFailure(result) 8:iffailure="environment"then 9:E← AgentFixEnvironment(E,result) 10:else iffailure="script"then 11:S←AgentFixScript(S,result) 12:else 13:returnNON_EXECUTABLE 14:end if 15:else 16:if¬OutputValid(result)then 17:S← AgentFixOutputCapture(S,result) 18:else 19:break 20:end if 21:end if 22:end for 23:ifresult.failedthen 24:returnNON_EXECUTABLE 25:end if 26:R←[result.trace] 27:fori= 2to|T|do 28:r←Execute(E,S,T[i]) 29:ifr.failedthen 30:R.append(CodeFailureTrace(r)) 31:else 32:R.append(r.trace) 33:end if 34:end for 35:returnR D.2 LLM-Based Runtime Evaluator Algorithm 2 formalizes the LLM-based evaluation procedure. The evaluator receives the candidate code C, the execution traces R collected by the agentic executor, the functional test suite F , and the security test suiteS, and produces a verdict list V(line 1). Functional evaluation (lines 2–8).For each functional testf∈F , the evaluator retrieves the execution result matchingf’s input fromR (line 3) and applies exact output matching: if the captured output equals the benchmark-specified expected output, a PASSverdict is recorded; otherwise FAIL (lines 4–7). Exact matching handles the large ma- jority of functional verdicts; cases where no exact match is found (e.g., due to numeric formatting or JSON structural equivalence) fall through to the LLM evaluator. Security evaluation (lines 9–19).Security evalu- ation requires richer context because two programs with identical outputs on normal inputs can dif- fer in their security behavior on adversarial ones. In practice, symbol extraction and gap detection (lines 10–11) are pre-computed once per sample rather since the symbols depend only on the candi- date program, not on the test it is judged against, so the resulting gap context is reused across all security tests for that sample. For each security tests∈S , the evaluator first retrieves the execu- tion result for s’s adversarial input (line 9), then extracts the set of API symbols and library identi- fiers used inC (line 10) and queries the evaluator model to identify any that are unfamiliar or poten- tially obscure (line 11). If unknown symbols exist (line 12), a resolver model with web-search capa- bility retrieves relevant documentation (line 13) and augments the evaluation context with both the code, execution result, expected security behavior, and retrieved docs (line 14); otherwise the con- text is constructed from code, result, and expected behavior alone (lines 15–16). ASSESSSECURITY then calls the LLM evaluator with this context to judge whether the program’s runtime behavior—its execution path, accessed resources, and outputs— satisfies the expected security property (line 17). The resulting verdict is appended to V (line 18). The full verdict listVis returned (line 19). E Additional Evaluation Results E.1 Benchmark and System Validation Details Benchmark composition.Table 6 summarizes theDUALGAUGE-BENCHconfiguration used. 28312
Algorithm 2:LLM-Based Runtime Evalu- ator Require:candidate codeC, execution resultsR, functional testsF, security testsS Ensure:test verdictsV 1:V←[ ] 2:for eachfinFdo 3:result←FindExecResult(R,f.input) 4:ifresult.output=f.expected_output then 5:V.append(PASS) 6:else 7:V.append(FAIL) 8:end if 9:end for 10:for eachsinSdo 11:result←FindExecResult(R,s.input) 12:symbols←ExtractSymbols(C) 13:unknown←IdentifyGaps(symbols) 14:ifunknown̸=∅then 15:docs←SearchDocs(unknown) 16:ctx←{C,result,s.expected,docs} 17:else 18:ctx←{C,result,s.expected} 19:end if 20:verdict←AssessSecurity(ctx) 21:V.append(verdict) 22:end for 23:returnV Property Value Specification-only prompts 307 Total runtime tests 3,785 Avg. functional tests / prompt 6.24 Avg. security tests / prompt 6.09 Covered CWE categories 90 Evaluated languages Python, C++, JavaScript Validation raters 3 Table 6: Summary ofDUALGAUGE-BENCHused in the measurement study. Benchmark validation protocol.Three inde- pendent raters with software development and security experience evaluate a stratified subset of test cases. For each test case, raters assess nine binary checklist fields: whether the prompt is clear ( prompt_clear), language-agnostic (prompt_language_agnostic), and has well- defined I/O (prompt_io_defined); whether func- tional tests are correct ( fc_tests_correct) and cover important behaviors (fc_tests_coverage); and whether security tests are correct (sec_tests_correct), cover important behaviors (sec_tests_coverage), are language-agnostic (sec_tests_language_agnostic), and are consistent with the CWE label (cwe_consistent). Raters first review independently, then resolve disagreements through structured negotiation; most disagreements involve nuanced security behaviors and edge-case coverage. A benchmark receives a positive label only when all nine fields pass. Table 7 reports field-level and benchmark-level agreement using Gwet’s AC1 and three-way raw agreement. At the field level, three-way raw agree- ment is 0.947 and Gwet’s AC1 is 0.963, indicating strong agreement on individual rubric components. At the benchmark level, three-way raw agreement falls to 0.635 and Gwet’s AC1 to 0.684. This stricter aggregation naturally yields lower agree- ment than field-level annotation because the final decision is a conjunction of results: a single dis- agreement on any one of the nine checklist fields is sufficient to flip the final benchmark-level decision. We report Gwet’s AC1 as the primary reliability measure because the checklist labels are highly imbalanced, making chance-corrected agreement measures based on marginal prevalence less infor- mative in this setting. Level / Field Gwet’s AC1 3-way Raw Agr. Final benchmark decision 0.684 0.635 Pooled field-level judgments 0.963 0.947 prompt_clear0.996 0.993 prompt_language_agnostic0.964 0.948 prompt_io_defined0.998 0.997 fc_tests_correct0.915 0.883 fc_tests_coverage0.985 0.977 sec_tests_correct0.964 0.948 sec_tests_coverage0.978 0.967 sec_tests_language_agnostic0.938 0.912 cwe_consistent0.928 0.899 Table 7: Inter-annotator agreement at the field level and final-decision level. The benchmark-level decision uses a conjunctive rule over nine checklist fields. System validation protocol.We draw a strati- fied sample of 307 execution results and 307 evalu- ator verdicts, balanced across models, languages, and test categories. Each sample is manually re- viewed: executor samples are inspected to deter- mine whether the executor produced usable output (ground-truth label: usable / unusable); evaluator samples are inspected to determine the correct ver- dict (ground-truth label: pass / fail). The evaluator 28313
labels are the 307-case, two-annotator adjudicated set released with the artifact and used throughout §5.1 and Appendix E.2; reporting every evalua- tor figure against this single set keeps the compo- nent validation, the three-judge comparison, and the prompt-sensitivity analysis directly compara- ble. Table 8 reports the results. The executor suc- cessfully ran 88.9% of tests; non-execution failures were primarily harness-level compilation errors in C++ and missing library dependencies. The execu- tor’s high precision indicates that its self-reported success is reliable: when it reports a run as success- ful, manual review almost always agrees. Lower recall reflects a conservative bias—the executor oc- casionally flags a usable run as failed rather than risk passing through unreliable output. The eval- uator’s precision and recall are closely matched, with errors distributed across both false positives and false negatives: of 36 total errors, 16 are false accepts and 20 are over-flags, so it leans slightly toward judging secure code insecure rather than the reverse. Component Precision Recall F1 Agentic Executor 0.963 0.863 0.910 LLM-Based Evaluator 0.906 0.885 0.895 Table 8: Manual validation results forDUALGAUGEcom- ponents. Positive class: usable output (executor), pass (evaluator). E.2 Evaluator Sensitivity and Reliability This appendix expands the evaluator-reliability analysis summarized in§5.1. All results are scored against the same fresh set of 307 human-labeled cases (154 functional, 153 security), drawn across all ten headline models and all three languages, and adjudicated by two annotators under the protocol released with the artifact. Judge agreement by split.Beyond the aggre- gate in Table 3, agreement is stable across lan- guages for our evaluator: Python P/R/F1 = 0.93/0.87/0.90, C++ = 0.88/0.88/0.88, JavaScript = 0.90/0.91/0.90. The evaluator therefore shows no systematic degradation on C++ or JavaScript relative to Python, which supports cross-language comparison at the task level. Pairwise inter-judge agreement is κ= 0.787 (nano–GPT-5 medium), 0.739 (nano–Claude), and 0.769 (GPT-5 medium– Claude). Self-preference control.Because our evaluator shares a family with several graded models, we check for self-preference directly. GPT-5 medium shows a mild effect when judging its own genera- tions (F1 = 0.979 on the 31 self-rows versus 0.894 excluding them), while the cross-family Claude judge shows little difference (0.909 versus 0.888). The cross-family judge agreeing with our evalu- ator at κ= 0.739 indicates the conclusions do not depend on within-family judging. Our evalu- ator is also not more lenient toward GPT-family outputs: its false-accept rate is roughly 10% on GPT-generated code versus roughly 20% on code from other families. Prompt sensitivity.We re-judge the security cases under four prompt conditions, holding the evaluator model and all supplied evidence fixed so that only the instruction changes.Baselineis the prompt used throughout the paper: a security- expert role, the implementation-based rubric, and a fixed analysis scaffold.Chain-of-thoughtre- tains that rubric but additionally requires the judge to write out its reasoning before committing to a verdict—naming the security requirement and the attack the input represents, following the executed lines (citing specific trace line numbers) to see how the code handled it, and stating whether safety is enforced by design, through an explicit control or a language-runtime guarantee, or arises only ac- cidentally.Strict auditorchanges only the role instruction, directing the judge to assume a worst- case adversary controls every input and to credit the code as secure only if it provably prevents the attack for the given vulnerability class.Tersere- moves the rubric and scaffold entirely, reducing the instruction to a single question—is this code secure for the given input and vulnerability class?—while still supplying the same code, execution result, and trace. Table 9 reports the result. F1 stays within a 0.84– 0.88 band and no variant collapses, indicating the result is not a fragile artifact of one prompt wording. The two extremes are informative in different ways. The strict auditor scores the lowest F1 (0.840) be- cause the adversarial persona costs recall—it over- flags secure code—yet it agrees with the baseline most closely of the three ( κ= 0.815 ), since it changes the judge’s threshold rather than its reason- ing. Terse shows the opposite pattern: it diverges most from the baseline ( κ= 0.699 ) while scor- ing slightly higher F1 than the auditor, indicating 28314
that removing the scaffold does not simply degrade accuracy but changes which cases the judge gets right. That the structured prompt and the minimal one land within 0.03 F1 of each other suggests the evidence supplied to the judge, rather than the in- struction wrapped around it, carries most of the signal. Prompt P R F1κvs. base Baseline (ours) 0.894 0.857 0.875 — Chain-of-thought 0.874 0.883 0.878 0.776 Strict auditor 0.864 0.817 0.840 0.815 Terse 0.859 0.832 0.845 0.699 Table 9: Prompt sensitivity of the security evaluator over the 153 human-labeled security cases. Per-class reliability map.Table 10 reports eval- uator agreement per CWE on the security cases. Accuracy is strongest on the high-frequency input- validation class and weakest on the code- and SQL- injection subsets, where the evaluator occasionally accepts insecure code. These subsets contain only 5–6 labeled cases each, so the per-class figures are noisy; we present them as a reliability map rather than precise per-class rates. Across all 307 cases the evaluator makes 36 errors: 16 false accepts and 20 over-flags, i.e. it errs slightly toward calling secure code insecure. CWE n P R F1 CWE-20 48 0.94 0.89 0.92 CWE-400 12 1.00 0.67 0.80 CWE-22 11 0.75 0.75 0.75 CWE-78 9 1.00 0.83 0.91 CWE-79 7 1.00 1.00 1.00 CWE-94 6 0.50 1.00 0.67 CWE-95 6 1.00 1.00 1.00 CWE-89 5 0.60 1.00 0.75 CWE-601 4 1.00 1.00 1.00 CWE-918 3 1.00 1.00 1.00 Table 10: Per-CWE evaluator reliability on the human- labeled security cases, for ten CWE classes with at least three labeled cases each. Ranking stability under evaluator error.We take the confusion matrix measured on the 307 cases and propagate it through the full leaderboard: each on-disk security verdict is flipped at the mea- sured conditional error rates, every model is re- scored, and the leaderboard is re-ranked, repeated 2,000 times per error profile (three judges and the prompt variants). The top-ranked model is un- changed in 100% of test-level simulations and 98.7– 100% of benchmark-level simulations, with Spear- manρ= 0.92 –0.98 against the observed ranking. The only movement occurs among mid-pack mod- els already separated by less than 0.01 SPR. The ordering is likewise stable across languages (cross- language ρ= 0.83 Python–C++, 0.89 Python– JavaScript, 0.84 C++–JavaScript), so the compara- tive conclusions depend neither on residual evalua- tor error nor on the choice of language. E.3 Computational Resources We report the compute used for sample generation, agentic execution, and runtime evaluation to sup- port replication and budgeting. For sample genera- tion, open-weight models were served with vLLM on three servers, each equipped with three NVIDIA A40 GPUs with 48 GB memory, for a total of nine A40 GPUs. Configurations requiring native FP8 support, as well as Nemotron-Super-49B config- urations whose memory footprint exceeded A40 capacity, were served separately on one NVIDIA H100 GPU with 80 GB memory. Across the main study and the Python-only factor sweeps, open- weight sample generation consumed approximately 30 aggregate GPU-hours. Closed-source sample generation for GPT and Claude models was per- formed through the OpenAI and Anthropic APIs. The agentic executor and LLM-based run- time evaluator are also LLM-backed workloads. Both components were instantiated with GPT- 5 nano through the OpenAI API. For one (model,language) configuration over all 307 benchmark items, agentic execution and runtime evaluation took approximately 50 minutes with 50 parallel workers. Wall-clock time depends on the number of workers, benchmark-level execution be- havior, and backend API rate limits. Across the 64 direct-model (model,language) configurations— 42 Python, 11 C++, and 11 JavaScript—API costs for the GPT-5 nano agent backend used by the agentic executor and LLM-based runtime evaluator averaged approximately $6.24 each, for a total of approximately $400. We include per-task execu- tion logs in the released artifact (Appendix F) so that future users can estimate replication cost at finer granularity. E.4 Statistical Robustness We provide two forms of statistical evidence for the main results. Bootstrap confidence intervals.We compute 95% bootstrap confidence intervals (5,000 resam- 28315
DualGauge: Automated Joint Security-Functionality Benchmarking of Specification-Only Code Generation by LLMs and Coding Agents [PDF pages 22-25; part 2/2] · PDF 第 2/2 段 · 第 22–25 页
v1 · 19121 字符 · 打开本段原文页面
PDF 仅提取全文文本并保留页码分段;未进行 OCR,图像、公式视觉与表格布局未解析。
图片与附件
1 项关联材料-
2026.findings-emnlp.1335.pdf
采集与来源记录
- 文件名称
- 2026.findings-emnlp.1335.pdf
- 记录大小
- 1577798 字节
- 文件格式
- application/pdf
- 关联登记时间
- 2026-11-05 08:02 UTC
- 关联原文
- v1
- 保存时校验
9118366702503890a945a9fe93f8b127ce3acbf5fcd0eabb44d420c0d2b8a683