acceptodds
Under review as a conference paper at ICLR 2027

Promises and Pitfalls of Multi-Turn Refinement for Secure Code Generation

Abstract

AI coding assistants are now widely adopted, yet they frequently generate vulnerable source code. A promising approach to mitigate these issues is inference-time code refinement, where models iteratively improve outputs using feedback signals such as test cases, static analysis, or natural language critiques. However, the effectiveness of different feedback modalities and the fundamental limitations of this paradigm remain poorly understood. We present a comprehensive empirical study of multi-turn refinement for secure code generation across two axes: generator capability and feedback signal. Our experiments across four feedback types and two benchmarks show that iterative refinement improves secure code generation performance, but no single feedback signal uniformly dominates. We identify reward hacking as a primary bottleneck limiting progress where language models often exploit weaknesses in feedback signals by generating superficial fixes that satisfy the critic without addressing the underlying correctness or security issues. We present a taxonomy of reward hacking behaviors and show that these behaviors can become more pronounced with additional refinement iterations. These findings highlight a key trade-off in feedback-based code refinement: while feedback can improve performance, it can also incentivize undesirable optimization strategies. Addressing reward hacking is therefore essential for advancing reliable and secure AI-assisted code generation.

Primary area:
foundation or frontier models, including LLMs
Keywords:
Code Generation, LLM Security, Reward Hacking

Reviews

Among:
Shape:
1234this paper, Bottom 10%
Figure 1. Mean review rating of the reviewed papers at ICLR 2027. This paper averages 1.67 over 3 reviews, above 10% of the others.
Reviewer_75BnOpenReview ↗
Rating
3
Confidence
3
Informativeness
3
Presentation
3
Soundness
2
Read review
Paper summary

The paper studies inference time refinement for secure code generation as a game between a generator and a critic. The generator writes and revises code according to critic feedback for up to five rounds, and the final code is evaluated on held out benchmark tests that neither agent sees. The study compares four feedback types under a shared critic backbone: executable testcases, open ended natural language critique, critique grounded in observed test failures, and a hybrid that pairs tests with Semgrep findings. Experiments cover three generators of different capability on SeCodePLT and BaxBench and report capability, security, and correct and secure rates. Three findings emerge. Refinement improves the correct and secure rate over direct generation, but no feedback type uniformly dominates. Reward hacking is a primary bottleneck: generators often emit edits that satisfy the critic while failing held out tests. The authors formalize this behavior with a taxonomy of five categories, validate syntactic indicators on 150 manually checked trajectories, and show that critic satisfaction keeps rising with more rounds while true performance plateaus.

Critical strengths

1.To my knowledge this is the first systematic study of reward hacking in secure code generation, and it delivers an instrument rather than an anecdote. The taxonomy is illustrated with convincing worked examples, the syntactic indicators are validated on 150 manually annotated trajectories with false alarm rates below 6 percent, and a further decomposition attributes about 74 percent of cases to generator shortcuts rather than incomplete feedback. The community can reuse this measurement setup to detect a failure mode that aggregate pass rates cannot reveal.

2.The joint correctness and security objective exposes failure modes that a single metric cannot see, and the experimental design isolates the feedback axis cleanly. Blanket rejection looks like pure improvement under a safety only lens, and only the joint metric reveals it. Holding the critic backbone fixed across feedback types, evaluating only on held out tests, and spanning generators from 1.7B to frontier scale make the comparison credible. The finding that grounding natural language critique in observed test failures outperforms either raw signal is not obvious and directly useful in practice.

Critical weaknesses
  1. The central claim that reward hacking is a primary bottleneck is not adequately quantified. The phenomenon of models exploiting weak proxies is well known, so the contribution rests on quantitative rigor, and this is where gaps appear. The hacking pool is defined after the fact as games that end critic satisfied but benchmark failing, its absolute size per feedback type and generator is never reported, and the proxy reward uses a different scale for each feedback type, so satisfaction levels are not comparable across settings. Without pool sizes the reader cannot verify that hacking, rather than ordinary failure, explains the remaining gap. The data appears recoverable from existing logs, so the issue is fixable.

  2. The critic is thin and effectively singular, and no mitigation is tested even though the data already suggests one. The critic writes only two tests per round, so proxy strength is a confound: hacking prevalence may partly reflect this budget and the choice of a single critic family, and the stronger critic ablation covers only SeCodePLT with no significance testing. More importantly, the conclusion is prescriptive, yet no guard is tried. Fig 3a shows that true reward gains concentrate in the first round, so best of rounds selection or an early stop rule triggered by destructive indicators costs nothing new to compute and directly tests the bottleneck claim.

