← Lab /Software

Iterative LLM IaC repair causes security regressions in about 3% of scenarios

Iterative LLM-driven IaC repair introduces security regressions in roughly 3.3% of scenarios

Software arXiv 13 Aug 2026 Measurement Simulation evidence

Published as “Does Fixing Break Security? An Empirical Study of Security Degradation in Iterative LLM-Driven Infrastructure-as-Code Repair”

Why it matters

Practitioners should limit iterative IaC repair to three iterations and prioritize strict-mode checking or RAG with Gemini to keep genuine security regressions below ~3% of scenarios.

Summary

Iterative LLM-driven IaC repair does cause security regressions: 13.8% of scenario timelines regress under a standard inclusive detection, but only 3.3% under a strict exclusive-failure detection, showing most regressions are multi-resource artifacts. The study analyzes 5,968 timelines (4,440 iteration transitions) from the public IaC-Eval benchmark, providing strong empirical evidence. Resource restructuring accounts for 79.0% of regression transitions and these transitions have 2.6× more code churn and 4.9× higher strict-mode check volatility. About 36.6% of regressions self-correct within 1.2 iterations, and the authors recommend stopping the feedback loop after iteration 3.

What they found 5

  1. 13.8% of IaC scenario timelines experience at least one security regression under standard detection.

    “In the standard analysis, of the 5,968 scenario timelines, 823 (13.8%, 95% CI: [12.9%, 14.7%]) exhibit at least one security regression event.”

  2. Only 3.3% of scenarios regress under strict exclusive-failure detection, indicating most regressions are multi-resource ambiguities.

    “Under strict detection (excluding ambiguous multi-resource cases), 194 scenarios (3.3%, CI: [2.8%, 3.7%]) exhibit regression”

  3. Resource restructuring is the dominant root cause, responsible for 79.0% of regression transitions.

    “Resource restructuring (79.0%) is the dominant root cause.”

  4. Regression transitions show 2.6× more code churn and 4.9× higher strict-mode check volatility than non-regressing transitions.

    “Regression transitions show 2.6× more code churn (Cohen’s d = 0.90) and 4.9× higher strict-mode check volatility (d = 1.49).”

  5. Iteration 3 offers the best trade-off between compliance gain and regression risk.

    “Iteration 3 offers the best trade-off.”

Caveats 7

  • 36.6% of standard-mode regressions self-correct within an average of 1.2 iterations, showing many regressions are temporary.
  • Clean timelines (no syntax errors) actually regress more often (20.8%) than syntax-struggled timelines (12.1%), suggesting regressions are not solely caused by fixing syntax.
  • Under strict detection, neither RAG+Gemini nor RAG+Mistral produced any scenario regressions, contradicting the headline claim of pervasive regression.
  • Our root-cause classification relies on automated diff analysis: it was not validated against human labels, may misclassify boundary cases (e.g., resource renaming), and its thresholds (>0.85 similarity for drift, ≥2 resource-count change for restructuring) were chosen conservatively rather than empirically tuned.
  • The per-iteration logs record the generation model for RAG runs but not non-RAG runs, precluding a model-controlled RAG-vs-non-RAG comparison.
  • We use single runs per configuration for computational reasons, since repeated trials (e.g., n = 3) would require roughly 1.3M additional API calls, and although the negligible temperature effect (V = 0.049) suggests stability, point estimates may vary ±2-5pp.
  • Our results are specific to Terraform and Checkov. Other IaC tools (Ansible, CloudFormation) and validators (tfsec, Terrascan) may exhibit different regression patterns.

What’s new here 4

  • First large-scale per-iteration analysis of security regression in IaC repair, rather than cumulative-best metrics.
  • Introduces a dual detection methodology (standard inclusive vs. strict exclusive) to separate multi-resource artifacts from genuine failures.
  • Provides a taxonomy of regression root causes and identifies code churn and check volatility as strong predictors.
  • Derives practical iteration-budget guidance (optimal stopping at iteration 3) for security-aware feedback loops.