AI & Security
LLM-powered Infrastructure Code Fixes May Unintentionally Weaken Security
A new study reveals that automated repair loops using large language models can occasionally introduce new security vulnerabilities while addressing other issues in cloud infrastructure configurations.
Developers increasingly rely on large language models to automatically fix errors in Infrastructure-as-Code (IaC)—the configuration files that define cloud resources. But a fresh empirical analysis suggests these automated repair cycles come with a hidden cost: they sometimes degrade security in the process of fixing other problems.
The Problem with Iterative Fixes#
When IaC validators like Checkov detect errors, they feed those signals back to an LLM for another repair attempt. This feedback loop repeats over multiple iterations, with each pass chasing the cumulative best result. However, prior research only tracked overall improvements—metrics that are inherently non-decreasing by design. The actual security trajectory at each iteration, step by step, had never been closely examined.
What the Research Found#
Researchers analyzed nearly 6,000 repair scenarios from the IaC-Eval benchmark, tracking how security checks evolved across up to five successive repair attempts. They examined 4,440 iteration transitions across 15 different model configurations and found security regressions—checks that previously passed but later failed—occurred in both obvious and hidden ways:
- Standard detection mode (inclusive): 13.8% of scenarios showed at least one regression, affecting 24.8% of transitions
- Strict detection mode (exclusive, real failures only): 3.3% of scenarios exhibited regressions, accounting for 5.2% of transitions
The difference between these rates reveals an important nuance: most apparent regressions stem from how resources are restructured during repair, rather than genuine security lapses.
Root Causes and Patterns#
Resource restructuring dominated as the culprit, responsible for 79% of regression instances. Regression transitions displayed markedly higher code churn—2.6 times more than non-regressing fixes—and significantly greater volatility in security check outcomes. Interestingly, 36.6% of detected regressions self-corrected within an average of 1.2 iterations, suggesting the feedback loop can sometimes recover on its own. The research indicates that iteration 3 emerges as the optimal stopping point before diminishing returns set in.