Questions for authors

1.What fraction of all games, per feedback type and generator, end in the reward hacking pool, and what share of all failures does the pool constitute? Does grounded critique induce fewer hacking cases in absolute terms?

2.Does hacking shrink when the critic writes more tests per round, for example five to ten? This separates generators hacking weak proxies from generators hacking any local proxy.

3.Are the gaps between feedback types in Table 2 statistically significant, for example 61.0 versus 60.2 versus 58.4 for Claude Opus 4.7 on BaxBench? Please state the sample size per benchmark.

4.From existing per round data, what correct and secure rate does first round stopping or best of rounds selection achieve per feedback type?

4 comments
AuthorsOpenReview ↗

Author Response (Part-1)

Thank you Reviewer 75Bn for your feedback. We appreciate that you recognize that our work is the first systematic study of reward hacking in secure code generation and that our experiment design isolates the feedback axis cleanly and evaluation includes generators from 1.7B to frontier scale, making the comparison credible. We address your concerns below.

Are the gaps between feedback types in Table 2 statistically significant? Please state the sample size per benchmark

We first note that SeCodePLT has 819 tasks and BaxBench has 392 tasks. Each cell in Table 2 (generator × feedback type) is evaluated on all tasks of its benchmark. Since all methods are run on the same tasks, we use paired tests to evaluate whether feedback types differ significantly. Specifically, for each generator × benchmark setting, we run pairwise McNemar tests [1,2] with Holm correction across the 6 pairs [3]. The McNemar test suits this setting because each task gives a paired binary outcome (Correct & Secure or not) under both feedback types. It tests significance using only the discordant tasks (solved by one method but not the other), so it accounts for the strong correlation between methods evaluated on the same tasks. Holm correction controls the family-wise error rate across the multiple pairwise comparisons.

BenchmarkGeneratorSignificant pairs (Holm-corrected p)
SeCodePLTGPT-4oTestcase > NL (2e-10); AGNL > NL (1e-7); Testcase > Hybrid (2e-4); Hybrid > NL (0.003)
SeCodePLTClaude-Opus-4.7AGNL > NL (8e-4); AGNL > Hybrid (0.026); Testcase > NL (0.033)
BaxBenchQwen3-1.7BAGNL > Testcase (2e-5); AGNL > Hybrid (8e-4); NL > Testcase (0.003)

We report the significant pairs for each model × dataset in the table above; AGNL denotes auto-grounded natural-language critique. First, as expected, pairs with larger performance differences are more likely to be significant. For GPT-4o on SeCodePLT, Testcase vs. NL (60.4 vs. 52.8, a 7.6-point gap) and AGNL vs. NL (6.1 points) are highly significant, whereas Testcase vs. AGNL (60.4 vs. 58.9) is not (p = 0.24). Similarly, for Claude-Opus-4.7 on SeCodePLT, AGNL vs. NL (4.4 points) is significant, while Testcase vs. AGNL (1.7 points) is not. For Qwen3-1.7B on SeCodePLT, every feedback type significantly improves over the baseline (Table 2), yet none differs significantly from another. Crucially, however, non-significance does not mean the methods behave the same or fix the same tasks. For Qwen3-1.7B on SeCodePLT, each feedback type fixes a similar number of the tasks that fail at baseline, but these are largely different tasks. Of the tasks fixed by at least one feedback type, only 24% are fixed by all four, and 28% are fixed by only one. Similarly, on BaxBench there is no substantial difference in performance across feedback types for GPT-4o and Claude-Opus-4.7, so we observe no significant differences. Here too, the feedback types fix different tasks. Only 9% (GPT-4o) and 20% (Claude-Opus-4.7) of the fixed tasks are fixed by all four feedback types, while 37-41% are fixed by only one. For Qwen3-1.7B on BaxBench, AGNL and NL significantly outperform testcase feedback: most of its baseline failures are applications that do not work at all, and prose critique helps a weak generator get a working program.

We also note that some CWEs are improved more by some feedback types than by others. For Qwen3-1.7B on SeCodePLT, testcase feedback fixes significantly more vulnerabilities than NL critique on CWEs that can be triggered through execution, including code/eval injection and resource exhaustion (e.g., CWE-94/95/770; p = 0.008). Conversely, NL critique fixes significantly more vulnerabilities than testcase feedback on CWEs that require reasoning about the code’s meaning, including broken cryptography, injection logic, information exposure and authorization (e.g., CWE-327/74/200/863; p = 0.001). These opposing effects cancel in aggregate, which helps explain the overall non-significance. On BaxBench, critique-based feedback likewise helps most on credential protection and resource exhaustion (e.g., for Claude-Opus-4.7 on CWE-522), while testcase feedback remains competitive on execution-visible injection such as XSS and SQL injection (CWE-79/89). We present these per-CWE results as exploratory. They suggest that the feedback types are complementary, and that choosing feedback by vulnerability category is a promising direction for future work. We have added this expanded discussion to the revised paper.

[1] McNemar, Q. (1947). Note on the sampling error of the difference between correlated proportions or percentages. Psychometrika, 12(2).

[2] Dietterich, T. G. (1998). Approximate statistical tests for comparing supervised classification learning algorithms. Neural Computation, 10(7).

[3] Holm, S. (1979). A simple sequentially rejective multiple test procedure. Scandinavian Journal of Statistics, 6(2).

AuthorsOpenReview ↗

Author Response (Part-2)

From existing per round data, what correct and secure rate does first round stopping or best of rounds selection achieve per feedback type? Does hacking shrink when the critic writes more tests per round, for example five to ten?

Using our existing per-round trajectories, we compute the C&S rate under two alternatives to running the full refinement game. First-round stopping keeps the code after the first revision. Best-of-rounds is an oracle that selects any round whose code passes the held-out tests. Since best-of-rounds uses the held-out ground-truth tests, it is an upper bound on what any round-selection strategy could achieve. The table reports First-round / Full refinement (Table 2) / Best-of-rounds.

BenchmarkGeneratorTestcaseNLAGNLHybrid
SeCodePLTGPT-4o57.4 / 60.4 / 64.253.1 / 52.8 / 59.053.8 / 58.9 / 62.654.0 / 56.3 / 60.0
SeCodePLTClaude-Opus-4.761.5 / 61.3 / 64.659.6 / 58.6 / 61.760.6 / 63.0 / 66.359.6 / 59.8 / 61.4
SeCodePLTQwen3-1.7B34.2 / 39.1 / 43.736.4 / 39.6 / 48.835.7 / 39.4 / 46.430.4 / 36.8 / 42.0
BaxBenchGPT-4o23.7 / 25.0 / 34.422.7 / 23.0 / 38.326.8 / 27.0 / 38.025.3 / 24.5 / 35.5
BaxBenchClaude-Opus-4.757.7 / 58.4 / 65.355.9 / 56.9 / 69.959.7 / 61.0 / 70.760.7 / 60.2 / 68.4
BaxBenchQwen3-1.7B2.0 / 2.0 / 2.32.3 / 5.9 / 7.21.8 / 7.7 / 8.42.8 / 2.8 / 3.6

We note that full refinement beats first-round stopping in most settings and slightly underperforms or ties in others. The gains are largest for the weakest generator. For Qwen3-1.7B, full refinement adds 3.2-6.4 points on SeCodePLT, and on BaxBench AGNL improves from 1.8 to 7.7. As expected, best-of-rounds exceeds full refinement, by 1.6-9.2 points on SeCodePLT and by up to 15.3 points on BaxBench. This gap measures code that was correct and secure at some round but was later broken by further refinement. It therefore gives an upper bound on the cost of the over-refinement and reward hacking analyzed in Section 4. Overall, these results support our conclusion that more refinement does not monotonically improve code. A practical stopping or selection rule that does not rely on the held-out tests could recover part of this gap, for example by regression-checking each revision against tests from earlier rounds. We see this as a promising direction and have added this analysis to the revised paper.

To test whether more feedback per round reduces reward hacking, we ran an additional ablation on SeCodePLT with GPT-4o as the generator. Since o4-mini has been retired from the OpenAI API, we use gpt-5.4-mini as the critic and re-run the default feedback types with it for a matched comparison. More executable tests help testcase feedback. With five capability and five safety tests per round instead of one each, testcase feedback reaches 62.5% C&S, compared with 59.6% by default and 55.1% for the baseline. It fixes more tasks (88 vs. 77) and regresses fewer (28 vs. 41), suggesting that richer tests leave less room for shortcut fixes. In contrast, asking the natural-language critic for more findings per round (8-12) hurts. NL and AGNL fall to 42.9% and 45.9%, below the baseline, and regress 173 and 149 tasks, compared with 33 and 12 by default. Most of the damage is to functionality: capability drops from 69.7% to 55.4% (NL) and 60.1% (AGNL), while security barely changes. Since the critic must keep producing findings, it rarely declares itself satisfied, and many of its findings go beyond the task specification or contradict earlier rounds. In one template-rendering task, for example, the critic asks the generator to both reject and allow literal braces, and the generator ends up failing both capability and security. More executable tests thus reduce regressions under testcase feedback, while more unverifiable critique leads the generator to break working code. We have added this ablation to the revised paper.

AuthorsOpenReview ↗

Author Response (Part-3)

Proportion of different failure modes. Does grounded critique induce fewer hacking cases in absolute terms?

Each feedback type is evaluated on 819 games on SeCodePLT and 392 games on BaxBench per generator. We compare the final code of each game with the zero-shot baseline on the same task and call a task “fixed” if the baseline fails it but the refined code is correct and secure, and “regressed” if the baseline is correct and secure but the refined code is not. The core failure mode in this setting is performance regression: across all generators and feedback types, feedback regresses roughly one task for every two it fixes (1,343 fixed vs. 653 regressed). For example, with testcase feedback, GPT-4o on SeCodePLT fixes 56 tasks while regressing 14. With AGNL, Claude-Opus-4.7 fixes 54 tasks while regressing 21 on SeCodePLT, and 58 while regressing 37 on BaxBench. The net gains in Table 2 are therefore much smaller than they would be if refinement preserved the tasks the baseline already solved. For example, AGNL fixes 62 tasks for GPT-4o on BaxBench, which alone would be a gain of 15.8 points, but it also regresses 31, so the net gain is 7.9 points. In some settings feedback hurts outright: plain NL regresses more tasks than it fixes for both GPT-4o (33 vs. 12) and Claude-Opus-4.7 (12 vs. 10) on SeCodePLT.

Regressions arise both in games where the critic is eventually satisfied and in games that run to the round budget. In the latter, the generator often satisfies one round’s concerns only for the critic to raise new ones, so regressions can accumulate through edits that address earlier feedback without solving the task. For the manual reward-hacking analysis, we focus on the former: games that converge before the final round, yet whose final code regresses in correctness or security relative to the game’s initial code. Here the generator has fully satisfied the critic, so the gap between the critic’s signal and the true objective is directly observable. This yields 124 cases on SeCodePLT and 147 on BaxBench. In terms of proportions, regressions account for about 8% of all games whose final code fails; the remaining failures are tasks the baseline also fails and refinement does not fix. Reward-hacking cases account for about 3.4% of failing games. Per generator, the pool covers 2.4% of all games for GPT-4o and 2.3% for Claude-Opus-4.7, vs. 0.9% for Qwen3-1.7B, since the weaker generator produces far less correct and secure code that refinement could regress. Per feedback type, it covers 1.8-2.0% of games (73 cases for AGNL, 68 for testcase, 66 for NL and 64 for Semgrep-hybrid), and individual generator × feedback × benchmark settings range up to 7.4% (GPT-4o with AGNL on BaxBench). Grounded critique therefore does not reduce reward hacking in absolute terms. Its advantage comes from fixing more tasks: AGNL fixes the most tasks in 5 of the 6 generator × benchmark settings, while its regressions and reward-hacking cases remain comparable to the other feedback types.

Area_Chair_bEvHOpenReview ↗

take part in the discussion

Dear reviewer 75Bn,

please take part in the discussion. time is runnning out.

thank you your ac

Reviewer_bq2GOpenReview ↗
Rating
1
Confidence
4
Informativeness
1
Presentation
2
Soundness
1
Read review
Paper summary

This paper presents an empirical investigation of inference-time refinement for secure code generation, focusing on how different feedback signals affect code correctness, security, and reward hacking. It introduce a unified generator–critic framework and investigate four feedback mechanisms: executable testcases, natural-language critique, auto-grounded natural-language critique, and Semgrep-hybrid feedback.

Critical strengths

1- Feedback modalities. The paper systematically evaluates four feedback mechanisms within a unified generator–critic framework.

Critical weaknesses

1- Limited methodological novelty. The generator–critic refinement framework builds on established approaches to iterative code generation and verification. The primary contribution is empirical analysis rather than a fundamentally new algorithm or training method.

Questions for authors

Q1. Which vulnerability categories are easiest and hardest to detect and repair? Q2. What is the novelty of the paper?

3 comments
AuthorsOpenReview ↗

Author Response (Part-1)

Thank you Reviewer bq2G for your feedback. We address your concerns below.

Which vulnerability categories are easiest and hardest to detect and repair?

On SeCodePLT, we now measure for each vulnerability category how often the critic flags insecure baseline code in the first round (detection) and how often refinement makes it correct and secure (repair). Injection (CWE-74) and XSS (CWE-79) are the easiest to repair, along with weak cryptography (CWE-327) under executable feedback. For the frontier generators, refinement repairs up to 39%, 43% and 38% of insecure tasks in these categories, because each has a standard, local fix: escaping or parameterizing input, or replacing a weak hash function. Resource exhaustion (CWE-770) and ReDoS (CWE-1333) are the hardest: they are rarely detected by the LLM-based critics (4-43% in the first round) and almost never repaired (mostly 0-5%). A second group of categories is often detected but rarely repaired, including improper signature verification (CWE-347), incorrect authorization (CWE-863) and command injection (CWE-77). For example, AGNL flags every insecure signature-verification task for GPT-4o, yet no frontier generator repairs any of them under any feedback type. Similarly, testcase feedback flags 82% of insecure incorrect-authorization tasks for GPT-4o, but none are repaired. What these hard categories share is that the fix requires a task-specific design decision rather than a local patch, such as choosing a resource limit, restructuring a regular expression, or defining the correct authorization policy. Generators therefore either leave the vulnerability in place or over-restrict the code and break its functionality, matching the over-restrictive implementations analyzed in Section 4.

Across categories, detection consistently exceeds repair. With testcase, NL and AGNL feedback, the critic flags 38-52% of insecure tasks in the first round for the frontier generators, but only 4-21% end up correct and secure. This further indicates that the generator, rather than the critic, is the main bottleneck. The per-CWE view also explains why Semgrep-hybrid feedback is weaker on SeCodePLT. Semgrep flags only 5-9% of insecure tasks for the frontier generators, because most SeCodePLT categories, such as authorization, ReDoS, weak cryptography and signature verification, fall outside its rules. The exception is command injection, where it flags 77-82%. Finally, refinement rarely introduces new vulnerabilities into code that was already secure (1-2% of tasks for the frontier generators, and at most 4%), so the damage from feedback falls mainly on correctness rather than security.

AuthorsOpenReview ↗

Author Response (Part-2)

Novelty and contributions

Indeed, the goal of our paper is a systematic empirical evaluation of generator-critic refinement for secure code generation, with carefully controlled analysis. This paradigm is already widely deployed in coding assistants, primarily to improve functional correctness, yet how it behaves under a joint correctness-and-security objective is not well understood. Our paper characterizes when it helps, when it fails and why, and these findings point directly to new methods.

Existing benchmark papers such as SeCodePLT and BaxBench primarily evaluate single-turn generation and report aggregate performance. Our work studies iterative refinement on these tasks systematically, varying one factor at a time (feedback type, generator capability and critic model) while keeping the tasks, round budget and held-out evaluation fixed. This distinguishes our work from prior refinement studies [1,2,3], which do not target security, and from feedback-based secure coding systems [4,5,6], which typically instantiate a single feedback recipe and report aggregate repair performance. This setup reveals behavior that aggregate pass rates do not. As refinement proceeds, the critic’s satisfaction keeps rising while held-out C&S plateaus. In reward-hacking games, C&S falls from 57% to zero even as the critic becomes fully satisfied. Later rounds shift from local patches toward over-restrictive implementations (5.4% → 31.1%) and major rewrites (2.4% → 28.3%). Beyond these findings, the reward-hacking taxonomy and its syntactic indicators, validated on manually annotated trajectories, provide a reusable way to detect failures that aggregate pass rates cannot reveal.

Concretely, feedback regresses roughly one task for every two it fixes, and an oracle that selects the best round exceeds full refinement by up to 9.2 points on SeCodePLT and 15.3 points on BaxBench. This motivates early-exit or round-selection methods, for example regression-checking each revision against tests from earlier rounds. Feedback types that perform similarly in aggregate also fix largely different tasks, with strengths that depend on the type of vulnerability, which motivates selecting or combining feedback by vulnerability category. We have revised the introduction to state these contributions more clearly.

[1] Madaan et al. Self-Refine: Iterative refinement with self-feedback. NeurIPS 2023.

[2] Chen et al. Teaching large language models to self-debug. arXiv:2304.05128, 2023.

[3] Olausson et al. Is self-repair a silver bullet for code generation? arXiv:2306.09896, 2023.

[4] Saul et al. SCGAgent: Recreating the benefits of reasoning models for secure code generation with agentic workflows. arXiv:2506.07313, 2025.

[5] Nunez et al. AutoSafeCoder: A multi-agent framework for securing LLM code generation through static analysis and fuzz testing. arXiv:2409.10737, 2024.

[6] Alrashedy et al. Leveraging static analysis for feedback-driven security patching in LLM-generated code. Journal of Cybersecurity and Privacy, 2025.

Area_Chair_bEvHOpenReview ↗

take part in the discussion

Dear reviewer bq2G,

please take part in the discussion. time is running out.

thank you your ac

Reviewer_y7YcOpenReview ↗
Rating
1
Confidence
4
Informativeness
1
Presentation
3
Soundness
2
Read review
Paper summary

This paper studies iterative secure code refinement using testcase feedback, natural-language critique, test-grounded critique, and a test/static-analysis hybrid. Experiments on SeCodePLT and BaxBench vary the generator and include a stronger-critic comparison. The authors find that feedback generally improves joint correctness and security, but can also make the critic more satisfied while generated code fails hidden tests. They analyze these failures through five syntactic indicators and manually inspected trajectories. The paper adds experiments on existing benchmarks, but I do not find sufficient novelty or new insight in the analysis. The failure taxonomy is descriptive, and the evidence does not support the central claims about reward hacking as the primary bottleneck or about its causes. The contribution is insufficient for acceptance.

Critical strengths
  • Useful empirical question: Comparing feedback modalities under the same framework is relevant to secure coding systems. Evaluating with hidden functional and security tests also helps distinguish satisfying the critic from solving the actual task.

  • Concrete failure analysis: The examples show how apparently reasonable security fixes can break required behavior. Tracking full trajectories, checking 150 cases manually, and testing a stronger critic make the analysis more informative than reporting final pass rates alone.

Critical weaknesses
  • Limited contribution: The paper adds multi-turn experiments on SeCodePLT and BaxBench, but the contribution beyond these evaluations is limited. Comparing standard feedback formats and grouping failing edits into five categories does not, by itself, establish a substantial new insight. The paper should explain what its analysis reveals beyond the benchmark papers and prior refinement studies, and support that contribution with controlled evidence. The current descriptive taxonomy and insufficiently validated attribution of failures to reward hacking do not establish this added value.

  • The “primary bottleneck” claim is not established: The paper analyzes cases selected because the final critic is satisfied and the final code fails benchmark tests. Figure 3b is informative about those failures, but cannot establish how often refinement harms the full task population or how much of the remaining failure rate is explained by this mechanism. Across all games, C&S actually rises from 37.4 to 46.3. The paper should report absolute regression rates and the share of all failures attributable to the identified behaviors.

  • The indicator validation does not establish per-category accuracy: Appendix B.3 counts a false alarm only when none of the triggered indicators describes the failing edit. A wrong label can therefore be counted as acceptable when another label is correct. The reported below-6% false-alarm rates do not validate the accuracy of each category, which matters because the main analysis compares their prevalence across rounds and models.

  • The aggregate results do not separate security from functionality: Section 3 defines capability, security, and their joint rate, but Table 2 reports only the joint rate. The case studies include both functional regressions and security regressions. Reporting the separate outcomes by feedback type would clarify whether a method actually introduces vulnerabilities, becomes overly restrictive, or simply fails to complete the task.

Questions for authors

See Weaknesses

4 comments
AuthorsOpenReview ↗

Author Response (Part-1)

Thank you Reviewer y7Yc for your feedback. We are glad that you find our empirical question useful and our failure analysis concrete, including the full-trajectory tracking. We address your concerns below.

Relation to prior work and contribution clarifications

Existing benchmark papers such as SeCodePLT and BaxBench primarily evaluate single-turn generation and report aggregate performance. Our work studies iterative refinement on these secure code generation tasks systematically, varying one factor at a time (feedback type, generator capability and critic model) while keeping the tasks, round budget and held-out evaluation fixed. We analyze not only whether refinement improves performance, but also how and when it fails. This distinguishes our work from prior refinement studies [1,2,3], which do not target security, and from feedback-based secure coding systems [4,5,6], which typically instantiate a single feedback recipe and report aggregate repair performance. To our knowledge, refinement under a joint correctness-and-security objective has not been studied systematically. This setup reveals behavior that aggregate pass rates do not. As refinement proceeds, the critic’s satisfaction keeps rising while held-out C&S plateaus. In reward-hacking games, C&S falls from 57% to zero even as the critic becomes fully satisfied. The nature of the failures also changes over the course of a game: later rounds shift from local patches toward over-restrictive implementations (5.4% → 31.1%) and major rewrites (2.4% → 28.3%). We also find that grounding natural-language critique in observed test failures is the most consistently well-performing feedback type, which is not apparent from either signal alone.

Following the reviewers’ suggestions, we have also added analyses that point toward concrete future directions. First, feedback types that perform similarly in aggregate fix largely different tasks, and their strengths can depend on the type of vulnerability. For Qwen3-1.7B on SeCodePLT, for example, testcase feedback fixes more vulnerabilities that surface during execution, such as code injection and resource exhaustion, while natural-language critique fixes more vulnerabilities that require reasoning about code semantics, such as broken cryptography and incorrect authorization. This suggests that selecting or combining feedback by vulnerability category is a promising direction. Second, feedback regresses roughly one task for every two it fixes. Full refinement generally outperforms stopping after the first round, yet an oracle that selects the best round exceeds full refinement by up to 9.2 points on SeCodePLT and 15.3 points on BaxBench. This suggests that early-exit or round-selection methods are a practical direction, for example regression-checking each revision against tests from earlier rounds. We have revised the introduction to state these contributions and their relation to prior work more clearly.

[1] Madaan et al. Self-Refine: Iterative refinement with self-feedback. NeurIPS 2023.

[2] Chen et al. Teaching large language models to self-debug. arXiv:2304.05128, 2023.

[3] Olausson et al. Is self-repair a silver bullet for code generation? arXiv:2306.09896, 2023.
[4] Saul et al. SCGAgent: Recreating the benefits of reasoning models for secure code generation with agentic workflows. arXiv:2506.07313, 2025.

[5] Nunez et al. AutoSafeCoder: A multi-agent framework for securing LLM code generation through static analysis and fuzz testing. arXiv:2409.10737, 2024.

[6] Alrashedy et al. Leveraging static analysis for feedback-driven security patching in LLM-generated code. Journal of Cybersecurity and Privacy, 2025.

AuthorsOpenReview ↗

Author Response (Part-2)

Absolute regression rates and the share of all failures attributable to the identified behaviors

Each feedback type is evaluated on 819 games on SeCodePLT and 392 games on BaxBench per generator. We compare the final code of each game with the zero-shot baseline on the same task. A task is fixed if the baseline fails it (C&S = 0) but the refined code is correct and secure, and regressed if the baseline is correct and secure but the refined code is not. Across all generators and feedback types, refinement fixes 1,343 tasks but regresses 653, breaking about 11% of the tasks the baseline already solves. For example, with testcase feedback, GPT-4o on SeCodePLT fixes 56 tasks while regressing 14. With AGNL, Claude-Opus-4.7 fixes 54 tasks while regressing 21 on SeCodePLT, and 58 while regressing 37 on BaxBench. In some settings feedback hurts outright: plain NL regresses more tasks than it fixes for both GPT-4o (33 vs. 12) and Claude-Opus-4.7 (12 vs. 10) on SeCodePLT. We have added these regression statistics to Section 4 of the revised paper.

Our analysis centers on what limits further improvement from refinement. As the reviewer notes, C&S rises on net, but regressions offset roughly half of all fixes, and about 62% for the frontier generators. For example, AGNL fixes 62 tasks for GPT-4o on BaxBench, which alone would be a gain of 15.8 points, but it also regresses 31, so the net gain is only 7.9 points. The oracle analysis shows the same pattern: selecting the best round exceeds full refinement by up to 9.2 points on SeCodePLT and 15.3 points on BaxBench, which is performance the games reached and then lost. Among all games whose final code fails, regressions account for about 8%; the remainder are tasks the baseline also fails and refinement does not fix. Regressions arise both in games where the critic is eventually satisfied and in games that run to the round budget. In the latter, the generator often satisfies one round’s concerns only for the critic to raise new ones, so regressions can accumulate through edits that address earlier feedback without solving the task. For the manual analysis, we focus on the former: games that converge before the final round with the critic satisfied, yet whose final code regresses in correctness or security relative to the game’s initial code. Here the generator has fully satisfied the critic, so the gap between the critic’s signal and the true objective is directly observable. This yields 124 cases on SeCodePLT and 147 on BaxBench, about 3.4% of all failing games. These cases are concentrated in the frontier generators (summed over feedback types and benchmarks, 117 for GPT-4o and 111 for Claude-Opus-4.7, vs. 43 for Qwen3-1.7B), since the weaker generator produces far less correct and secure code that refinement could regress.

Indicator validation.

We agree that evaluating the triggered indicators jointly does not measure each category’s accuracy. We therefore re-scored the 150 manually annotated trajectories per indicator. An indicator now counts as a false alarm whenever it fires but does not describe the failing edit, regardless of whether other indicators do. The per-category false-alarm rates are 4.1% for output-control flow changes (H1), 9.0% for dependency introduction (H2), 4.1% for validation patches (H3), 8.2% for over-restrictive implementations (H4) and 3.3% for major rewrites (H5). Most errors are confusions between related categories. For example, validation patches and over-restrictive implementations both rewrite validation logic, but in opposite directions. The trends our analysis relies on are large relative to these error rates. We now report these per-category rates in the revised paper.

AuthorsOpenReview ↗

Author Response (Part-3)

Reporting separate correctness and security

We now report capability (CAP) and security (SAF) separately for each feedback type, and have added these results to Appendix B.6 of the revised paper.

BenchmarkFeedbackGPT-4oClaude-Opus-4.7Qwen3-1.7B
SeCodePLTBaseline69.7 / 76.875.5 / 75.545.9 / 59.7
Testcase73.3 / 80.974.2 / 79.956.4 / 61.9
NL66.9 / 77.973.6 / 76.353.1 / 71.4
AGNL70.9 / 80.774.2 / 80.153.8 / 69.8
Hybrid71.3 / 74.875.6 / 76.358.7 / 60.6
BaxBenchBaseline38.3 / 68.681.1 / 73.03.3 / 91.8
Testcase30.6 / 88.073.7 / 81.92.6 / 94.9
NL27.0 / 92.367.3 / 88.86.9 / 94.3
AGNL32.9 / 88.572.7 / 87.87.9 / 94.6
Hybrid30.1 / 89.574.5 / 83.94.1 / 92.5

Each cell: CAP / SAF (%).

On SeCodePLT, feedback improves C&S for the frontier generators mainly through security. Testcase and AGNL feedback raise SAF by about 4-5 points, while changes in CAP are smaller (−1.3 to +3.6). On SeCodePLT, feedback rarely introduces new vulnerabilities: SAF is at or above the baseline in every setting except Semgrep-hybrid with GPT-4o (76.8 to 74.8), where capability improves at a small cost in security. Plain NL with GPT-4o lowers CAP (69.7 to 66.9) with little gain in SAF, which explains why its C&S falls below the baseline. For Qwen3-1.7B, all feedback types improve capability, but only the natural-language feedback types substantially improve security (+10-12 points vs. +1-2 for testcase and hybrid feedback).

On BaxBench, feedback trades capability for security in the frontier generators, while C&S still improves on net (Table 2). SAF rises sharply (GPT-4o: 68.6 to 88.0-92.3; Claude-Opus-4.7: 73.0 to 81.9-88.8), while CAP falls (GPT-4o: 38.3 to 27.0-32.9; Claude-Opus-4.7: 81.1 to 67.3-74.5). A non-functional application trivially withstands exploits, so we also measure security among functionally correct solutions. This rises from 49.9% to 81-85% for GPT-4o and from 68.6% to 79-85% for Claude-Opus-4.7, confirming genuine security improvements on working applications. The loss in capability reflects the over-restrictive implementations and major rewrites analyzed in Section 4. It is largest under plain NL critique (−13.8 points for Claude-Opus-4.7), which also produces the most over-restriction (Appendix B.4). For Qwen3-1.7B on BaxBench, CAP stays below 8% under every feedback type, so its failures are mostly failures to produce a working application.

Thanks for your reply and I am keeping my score. This paper is a clear AI slop, running few models on a few SCG benchmarks and using cc or codex to analyze failure pattern clearly is not a contribution to the community. I am surprised this is not desk rejected

From OpenReview, CC BY 4.0. Authors as signed there; shown unedited.

Related papers

Loading the map…

Discussion (0)

Sign in to comment.